|
I have a working RPG program which calls a Java program. Here are some extractions from those programs: Java program: public class SboXmlXlator { // <-- class header ... public SboXmlXlator() { // constructor ... public byte[] xml2Fixed(byte[] bobj, byte[] bact, byte[] breq) { // <-- one of the called method signatures ... RPG IV program: d SboXmlXlator c 'SboXmlXlator' d xml s o class(*java : SboXmlXlator) <-- Java object instantiated by constructor d constructor pr o extproc(*java : SboXmlXlator : <-- Java constructor d *constructor) d xml2Fixed pr 32767a varying <-- prototype for Java method xml2Fixed d extproc(*java : SboXmlXlator : <-- returns a byte array (highly recommended d 'xml2Fixed') d 14a varying <-- passes byte arrays (highly recommended d 10a varying d 32767a varying ... xml = constructor(); <-- calls Java constructor, return instantiated ... Object of type SboXmlXlator response = fixed2Xml(xml : object : tag : request); <-- calls Java method; notice first parameter <-- is the object returned by the constructor <-- and not defined in the method prototype. Byte arrays are highly recommended as they are compatible with RPG IV varying length strings. I started out calling the Java String constructor three times to create a Java String object for the three input parameters to the xml2Fixed method. Also, the xml2Fixed method returned a Java String object, which I then had to call the Static GetBytes method to create The RPG string variables. By passing and returning the RPG strings as byte arrays, I saved four entries into Java. Also, the four extra Java objects being created were not being garbage collected. The byte arrays are not garbage collected just fine. This works very well. Also, notice the Java constructor method must be call first to instantiated the Java object of the type of the Java class. That object then is passed as the initial parameter of each method call. Remember in Java, you would reference the Java method as object.methodname. These programs are run in batch and do not exit until the job is ended. The first entry into Java loads the Java Virtual Machine which takes a little time. As long as the RPG program does not exit (with LR on), the JVM should stay loaded, along with the called Java object. Good luck, Bill -----Original Message----- From: Ashish Kulkarni [mailto:kulkarni_ash1312@xxxxxxxxx] Sent: Monday, January 19, 2004 11:47 AM To: Java Programming on and around the iSeries / AS400 Subject: RE: Error while calling java from RPG Java exception "java.lang.UnknownError:" Hi The problem is i cannot ask the end users to signoff and signon here is my RPG code, what wrong may i be doing H thread(*serialize) /define OS400_JVM_12 /Copy JNI /Copy Prototype d env s * D crtPgm pr o extproc(*java: d 'com.pfizer.maps.data.PORPGToJava' d :*Constructor ) d dateFormat o class(*java:'java.lang.String') d const // i call a CL program to set env variable c eval env = getJniEnv('-Djava.version=1.4;') c callp beginObjGroup(env:1000) C eval dateFormat=crtString(Datfmt) //it fails on this line.... C eval popgm=crtPgm(@dateFormat) // othe logic to call methods c callp endObjGroup (env) C EVAL *INLR = *ON C RETURN Ashish --- "Bartell, Aaron L. (TC)" <ALBartell@xxxxxxxxxxxxxx> wrote: > Did you exit out of the program prematurely while in > debug or something of > that nature? If so then a clearing of your > environment is a must to make > sure everything is in order, and the easiest and > safest way to do so is to > sign-off and back on again. You could try and > reclaim the activation group, > but I don't know if that will take care of the Java > cleanup and references. > . . > > HTH, > Aaron Bartell > > -----Original Message----- > From: java400-l-bounces@xxxxxxxxxxxx > [mailto:java400-l-bounces@xxxxxxxxxxxx]On Behalf Of > Ashish Kulkarni > Sent: Monday, January 19, 2004 11:21 AM > To: Java Programming on and around the iSeries / > AS400 > Subject: Re: Error while calling java from RPG Java > exception > "java.lang.UnknownError:" > > > Hi > Also in my job log i see error message > Tried to refer to all or part of an object that no > longer exists > > What should i do > > Ashish > --- Ashish Kulkarni <kulkarni_ash1312@xxxxxxxxx> > wrote: > > Hi > > I am using V5R2 and JDK1.4.1 > > and calling Java from RPG, and having a weird > > problem > > Every thing works when i call this RPG program > first > > time, but when i call the RPG program second time > i > > get > > error saying > > > > Message ID . . . . . . : RNQ0301 Severity > . > > . > > . . . . . : 99 > > Message type . . . . . : Inquiry > > > > > > > Date sent . . . . . . : 01/19/04 Time > sent > > . > > . . . . . : 10:54:23 > > > > > > > > > Message . . . . : Java exception received when > > calling Java method (C G D > > F). > > > > > > > Cause . . . . . : RPG procedure PU610B01 in > > program > > CXSXA/PU610B received > > Java exception "java.lang.UnknownError:" when > > calling method "<init>" with > > signature "(Ljava.lang.String;)V" in class > > > > > > > "com.pfizer.maps.data.PORPGToJava". > > > > > > > Recovery . . . : Contact the person > responsible > > for program maintenance to > > determine the cause of the problem. > > > > > > > Possible choices for replying to message . . . . > . > > . > > . . . . . . . . . : > > D -- Obtain RPG formatted dump. > > > > > > > S -- Obtain system dump. > > > > > > > G -- Continue processing at *GETIN. > > > > > > > > > __________________________________ > > Do you Yahoo!? > > Yahoo! Hotjobs: Enter the "Signing Bonus" > > Sweepstakes > > http://hotjobs.sweepstakes.yahoo.com/signingbonus > > _______________________________________________ > > This is the Java Programming on and around the > > iSeries / AS400 (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. > > > > > __________________________________ > Do you Yahoo!? > Yahoo! Hotjobs: Enter the "Signing Bonus" > Sweepstakes > http://hotjobs.sweepstakes.yahoo.com/signingbonus > _______________________________________________ > This is the Java Programming on and around the > iSeries / AS400 (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. > _______________________________________________ > This is the Java Programming on and around the > iSeries / AS400 (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. > __________________________________ Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbonus
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.