Topic
  • 8 replies
  • Latest Post - ‏2011-11-18T15:01:19Z by tools400
tools400
tools400
36 Posts

Pinned topic Can not debug Java class

‏2011-11-15T11:20:11Z |
First of all please bear with me if I did not yet find the answer to my question although it might be here. I already spend hours to search the Internet and, of course, the RPG Cafe.

The problem is that I cannot debug into a simple Java class regardless of what I do. All I want to do is to debug a simple HelloWorld class with the Graphical System i5 Debugger.

First I tried to directly start the i5 Debugger for the class which I intended to call from QShell. But all my efforts were blocked with message CPF9594.

Then I found Barbara's statement "you can't step into a Java method until at least one Java method has already been called" in the RPG Cafe and I wrote a simple RPG program to call HelloWorld. I started the debugger for the program and let the program stop right before the method I wanted to debug. Then I attempted to add my HelloClass to the debugger which was rejected with error message "Class file not found." (CPF9592). Needless to say that "Step into" did not work either although method "printToConsole()" was executed after I had pressed the "Resume" button.

So all my efforts to debug HelloWorld were block with one of these messages:

(CPF9592): "Class file not found."
(CPF9594): "Java class file HelloWorld not available. Reason code 1."

The attached zip file contains the following files:

HelloWorld.java
HelloWorld_AddClassToDebugger.JPG
HelloWorld_SystemDefault.properties
HelloWorld.rpgle
HelloWorld_5250_JobLog.txt.txt
HelloWorld_QTESDBGSVR_JobLog.txt.txt

Any ideas how to solve the problem?

Regards,

