Notice that little word "static" in the definition of your "main" function?
This prototype is trying to invoke the method "main" on a member object. The function only exists in the class object. Thus, the error, no such method exists.
I think there's a way to invoke a static method from RPG, but I've never tried and don't know the syntax.
Another tip: Unless you want to go through another set of Java calls, declare your function to take and return byte arrays. Byte arrays work just fine in both RPG and Java so you don't have to go through another set of calls to get the RPG variable from the String.
So your java should look something like this:
byte[] myFunction( byte[] input){
return "Something".getBytes();
}
-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of mikemonger@xxxxxxx
Sent: Tuesday, March 08, 2011 9:11 AM
To: java400-l@xxxxxxxxxxxx
Subject: Signature mismatch when calling java prototype
Ok, I'm officially at my wits end. I've written a java class which accepts an array of string objects and returns a string. Here is the prototype in the RPG program:
d ResendOrder pr o extproc(*JAVA:
d 'com.WMS_BPCS_Integrator.ex-
d ecutable.ResendOrder':'main')
d class(*JAVA:'java.lang.String')
d o class(*JAVA:'java.lang.String')
d dim(2)
However, when I call it, I'm receiving the following error:
Cause . . . . . : RPG procedure GWBA09D5 in program MXMLIB/GWBA09D5 received
Java exception "java.lang.NoSuchMethodError: main" when calling method
"main" with signature "([Ljava.lang.String;)Ljava.lang.String;" in class
"com.WMS_BPCS_Integrator.executable.ResendOrder".
NOW HERE'S THE FUNNY PART.
When I pull up the class with javap -s, here's what I get for the signatures:
public class com.WMS_BPCS_Integrator.executable.ResendOrder extends
java.lang.Object{
public com.DelMonte.WMS_BPCS_Integrator.executable.ResendOrder();
Signature: ()V
public static java.lang.String main(java.lang.String[]);
Signature: ([Ljava/lang/String;)Ljava/lang/String;
}
Notice how the signatures match? So do I.
This class works just fine as long as I don't try to RETRIEVE a parm. Removing the return value from both the prototype and the class has the class running normally.
So...is it possible to actually prototype a java class so that it actually does return a value to the calling RPG program, or am I banging my head against the wall for nothing?
I've tried everything that I can think of so far. I even tried changing it to a *constructor procedure and passing in the parms that way, but it really didn't like that.
--
This is the Java Programming on and around the IBM i (JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at
http://archive.midrange.com/java400-l.
As an Amazon Associate we earn from qualifying purchases.