I'm goofing up terminology here: where I said member object, I should have said instance object.
-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Dan Kimmel
Sent: Tuesday, March 08, 2011 10:49 AM
To: Java Programming on and around the IBM i
Subject: RE: Signature mismatch when calling java prototype
Here's a working prototype.
* Create the workpiece
dcreateWorkpiece...
d pr 90a extproc(*java :
d 'com.rjssoft.workflow.util.+
d WorkpieceCreationInfo' :
d 'createWorkpiece')
d varying
d user 90a const varying
d password 90a const varying
It takes two byte array parameters and returns a byte array, all 90 characters long.
When this function is executed from RPG, the member object (newWorkpieceCreationInfo) has already been created and is the first parameter passed. The return value is newWorkpieceID.
newWorkpieceID =
createWorkpiece...
(newWorkpieceCreationInfo :
%trim(checkinUser) :
%trim(checkinPassword) );
-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of mikemonger@xxxxxxx
Sent: Tuesday, March 08, 2011 10:18 AM
To: java400-l@xxxxxxxxxxxx
Subject: Re: Signature mismatch when calling java prototype
See, here's the funny part about that static keyword.
If I don't include it, the program won't compile unless I include the return variable as the first parameter in the prototype call.
But when I do that....I get the exact same error. And what's funny is that it reports the same signature being sent (String,String)String. Which doesn't make a whole lot of sense to me, but, whatever.
I've never had problems calling java classes with prototypes in the past. But this is the first time that I've actually tried to get something back from one.
And the issue doesn't seem to be whether to method is static or not in the class. I'm getting the same thing no matter how I define it.
-----Original Message-----
From: Dan Kimmel <dkimmel@xxxxxxxxxxxxxxx>
To: Java Programming on and around the IBM i <java400-l@xxxxxxxxxxxx>
Sent: Tue, Mar 8, 2011 11:07 am
Subject: RE: Signature mismatch when calling java prototype
otice 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 unction only exists in the class object. Thus, the error, no such method xists.
I think there's a way to invoke a static method from RPG, but I've never tried nd don't know the syntax.
Another tip: Unless you want to go through another set of Java calls, declare our function to take and return byte arrays. Byte arrays work just fine in both PG and Java so you don't have to go through another set of calls to get the RPG ariable from the String.
So your java should look something like this:
byte[] myFunction( byte[] input){
return "Something".getBytes();
}
----Original Message-----
rom: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On ehalf Of mikemonger@xxxxxxx
ent: Tuesday, March 08, 2011 9:11 AM
o: java400-l@xxxxxxxxxxxx
ubject: Signature mismatch when calling java prototype
Ok, I'm officially at my wits end. I've written a java class which accepts an rray of string objects and returns a string. Here is the prototype in the RPG
rogram:
d ResendOrder pr o extproc(*JAVA:
'com.WMS_BPCS_Integrator.ex-
ecutable.ResendOrder':'main')
class(*JAVA:'java.lang.String')
o class(*JAVA:'java.lang.String')
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
ava.lang.Object{
ublic com.DelMonte.WMS_BPCS_Integrator.executable.ResendOrder();
Signature: ()V
ublic 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 he return value from both the prototype and the class has the class running ormally.
So...is it possible to actually prototype a java class so that it actually does eturn a value to the calling RPG program, or am I banging my head against the all 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 ike that.
--
his is the Java Programming on and around the IBM i (JAVA400-L) mailing list To ost a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or hange list options,
isit:
http://lists.midrange.com/mailman/listinfo/java400-l
r email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to eview the archives at
http://archive.midrange.com/java400-l.
--
his is the Java Programming on and around the IBM i (JAVA400-L) mailing list o post a message email: JAVA400-L@xxxxxxxxxxxx o subscribe, unsubscribe, or change list options,
isit:
http://lists.midrange.com/mailman/listinfo/java400-l
r email: JAVA400-L-request@xxxxxxxxxxxx
efore posting, please take a moment to review the archives t
http://archive.midrange.com/java400-l.
--
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.