.
 News & Views
  The online information source for iSeries and mrc-Productivity Series users
.  March 2003  
Volume 3, Issue 3  
.
. . . . . . . . .
 

How to debug mrc Java Servlets

by Adam Flynn
 


This document presumes your servlet is being processed by Tomcat. The instructions should work for WebSphere with a couple of minor changes.

1. First, ensure your servlet is not currently running. Restart Tomcat using the MRCTOMCAT command, if necessary.

2. Start QSHELL with STRQSH, and change to the IFS directory containing your servlet classes, e.g . cd /mrcjava/WEB-INF/classes/UTEST

3. Recompile the servlet with debugging information, e.g. javac -g -d /mrcjava/WEB-INF/classes -classpath /mrcjava/mrcclasses/mrcjava.jar:/mrcjava/mrcclasses/swing.jar:/mrcjava/mrcclas ses/mrcjava11.jar:/mrcjava/mrcclasses/jsdk.jar:/mrcjava/WEB-INF/lib/mrcjs11.jar:/mrcjava/WEB-INF/lib/mrcfop.jar:/mrcjava/WEB-INF/lib /mrcextobj.jar:/mrcjava/WEB-INF/classes/. I00780s.java ( N.B. I used the MRCCLSPTH data area to get the classpath option. )

4. Create a directory in /QIBM/ProdData/Java400 with the same name as the directory (and package) in which your servlet classes reside, e.g. mkdir /QIBM/ProdData/Java400/UTEST

5. Copy your servlet .class, .java, and .html files to the directory created above.

6. After you've copied them, make sure you have authority to the copied files by placing a 9 against each one. ( For some reason, when copying files using WRKLNK your authority is sometimes revoked.) Also make sure the .java files have a CCSID of 819. If they don't, use CHGATR to change them e.g. CHGATR OBJ('/QIBM/ProdData/Java400/UTEST/I00780*.java') ATR(*CCSID) VALUE(819)

7. Now do a CRTJVAPGM against the main .class file, e.g. CRTJVAPGM CLSF('/QIBM/ProdData/Java400/UTEST/I00780s.class') OPTIMIZE(10)

8. Now here's the important bit. This step doesn't make any sense, but believe me, you have to do it. Copy the .java files from the directory you created above to /QIBM/ProdData/Java400. When you've done this, check your authority to the copied files using option 9 again. The source debugger won't use these copied files: it will use the ones in /QIBM/ProdData/Java400/UTEST (I checked by making minor amendments to the source files in both locations.) .But, if you don't copy them to this location, the debugger won't find the source files in the /QIBM/ProdData/Java400/UTEST directory.

9. Service the Tomcat job running in MRCTCPSRV. This will be the job called QP0ZSPWP. E.g. STRSRVJOB JOB(133467/QPGMR/QP0ZSPWP)

10. Start the source debugger over your class using STRDBG. When you run this command initially, you will get a message saying 'Class file not found'. Don't worry, it just means you haven't run the servlet in the browser yet. STRDBG CLASS(UTEST.I00780s)

11. Now run your servlet in the browser. Return to green screen and the source code should appear! Place a breakpoint at somewhere convenient ( such as line 42 below ) and use Shift+F10 to step through the code.

Sometimes on the first run through, the servlet will run without stopping. Just refresh the browser and the source will return and stop at the breakpoint. The second time through you should be able to step through with Shift-F10 and have no problems.



This month’s technical article is a contribution from Adam Flynn, an mrc-Productivity Series expert from our mrc UK office.



.
. Quick Links...

Visit mrc's Web site

See a live demo

Get more information

View Latest Newsletter

Last Month's Newsletter

.
.
.
.
. Contact mrc...

U.S. Offices
mrc@mrc-productivity.com

voice: 630-916-0662

www.mrc-productivity.com



U.K. Offices
michaels, ross & cole (UK) ltd

voice (UK): +44 (0)20 8282 1600

mail@mrcuk.com


.
 mrc publishes this newsletter on a monthly basis. Subscription is free of charge. Please send any questions or comments about this newsletter to news@mrc-productivity.com. This newsletter is edited by Heather Gately.

To unsubscribe, please just reply to this e-mail with Unsubscribe in the subject line.
View our privacy promise.

.