1

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

user987339
  • 10,519
  • 8
  • 40
  • 45
tewemit
  • 43
  • 4
  • Have you set the classpath at the `*JOB` level or the `*SYS` level? – Benny Hill Oct 14 '13 at 19:06
  • Hi Benny, I did try both of them. I have a command embedded in my RPG code which sets the class path to include my jar file. I also changed the CLASSPATH manually before I run the program to be sure. – tewemit Oct 14 '13 at 19:54
  • "If you are using environment variables to control how the JVM is started, you must be sure that the environment variables exist in the job before any RPG programs call Java methods." - this is important if your RPG program is in the default activation group. [More information](http://publib.boulder.ibm.com/infocenter/iadthelp/v7r0/index.jsp?topic=/com.ibm.etools.iseries.pgmgd.doc/c0925076175.htm). – Benny Hill Oct 14 '13 at 20:28

2 Answers2

0

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.

Benny Hill
  • 6,191
  • 4
  • 39
  • 59
  • In the beginning I had all Jars and files in the same outer Jar which I exported from Eclipse and using a path to that jar 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 worked right. – tewemit Oct 17 '13 at 14:35
  • Thank you Benny. I have another optimization question on using JtOpen for connecting to IBM i systems. Are you good at that too? I will post it in another, related, topic though. – tewemit Oct 17 '13 at 14:44
  • @tewemit - it's been about 14 years since I did any work with Java or jtOpen so I'm definitely not the most knowledgeable person about those technologies. However there are lots of people here at Stackflow that are experienced in a lot of things including jtOpen so I'm sure you'll get some good recommendations/advice for whatever you need. – Benny Hill Oct 17 '13 at 14:57
0

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!

tewemit
  • 43
  • 4