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

"Blalock, Bill via JAVA400-L" <[email protected]> Sun, 6 Oct 2024 22:22:29 +0000
Newsgroups gmane.comp.lang.as400.java
Message-ID <PAXPR08MB72305B8A588C7D722A352E0C837C2@PAXPR08MB7230.eurprd08.prod.outlook.com>
Thank you all,

Maybe this problem is something else.  I went for a really simple example, " http://www.ibm.com/support/pages/example-rpgle-program-calling-helloworld-java-program ".  This is the example:

----- Begin example
This example shows how an ILE RPG program would call a Java Program called HelloWorld.

Caution: This is an example only. IBM accepts no responsibility for its correctness.

The java code, HelloWorld.java:
class HelloWorld
{
public static void Hello ()
{
System.out.println("Hello World") ;
}
}

The ILE RPG code to call the Hello method in java class HelloWorld would be:
H DFTACTGRP(*NO)
D sayhello        PR                  EXTPROC(*JAVA
D                                     :'HelloWorld'
D                                     :'Hello')
D                                     Static
C                   callp     sayhello
C                   eval      *INLR = *ON

If the HelloWorld.class object is in IFS directory /home/abc, you must ensure the classpath environment variable is set to this directory.  This allows the JVM to find the class object.  For example:
 ADDENVVAR ENVVAR(CLASSPATH) VALUE('/home/abc') LEVEL(*JOB)
----- end example

I created the class and the RPGLE pgm as in the example.  I put the class object in /home/abc/.  I opened a fresh interactive session and set the CLASSPATH per the example.  Then I entered the command CALL PRCHELLO (the name of the RPGLE program).  I am still getting the error message

                         Additional Message Information

 Message ID . . . . . . :   RNQ0301       Severity . . . . . . . :   99
 Message type . . . . . :   Sender copy
 Date sent  . . . . . . :   10/06/24      Time sent  . . . . . . :   17:15:15

 Message . . . . :   Java exception received when calling Java method (C G D
   F).
 Cause . . . . . :   RPG procedure PRCHELLO in program BLALOCK/PRCHELLO
   received Java exception "java.lang.NoClassDefFoundError: HelloWorld" when
   calling method "Hello" with signature "()V" in class "HelloWorld".                                  Additional Message Information

 Message ID . . . . . . :   RNQ0301       Severity . . . . . . . :   99
 Message type . . . . . :   Sender copy
 Date sent  . . . . . . :   10/06/24      Time sent  . . . . . . :   17:15:15

 Message . . . . :   Java exception received when calling Java method (C G D
   F).
 Cause . . . . . :   RPG procedure PRCHELLO in program BLALOCK/PRCHELLO
   received Java exception "java.lang.NoClassDefFoundError: HelloWorld" when
   calling method "Hello" with signature "()V" in class "HelloWorld".

-----End of message.

I am at a loss.  I have done exactly what the IBM example did, down to name the IFS folder.  Still getting this error.  There are no parameters passed so it should not be a signature problem.

What do you think?






-----Original Message-----
From: JAVA400-L <java400-l-bounces-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org> On Behalf Of Blalock, Bill via JAVA400-L
Sent: Sunday, October 6, 2024 3:36 PM
To: Java Programming on and around the IBM i <[email protected]>
Cc: Blalock, Bill <Bill.Blalock-/[email protected]>
Subject: RE: Need help with RNX0301 error -- CLASSPATH or signature error

Hi Colin;

The Item class is in the jar.  The package name is rpgExample.

I viewed the structure of the jar by copying it to a zip file and opening the zip file.

rpzExampleJar.jar
        META-INFO
                MANIFIST.MF
        rpgExample
                GetItem.class
                GetItem.jar
                Item.class
                Item.jar
        folders for other projects in the Eclipse workspace.


-----Original Message-----
From: JAVA400-L <java400-l-bounces-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org> On Behalf Of Colin Williams
Sent: Sunday, October 6, 2024 1:41 PM
To: Java Programming on and around the IBM i <[email protected]>
Subject: Re: Need help with RNX0301 error -- CLASSPATH or signature error

So your code is looking for fully qualified rpgExample.Item.

Is this inside your classes folder in your jar?

On Sun, 6 Oct 2024, 17:25 Blalock, Bill via JAVA400-L, < [email protected]> wrote:

> 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%2F2011%2F06%2Fcall-java-from-rpgle-explanation-with.h
> tml&data=05%7C02%7Cbill.blalock%40fisglobal.com%7C9be6398fec314522b0db
> 08dce636840b%7Ce3ff91d834c84b15a0b418910a6ac575%7C0%7C0%7C638638369036
> 954146%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJ
> BTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=dyiB4WIeuZshXfYBsbjClQN
> sW1i%2Fjjdw5WvKwNDMQ8s%3D&reserved=0
> 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
>
>
>
>
>
>
> Bill Blalock
> Complete Payment Recovery Services
> C  (205) 292-0725
> E  [email protected]<mailto:[email protected]>
>
> The information contained in this message is proprietary and/or
> confidential. If you are not the intended recipient, please: (i)
> delete the message and all copies; (ii) do not disclose, distribute or
> use the message in any manner; and (iii) notify the sender
> immediately. In addition, please be aware that any message addressed
> to our domain is subject to archiving and review by persons other than
> the intended recipient. Thank you. Message Encrypted via TLS
> connection
> --
> 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://list/
> s.midrange.com%2Fmailman%2Flistinfo%2Fjava400-l&data=05%7C02%7Cbill.bl
> alock%40fisglobal.com%7C9be6398fec314522b0db08dce636840b%7Ce3ff91d834c
> 84b15a0b418910a6ac575%7C0%7C0%7C638638369036970784%7CUnknown%7CTWFpbGZ
> sb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3
> D%7C0%7C%7C%7C&sdata=u94byzc2WT9M3H%2Fa%2B9vPaNiIDI6hoGxG3sLCevTBKMw%3
> D&reserved=0 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.
>
--
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.
The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.
Message Encrypted via TLS connection
--
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.
The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.
Message Encrypted via TLS connection
-- 
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.