Question

I would highly appreciate your help with a ClassNotFoundError while calling a Java method from RPG. This happens when any other user, except me, tries to run my program. It literally seems a problem with CLASSPATH or access to jar files but I tried from that aspect too.

Explanation: I have an RPG program which calls a java method in a jar file. My CLASSPATH has the right jars included (JtOpen jar files). It works perfectly when I run the RPG program from a Green and Black screen (Iseries session manager). Where as it throws the following error message whenever another user tries to run it the same way:

RPG Procedure received Java Exception java.lang.NoClassDefFoundError: com.ibm.as400.access.AS400 when calling method "invokeApiPgm" with signature "([Ljava.lang.String;Ljava.lang.String;I[Ljava.lang.String;)Z" in class "callIceApi.CallIceApiPgm".

The signature above is also the same as that of the method i call. Does the class the Java is complaining seem to be that of AS400 or could it be mine? I can see that the AS400 class is available as public. The class object was created successfully by the constructor of my class. It just fails when calling the main method invokeApiPgm.

What do you think I am missing or messing up with, guys?

Thanks for your help!

Tewelle

Was it helpful?

Solution

How about a CL program that explicitly sets the classpath and then calls your RPG program?

The CLP:

PGM

ADDENVVAR ENVVAR('CLASSPATH') VALUE('.:/dir1:/dirA/dirB:/javaToolkit/jt400.jar') LEVEL(*JOB)
CALL PGM(MYLIB/MYPGM)

ENDPGM

This page may also be helpful.

OTHER TIPS

In the beginning I had all Jars and files in the same outer Jar which I exported from Eclipse and adding the Jar's path to my CLASSPATH couldn't work for me. However, I don't know why though, it worked after taking the JT400.Jar separately out and then including its path in the CLASSPATH, as Benny's answer, with another separate inclusion to the main project jar worked right.

Thanks Benny!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top