Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Call Java Pgm. from RPG in Submit???

110 views
Skip to first unread message

Martin St?berl

unread,
Oct 14, 2003, 7:40:32 AM10/14/03
to
Hi together!

I am trying to call a Java Pgm. from RPG in Submit using QCMDEXC. In
QPRINT Spoolfile I always get the following error:

java.lang.NoClassDefFoundError
java/lang/Throwable.<init>()V+4 Throwable.java:78)
java/lang/Error.<init>()V+1 (Error.java:37)
java/lang/NoClassDefFoundError.<init>()V+1
NoClassDefFoundError.java:33)
java/lang/ClassLoader.defineClass(Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class;+79
(ClassLoader.j
java/security/SecureClassLoader.defineClass(Ljava/lang/String;[BIILjava/security/CodeSource;)Ljava/lang/Class;+27
(SecureCla
java/net/URLClassLoader.defineClass(Ljava/lang/String;Lsun/misc/Resource;)Ljava/lang/Class;+196
(URLClassLoader.java:287)
java/net/URLClassLoader.access$300(Ljava/net/URLClassLoader;Ljava/lang/String;Lsun/misc/Resource;)Ljava/lang/Class;+1
(URLCl
java/net/URLClassLoader$ClassFinder.run()Ljava/lang/Object;+42
(URLClassLoader.java:594)
java/net/URLClassLoader.findClass(Ljava/lang/String;)Ljava/lang/Class;+16
(URLClassLoader.java:200)
java/lang/ClassLoader.loadClass(Ljava/lang/String;Z)Ljava/lang/Class;+41
(ClassLoader.java:303)
sun/misc/Launcher$AppClassLoader.loadClass(Ljava/lang/String;Z)Ljava/lang/Class;+33
(Launcher.java:286)
java/lang/ClassLoader.loadClass(Ljava/lang/String;)Ljava/lang/Class;+1
(ClassLoader.java:259)
java/lang/ClassLoader.loadClassInternal(Ljava/lang/String;)Ljava/lang/Class;+1
(ClassLoader.java:319)

The Submit Job works from the programmer's menue, but not from RPG via
QCMDEXC. I also tried to set the CLASSPATH System variable, using QSH
and the JAVA command. Also tried to call the Java programm directly
without a Submit Job from RPG. Always the same error!
The call from RPG programm works under V4R2 but not on V5R2!
Any hints what the problem could be?

cu

Martin

Jack Kingsley

unread,
Oct 14, 2003, 1:08:35 PM10/14/03
to
martins...@gmx.de (Martin St?berl) wrote in message news:<1f43f74e.03101...@posting.google.com>...

Is it a compiled java program?? Is it in the IFS?? What does the
joblog look like from the one that does run. Sounds like you might be
missing a library in your library list.

Dieter Bender

unread,
Oct 14, 2003, 2:57:55 PM10/14/03
to
Hi,

looks like classpath problems. Did you try
qsh cmd('java MyClass -classpath MyClassPath') ?

Dieter

Dan Hicks

unread,
Oct 14, 2003, 7:28:43 PM10/14/03
to
The "class" you're trying to execute isn't a valid class. Maybe you
FTPed it without specifying "binary"?

--
Dan Hicks
Hard work never killed anybody, but why take a chance?

Martin St?berl

unread,
Oct 15, 2003, 2:50:31 AM10/15/03
to
> Is it a compiled java program?? Is it in the IFS?? What does the
> joblog look like from the one that does run. Sounds like you might be
> missing a library in your library list.
Yes, I transfered the program through iSeries Navigator to a folder in
the IFS and compiled it in QSH. I don't get a joblog from the RPG
program, the only message I get is in the QPRINT spool file I printed
in the previous posting. Do I need a special library list for my job
to call a java program?

cu

Martin

Martin St?berl

unread,
Oct 15, 2003, 2:56:44 AM10/15/03
to
> looks like classpath problems. Did you try
> qsh cmd('java MyClass -classpath MyClassPath') ?
Yes, I tried the same command in QSH with the Classpath Option and it
works. When I call the Java program from RPG I get the error. Also
tried setting the Classpath as a system value, so I don't have to use
the classpath option in QSH. It works when I use QSH manually, but it
fails when I call the java program from RPG.
Can I also set a system value like 'MYCLASSPATH' and use the option in
QSH like java -classpath MYCLASSPATH or do I have to use the variable
'CLASSPATH'?

cu

Martin

Martin St?berl

unread,
Oct 15, 2003, 3:00:02 AM10/15/03
to
> The "class" you're trying to execute isn't a valid class. Maybe you
> FTPed it without specifying "binary"?
I transfered the *.java file via iSeries Navigator to the IFS and
compiled it in QSH. The Java programm works when I call it manually
from the programmer's menue for example. The error only occurs when I
call it from an RPG program and also only under V5R2, under V4R2 the
program works without a problem.

cu

Martin

Dieter Bender

unread,
Oct 15, 2003, 3:10:12 AM10/15/03
to
Martin,

Martin St?berl wrote:

Best way in my opinion is to specify the classpath explicit in the java
command:
for example:
java myClass -classpath /home/dieter/java:/home/dieter/java/jt400.jar
with /home/dieter/java is the location of my classes
and the Toolbox Driver is in /home/dieter/java in jt400.jar (if I need it)
test this command from QSHELL if it works then:
qsh cmd('java myClass -classpath
/home/dieter/java:/home/dieter/java/jt400.jar')
executed via SBMJOB or QCMDEXC or whatever you want.

Dieter
>
> cu
>
> Martin

Matthias

unread,
Oct 15, 2003, 3:38:40 AM10/15/03
to
Hello,

have your tried to set the HOME variable with WRKENVVAR for *JOB and
*SYS ? Also you can create a profile file in /etc with CLASSPATH
informations. Maybe this helps.

Best regards,
Matthias

On 14 Oct 2003 04:40:32 -0700, martins...@gmx.de (Martin St?berl)
wrote:

Dr. Ugo Gagliardelli

unread,
Oct 15, 2003, 3:56:30 AM10/15/03
to
Maybe it's a classpath problem. Try putting your .jar file (or .class) in
/QIBM/UserData/Java400/ext directory, it's the right place to put your java
programs getting rid from classpath problems. Then simply call JAVA
CLASS('YourPackage.YourClass')
--
Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherAñejoAlcoolInside
Spaccamaroni andate a cagare/Spammers not welcome/Spammers vão à merda
Spamers iros a la mierda/Spamers allez vous faire foutre
Spammers loop schijten/Spammers macht Euch vom Acker

Martin Stöberl

unread,
Oct 15, 2003, 4:08:40 PM10/15/03
to
> Maybe it's a classpath problem. Try putting your .jar file (or .class) in
> /QIBM/UserData/Java400/ext directory, it's the right place to put your
java
> programs getting rid from classpath problems. Then simply call JAVA
> CLASS('YourPackage.YourClass')
I will try this out within the next days, at the moment I have to work on
another program ... I will also try to modify the java system environment in
file SystemDefault.properties.

cu

Martin


Martin Stöberl

unread,
Oct 15, 2003, 4:07:55 PM10/15/03
to
> have your tried to set the HOME variable with WRKENVVAR for *JOB and
> *SYS ? Also you can create a profile file in /etc with CLASSPATH
> informations. Maybe this helps.
Hmm, I found an article at iSeries Information Center about setting up the
java system properties ... perhaps I find the problem here.
The curious thing is that I can call the the program in Submit from a normal
command prompt, but when I use QCMDEXC from an RPG program I get the error.

cu

Martin


Martin Stöberl

unread,
Oct 17, 2003, 2:22:00 PM10/17/03
to
Today I had time to continue working on the problem. I think it's definitly
no classpath problem! It's no problem to call the java program from a
command prompt (doesn't matter if I use QSH, JAVA or RUNJVA) or from a CL
(can also use QCMDEXC here) in Submit or Interactive. The problem only
occurs when I call it from an RPG program with QCMDEXC. At the moment I
solved the problem by writing a small CL expecting two paramters, one for
the command and one for the length. Then I use QCMDEXC to start the java
program ("CALL 'QCMDEXC' PARM(&CMDEXC &CMDLEN)").
I found a posting in a forum (don't remember the link at the moment) from
someone who wrote that the problem could be that I am not allowed to start a
new thread from the RPG program!? Anyone here who knows more about this?

cu

Martin


amw...@gmail.com

unread,
Mar 16, 2005, 1:23:34 PM3/16/05
to
Have you found any way around this? I have the same problem.

Aaron

unread,
Mar 17, 2005, 3:40:49 PM3/17/05
to
A word of caution about calling Java from batch. Unless you use JNI
from and RPGLE program, the java program will spawn a new job in the
same subsystem your batch job is running. This can be a problem if you
have a limited number of jobs that can be active in the subsystem. The
java program will fail to run. It's really annoying.
0 new messages