RE: Need help with RNX0301 error -- CLASSPATH or signature error

Richard Schoen <richard-DiTrGpQEJGItADg8e/3/[email protected]> Sun, 6 Oct 2024 17:11:45 +0000
Newsgroups gmane.comp.lang.as400.java
Message-ID <CH0PR12MB52500FB3E9C622D8966F353AB77C2@CH0PR12MB5250.namprd12.prod.outlook.com>
You specified: /iasp1/java/prcExample/rpgExample.jar on your env variable.

And this has: CLASSPATH  '/java/prcExample/rpgExample.jar'

2nd one missing /iasp1   

Not sure if that's relevant but inconsistent.

Regards,
Richard Schoen
Web: http://www.richardschoen.net
Email: richard-DiTrGpQEJGItADg8e/3/[email protected]
 
----------------------------------------------------------------------

message: 1
date: Sun, 6 Oct 2024 16:24:59 +0000
from: "Blalock, Bill via JAVA400-L" <[email protected]>
subject: Need help with RNX0301 error -- CLASSPATH or signature error

I am trying to call Jave from RPGLESRC.  I keep running into RNX0301 when executing the RPGLE program.  I have been at it 3 days and sure could use some guidance.

Message . . . . :   Java exception received when calling Java method.
 Cause . . . . . :   RPG procedure PRCPWDIRG in program BLALOCK/PRCPWDIRG
   received Java exception "java.lang.NoClassDefFoundError:rpgExample.Item" when calling
   method "<init>" with signature "()V" in class "Item".

I tried for two days to get past this error with my own class and RPG.  Yesterday I decided to see if I could make RPGLE and Java work together with an example from the Internet.  https://www.mysamplecode.com/2011/06/call-java-from-rpgle-explanation-with.html  This is a well thought out example.

I wanted to eliminate coding errors in my RPGLE and Java, to minimize the possibility that this is a signature error. Still getting the same error.

I created an Eclipse project, rpgExample.  I copied the Java source from the example into two files, Item.java and GetItem.java.  In Eclipse I exported them to the IFS as a jar file, named rpgExample.jar.  The destination was /iasp1/java/prcExample.  So now I have the jar in /iasp1/java/prcExample/rpgExample.jar.

I create the RPGLE program as BLALOCK/QRPGLESRC (PRCPWDIRG).  I changed the package name from "com.as400samplecode" to match my package name of "rpgExample" in both Java and RPGLE.

I used this statement at the top of the RPGLE program:
         cmdString = 'ADDENVVAR ENVVAR(CLASSPATH) ' +
                  'VALUE(''/iasp1/java/prcExample/rpgExample.jar'')' +
                   'REPLACE(*YES)';
         runCmd(cmdString);

I checked the value of CLASSPATH after executing the program with WRKENVVAR.  The value was
                 CLASSPATH                   '/java/prcExample/rpgExample.jar'
That is what I expected.  I checked the CLASSPATH with WRKLNK.  It was found.

The execution fails with the RNX0301 error.

I cannot understand what is going on.  I'd appreciate some advice.  I can send the source code to you.

Thanks


-- 
This is the Java Programming on and around the IBM i (JAVA400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org
Before posting, please take a moment to review the archives
at https://archive.midrange.com/java400-l.