IBM Support

Using native IBM i debugger to debug Java class that is invoked by an ILE program

Question & Answer


Question

How to use the native STRDBG cmd to debug a Java class that is invoked by an ILE program, like RPG, and not contend with message CPF9594 Java class file not available.

Cause

From an interactive session if you issue
STRDBG CLASS(<your class name>) or STRDBG PGM(<your pgm name>) where the program invokes a Java class then you will receive this message:
Message ID . . . . . . . . . : CPF9594
Message file . . . . . . . . : QCPFMSG
Library . . . . . . . . . : QSYS

Message . . . . : Java class file not available.
Cause . . . . . : Java class file &1 not available. Reason code 1.
Reasons are as follows:
1 - Java virtual machine not started.
2 - Error creating debug view.
Recovery . . . : Correct the problem and submit the request again.

Answer

STRDBG has prerequisites for Java debug.

1. STRDBG CLASS must be done from a servicing job environment, since Java starts a spawn job.
Therefore, STRSRVJOB should be done before STRDBG JAVA

2. STRDBG CLASS has no meaning unless a Java program has been started first. Unlike traditional debug support, where a user can start debug first, set breakpoints, then call the program, the Java user must first issue the Java command, then issue STRDBG. If STRDBG CLASS is attempted before the Java virtual machine is initialized in Job B, an error message of the form "Java virtual machine not started" will be generated by the debugger

These prerequisites are circumvented when starting Java with the *debug option (JAVA CLASS(Version) OPTION(*DEBUG)), because STRDBG CLASS is then invoked in the back-end job.

In order to debug RPG and Java together it is essential to use service job.
STRDBG cannot be used directly since it's not possible to debug Java when it's running in the same process as the debugger.

Steps:
Job1:
- Add the environment variables
ADDENVVAR ENVVAR(QIBM_RPG_JAVA_PROPERTIES) VALUE('-debug;')
and other variables that might be needed such as CLASSPATH
ADDENVVAR ENVVAR(CLASSPATH) VALUE('<your pathnames>')
Take note of the job name.


Job2:
- STRSRVJOB using job name that was noted in job1.
- STRDBG the RPG program
- Add a breakpoint on the call to Method1

Job1:
- Call the RPG program

Job2:
The RPG program will stop on the breakpoint.
At this point the Java class needs to be added to the module list.
Select F14=Work with module list.
Use 1=Add program, tab over Program/module, Library and replace *PGM with *CLASS and press enter.
The 'Enter Class filename' dialog will be presented. Enter the class name. If the class uses a package name then enter package.classname
i.e com.mypackage.Myclass
After adding the class to the list of modules you will be back in the Display Module Source panel.
- Step into the method that invokes the Java method by using F22=Step into
- Now you can debug the Java method and the RPG program

[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.1.0"}]

Document Information

Modified date:
08 May 2020

UID

nas8N1021114