How Do I Debug Enterprise JavaBeans deployed in JBoss?

An Oracle JDeveloper TechNote
February 2002

Content

 

Introduction

This TechNote describes in detail the requirements and steps to debug Enterprise JavaBeans which are deployed to JBoss from Oracle9i JDeveloper.

This document was written for Oracle9i JDeveloper Release Candidate and JBoss 2.4.4 (Dated December 29, 2001), although other versions of Oracle9i JDeveloper and/or JBoss should behave the same.

On Windows, Oracle9i JDeveloper can use the OJVM debugging protocol with the OJVM client Java VM (included with Oracle9i JDeveloper) which is much more performant than JPDA. OJVM is currently not available on other platforms, therefore on UNIX JPDA must be used. This document will describe both OJVM and JPDA debugging.

For references on how to deploy an EJB to JBoss, please see the Oracle Technology Network TechNote How Do I Deploy Enterprise JavaBeans to JBoss?

Setting up the Environment

On Windows:

Use the setvars.bat script on Windows, located in your JDeveloper\jdev\bin directory to set the JAVA_HOME and PATH environment variables. For help on using the setvars script, just execute setvars.bat and usage examples will be displayed.

Example:

setvars -go

On UNIX (C Shell)

Set the JAVA_HOME environment variable and add the Java2 SDK’s bin directory to your PATH. 

Example:

  1. setenv JAVA_HOME /usr/java/jdk1.3
  2. setenv PATH ${PATH}:${JAVA_HOME}/bin

On UNIX (Bourne Shell)

Set the JAVA_HOME environment variable and add the Java2 SDK’s bin directory to your PATH. 

Example:

  1. export JAVA_HOME=/usr/java/jdk1.3
  2. export PATH=${PATH}:${JAVA_HOME}/bin

 

Modifying the run.bat script (Windows)

Open the run.bat script which is located in the JBoss\bin directory with a text editor (such as notepad)

Replace this one line:

  • java %JAXP% -classpath "%JBOSS_CLASSPATH%" org.jboss.Main %1 %2 %3 %4 %5 %6 %7 %8 %9

With these two lines:

  • set JBOSS_DEBUG_FLAGS=-ojvm -XXdebug,detached,quiet,port4000
  • java %JBOSS_DEBUG_FLAGS% %JAXP% -classpath "%JBOSS_CLASSPATH%" org.jboss.Main %1 %2 %3 %4 %5 %6 %7 %8 %9

 

Modifying the run.sh script (UNIX)

 

Open the run.sh script which is located in the JBoss\bin directory with a text editor (such as emacs or vi)

Replace this one line:

  • java $HOTSPOT $JAXP -classpath $JBOSS_CLASSPATH org.jboss.Main $@

With these two lines::

  • set JBOSS_DEBUG_FLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4000
  • java $JBOSS_DEBUG_FLAGS $HOTSPOT $JAXP -classpath $JBOSS_CLASSPATH org.jboss.Main $@

If you want to debug with Sun's classic VM, use these three lines instead:

  • set CLASSIC=-classic
  • set JBOSS_DEBUG_FLAGS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4000
  • java $JBOSS_DEBUG_FLAGS $CLASSIC $JAXP -classpath $JBOSS_CLASSPATH org.jboss.Main $@

 

Starting JBoss

Execute the run script (or run_with_tomcat) located in the JBoss/bin directory. (For example, this might be C:\JBoss-2.4.4\bin).

After JBoss is started, you will see many lines of information printed to the command shell. If you have not already deployed your Enterprise JavaBean, please do so now.

[INFO,Default] JBoss-2.4.4 Started in 0m:7s.951

 

Modifying your Project in JDeveloper to Enable Remote Debugging

Use these steps to configure the your project for remote OJVM debugging:

  1. In the navigator, right-click your project's node in the System Navigator and choose Project Settings from the context menu.
  2. The Project Settings dialog appears.
  3. Click the Debugger node below the Development node to see all the options.
  4. In the Project Settings Dialog, expand the Debugger node in the Project Settings dialog to show the Remote node.
  5. Check the Remote Debugging checkbox.
  6. If you are on Windows and using the ojvm client VM
    • Choose the Attach to OJVM radio button.
  7. If you are on not using the ojvm client VM (For Example, if you are using Hotspot or classic)
    • Choose the Attach to JPDA radio button.
  8. Close the Project Settings dialog.

Debugging the Enterprise JavaBean

Your Enterprise JavaBean must be deployed to JBoss before you can debug it. Refer to the Oracle TechNote How Do I Deploy Enterprise JavaBeans to JBoss? for information on deploying your Enterprise JavaBean to JBoss.

If you have not already set a breakpoint in your Enterprise JavaBean, do so now. You should set one on the setInfo method of the sample bean created in our deployment TechNote.

 

There are two actions required to debug your Enterprise JavaBean. You will be debugging JBoss from the project, while running the client application separately.

  1. First you must start start the debugger by right-clicking your project's node in the System Navigator and choosing Debug <project name> from the context menu. When the dialog asking for the hostname and port number is displayed, use port 4000 and leave the hostname blank as it will default to localhost.
  2. Second, you must execute the EJB Client you created by right-clicking on the Java node and choosing Run <filename.java> from the context menu. The EJB Client will have a name similiar to SampleMySessionEJBClient.java.

Here are the context menus for each of these actions:

 

JDeveloper will stop at your breakpoint set inside the methon of the EJBBean class once it has been invoked by the client application (SampleMySessionEJBClient).

 

References

E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy