I thought that I'd posted it before but could not find it in the archives.
Thus I am posting it again.


People have asked if it is possible to debug servlets or EJB's using
Emacs, JDE, and the WebLogic server.  This is the method that I use on
my Windows NT 4 workstation to debug servlets. I am sure that similar
techniques can apply to EJB's and to Unix workstations.

One needs a batch file to start the WebLogic server in remote debug
mode. And one needs to set the JDE properties to use the proper class
path and other options.

In the following instructions, I am debugging using the JDK1.2.2 that I
have installed on the C: drive. Weblogic 4.5.1 is also installed on the C:
drive. The servlet class files will be in the C:/weblogic/servlets
directory. The source for my servlet is in
D:/ehusby/java/servletTest/ServletTest.java.


Starting WebLogic in remote debug mode

  This batch file will start WebLogic in remote debug mode. When the
java VM starts a remote debugging session it will display an dt_shmem
address. You need the name of the address to attach the JDBebug to the
java VM.

----------------------- cut here -------------------------------------
rem
rem File: startServerDebug.bat
rem Author: M. Erik Husby on 5-Aug-1999
rem Start the WebLogic server in debug mode.
rem
setlocal
cd /d c:\weblogic
set jdk=c:/jdk1.2.2
set jdpa=c:\jpda
set oracle=d:\orant
set weblogic=c:/weblogic
set weblogiccp
=%weblogic%/classes;%weblogic%/lib/weblogicaux.jar;%weblogic%/license
set cp=%weblogiccp%
set JAVACLASSPATH=%weblogic%\classes\boot;%xml%
set WEBLOGICCLASSPATH=%weblogic%\license;%weblogic%\classes;%weblogic%
\lib\weblogicaux.jar
set a=%jdk%\bin\java -ms64m -mx64m -classpath %JAVACLASSPATH%
set b=-Dweblogic.class.path=%WEBLOGICCLASSPATH%
set c=-Djava.compiler=NONE
set d=-Dweblogic.system.home=%weblogic%
set e=-Djava.security.policy==weblogic.policy
set f=-Xbootclasspath:%jdk%\jre\lib\rt.jar;%jdk%\lib\tools.jar
set g=-Xdebug
set h=-Xnoagent
set i=-Xrunjdwp:transport=dt_shmem,server=y,suspend=n
set k=weblogic.Server
rem
set path=%jdk%\bin;%jdpa%\bin;%weblogic%\bin;%oracle%\bin
%a% %b% %c% %d% %e% %f% %g% %h% %i% %k%
rem
endlocal
----------------------- cut here -------------------------------------

Note: The java command in the batch file should be all on one line. The
options are listed one by one to make it easier to read.

Most of the options are the standard ones used to start the WebLogic
server.

The -Djava.compiler=NONE option turns off the JIT compiler processing
which is necssary for debugging.

The -Dweblogic.system.home option specifies the home directory of the
WebLogic server.

The -Xbootclasspath option includes the special remote debugging libaries.

The -Xdebug option turns on the remote debugging feature.

The -Xnoagent turns off the tcp/ip based debugging.

The -Xrunjdwp option specifies that the Java VM will use shared memory
to talk to the debugger.

Set JDE properties for compilation

  JDE Options Compile

  Set the directory which will receive the class files.
  Jde Compile Option Directory: [Hide] c:\weblogic\servlets

  Set the debug compilation options to include all debugging information
  Jde Compile Option Debug: [Hide]
  Debug info to include in class:
  (*) all
  ( ) none
  ( ) selected
    info:
    [X] Line Numbers
    [X] Variables
    [X] Source

  Turn off compiler optimization.
  Jde Compile Option Optimize: [Hide] [Toggle]  off (nil)

  JDE Options Project

  Set the debug source directories to point to the source of your servlet.
  Jde Db Source Directories: [Hide]
  [INS] [DEL] Path: d:/ehusby/java/servletTest/

Debugging the servlet

  Use the batch procedure to start the WebLogic server in debug
mode. The server should state that it is listening for a debug
connection

     Listening for transport dt_shmem at address: javadebug

  Start the debugger via
     JDEbug -- Processes -- Start Debugger

  Attach the debugger to the server process
     JDEbug -- Processes -- Attach Process -- Via Shared Memory

  At the prompt enter "javadebug" (or whatever is the name of the dt_shmem
address).

  In the debugger window you should see something like:

     Attached to process javadebug.
     Attached VM (shmem) Java Debug Interface (Reference Implementation)
version 1.3
     Java Debug Wire Protocol (Reference Implementation) version 1.0
     JVM Debug Interface version 1.0
     JVM version 1.2.2 (Classic VM, build JDK-1.2.2-W, native threads,
nojit)

  Set a breakpoint in your servlet or EJB.

Do whatever is necessary to invoke your servlet or EJB. When the
breakpoint is hit, the Emacs window should pop to the front. From
there you can use the JDEbug like any other debugging session.


Erik Husby
Domain Pharma Corp
Suite 110      Vox: 781-778-3834
10 Maguire Rd       Fax: 781-778-3800
Lexington, MA 02421 Email: [EMAIL PROTECTED]




Reply via email to