Thomas.
Updated on 2011-11-18T15:01:19Z at 2011-11-18T15:01:19Z by tools400
  • barbara_morris
    barbara_morris
    386 Posts

    Re: Can not debug Java class

    ‏2011-11-15T16:50:24Z  
    Thomas, I'm guessing that you are using J9 Java? Here's how I have been able to debug RPG and J9.

    Add the "-debug" option to your Java options for your RPG job. It's not in the usual form "-Doption=value", just "-debug".

    Using the system debugger, I have only been able to debug from a service job, but I assume that the graphic system debugger is already using a service job, so it's likely that just the -debug option would be enough.
  • tools400
    tools400
    36 Posts

    Re: Can not debug Java class

    ‏2011-11-16T07:50:27Z  
    Thomas, I'm guessing that you are using J9 Java? Here's how I have been able to debug RPG and J9.

    Add the "-debug" option to your Java options for your RPG job. It's not in the usual form "-Doption=value", just "-debug".

    Using the system debugger, I have only been able to debug from a service job, but I assume that the graphic system debugger is already using a service job, so it's likely that just the -debug option would be enough.
    Barbara, thank you for your prompt response. I do not think that I am using the J9 Java because the job log of the interactive job (the job calling the HELLOWORLD program) shows a message "Java Virtual Machine is Classic."

    Nevertheless I added the "-debug" parameter to my Java options and tried to debug the "HelloWorld" class. Unfortunately with no success so far.

    Since WRKENVVAR shows the same result after having called the HELLOWORLD program I assume that I properly used SetEnvVar().

    Regards,

    Thomas.
  • tools400
    tools400
    36 Posts

    Re: Can not debug Java class

    ‏2011-11-16T07:51:13Z  
    Thomas, I'm guessing that you are using J9 Java? Here's how I have been able to debug RPG and J9.

    Add the "-debug" option to your Java options for your RPG job. It's not in the usual form "-Doption=value", just "-debug".

    Using the system debugger, I have only been able to debug from a service job, but I assume that the graphic system debugger is already using a service job, so it's likely that just the -debug option would be enough.
    
    setEnvVar(
    'QIBM_RPG_JAVA_PROPERTIES' : 
    '-debug;+ -Djava.version=1.5;+ -Dos400.stderr=file:\home\raddatz\HelloWorld_stderr.txt;+ -Dos400.stdout=file:\home\raddatz\HelloWorld_stdout.txt;+ 
    '); msg = String_new(
    'Hello World'); HelloWorld = HelloWorld_new(); HelloWorld_init(HelloWorld); HelloWorld_init(HelloWorld); HelloWorld_printToConsole(HelloWorld: msg); *inlr = *on;
    


    
    Opt  Name                        Value   LANG                        
    '/QSYS.LIB/DE_DE.LOCALE' strgh.log4rpg               
    '0' strgh.cfgpath               
    'file:log4rpg_gh.properties' ILE_DEBUGGER_1              
    'ALLOW_WIDE_SCREEN' QIBM_CHILD_JOB_SNDINQMSG    
    '0' QIBM_RPG_JAVA_PROPERTIES    
    '-debug;-Djava.version=1.5;-Dos400.' >
    
  • barbara_morris
    barbara_morris
    386 Posts

    Re: Can not debug Java class

    ‏2011-11-16T13:50:56Z  
    • tools400
    • ‏2011-11-16T07:51:13Z
    <pre class="jive-pre"> setEnvVar( 'QIBM_RPG_JAVA_PROPERTIES' : '-debug;+ -Djava.version=1.5;+ -Dos400.stderr=file:\home\raddatz\HelloWorld_stderr.txt;+ -Dos400.stdout=file:\home\raddatz\HelloWorld_stdout.txt;+ '); msg = String_new( 'Hello World'); HelloWorld = HelloWorld_new(); HelloWorld_init(HelloWorld); HelloWorld_init(HelloWorld); HelloWorld_printToConsole(HelloWorld: msg); *inlr = *on; </pre>

    <pre class="jive-pre"> Opt Name Value LANG '/QSYS.LIB/DE_DE.LOCALE' strgh.log4rpg '0' strgh.cfgpath 'file:log4rpg_gh.properties' ILE_DEBUGGER_1 'ALLOW_WIDE_SCREEN' QIBM_CHILD_JOB_SNDINQMSG '0' QIBM_RPG_JAVA_PROPERTIES '-debug;-Djava.version=1.5;-Dos400.' > </pre>
    Hi Thomas, I'm getting an error from this forum saying my message has unallowed text, so I'm posting my answer in an attachment.

    Also, here's an usenet thread that talks about debugging RPG with Java. https://groups.google.com/group/comp.sys.ibm.as400.misc/browse_frm/thread/2e79bb3d40d2b9a7/?hl=en
  • tools400
    tools400
    36 Posts

    Re: Can not debug Java class

    ‏2011-11-16T18:05:41Z  
    Hi Thomas, I'm getting an error from this forum saying my message has unallowed text, so I'm posting my answer in an attachment.

    Also, here's an usenet thread that talks about debugging RPG with Java. https://groups.google.com/group/comp.sys.ibm.as400.misc/browse_frm/thread/2e79bb3d40d2b9a7/?hl=en
    Hurray! I eventually got it working.

    After it was clear that I use the Classic JVM and after I found the "Unable to start Java system debug" (JVAB307) message in both job logs (5250 job and QTESDBGSVR job) I again went to the Information Center and had a close look at "System debugging for Classic JVMs". Then, after having added the "-Djava.compiler=NONE" option to my Java options list, I could successfully debug my HelloWorld class.

    Eventually the only requirements to debug the class are:

    a) Java properties:
    
    setEnvVar(
    'QIBM_RPG_JAVA_PROPERTIES' : 
    '-Djava.compiler=NONE;+ -Djava.version=1.5;+ 
    ');
    


    b) The debugger must be started by the System Debug Manager (because of the service job, I assume).

    c) The class needs to be compiled with the -g option.

    And, if you change anything (such as recompiling the class), do a fresh signon to get rid of the JVM! Maybe that was the hardest thing to learn and it might have been responsible for a whole bunch of problems that I could not understand. I usually do not have to care about that when doing Java with Eclipse.

    By the way, I got the same "unallowed text" message which was the reason for the two postings, yesterday.

    Thank you so much, Barbara.

    Thomas.
  • barbara_morris
    barbara_morris
    386 Posts

    Re: Can not debug Java class

    ‏2011-11-16T19:18:02Z  
    • tools400
    • ‏2011-11-16T18:05:41Z
    Hurray! I eventually got it working.

    After it was clear that I use the Classic JVM and after I found the "Unable to start Java system debug" (JVAB307) message in both job logs (5250 job and QTESDBGSVR job) I again went to the Information Center and had a close look at "System debugging for Classic JVMs". Then, after having added the "-Djava.compiler=NONE" option to my Java options list, I could successfully debug my HelloWorld class.

    Eventually the only requirements to debug the class are:

    a) Java properties:
    <pre class="jive-pre"> setEnvVar( 'QIBM_RPG_JAVA_PROPERTIES' : '-Djava.compiler=NONE;+ -Djava.version=1.5;+ '); </pre>

    b) The debugger must be started by the System Debug Manager (because of the service job, I assume).

    c) The class needs to be compiled with the -g option.

    And, if you change anything (such as recompiling the class), do a fresh signon to get rid of the JVM! Maybe that was the hardest thing to learn and it might have been responsible for a whole bunch of problems that I could not understand. I usually do not have to care about that when doing Java with Eclipse.

    By the way, I got the same "unallowed text" message which was the reason for the two postings, yesterday.

    Thank you so much, Barbara.

    Thomas.
    Glad to hear you got it to work, Thomas. The java.compiler=NONE option is new for me, thanks for that.
  • tools400
    tools400
    36 Posts

    Re: Can not debug Java class

    ‏2011-11-18T11:24:50Z  
    Glad to hear you got it to work, Thomas. The java.compiler=NONE option is new for me, thanks for that.
    I can not believe that I told you something new. You must be kidding. ;-)

    OK, attached you find a complete description of what I did to debug HelloWorld using the Classic and the J9 JVM. Hopefully I did not forget something and I hope that it is detailed enough and useful for everybody.

    Just as a side note, actually most things work as described in the Information Center. The only problem I had was the '-debug' parameter which does not work for me. Instead it produces this error message:

    
    >> CALL PGM(RADDATZ/HELLOWRLD3) JVM properties were loaded from a properties file. JVM properties were loaded from a properties file. Java Virtual Machine is IBM Technology 
    
    for Java.  PID(9228) JVM properties were loaded from a properties file. JVM properties were loaded from a properties file. JVMJ9VM007E Command-line option unrecognised: -debug Pointer not set 
    
    for location referenced.
    


    Output of WRKENVVAR:

    
    QIBM_RPG_JAVA_PROPERTIES    
    '-Dos400.stdout=file:/home/raddatz/' > JAVA_TOOL_OPTIONS           
    '-debug'
    


    Now I use '-agentlib:d9ti' instead of '-debug'.

    Thomas.
  • tools400
    tools400
    36 Posts

    Re: Can not debug Java class

    ‏2011-11-18T15:01:19Z  
    See attached file 'i5 System Debugger Setup.zip' for the details.