Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


 



Remote Debugging OFBiz in Eclipse

I'm fairly new to Java web development and it took me a little time to figure out how to start debugging OFBiz through Eclipse, so I thought I'd share what I found to speed things up for others. This is the recommended way for debugging ofbiz.

Step 1: Run OFBiz in debug mode

Normally we start OFBiz with the command line

%JAVA_HOME%\bin\java -jar ofbiz.jar

To start in debug mode use the command line

%JAVA_HOME%\bin\java -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8091 -jar ofbiz.jar

This changed command line instructs java to run in debug mode listening for a socket connection on port 8091 for a debugger to connect. You can change the port number to any port not otherwise being used.

Step 2: Connect to OFBiz with Eclipse as a Debugger

Before connecting you have to create a new debug configuration.

  • In Eclipse (at least, in 2.1.1) choose Run->Debug... from the menu. A Debug window should pop up.
  • Select Remote Java Application from the tree on the left.
  • Click New (button on the bottom left).
  • Type a name at the top (OFBiz, perhaps?)
  • On the Connect tab
    • Pick ofbiz for the project
    • Select Standard (Socket Attach) for Connection Type
    • Type localhost for host
    • Type 8091 (or whatever port you chose) for port
  • On the Source tab
    • Click Add Projects... (buttons on the right)
    • Select the ofbiz project
  • Click ApplyIf you have OFBiz running debug (Step 1 above) you can start debugging by clicking Debug (on the bottom) now.

    You know that you are conneced when you see a start stop button in the debug perspective of eclipse First created by Jarrod Ribble

...

Running (or debugging

...

) OFBiz in Eclipse

  • Select OFBiz project, right-click on it -> Run As -> Run ... (alike for Debug)
  • Select Java Application and click on New
  • Set Run

...

  • configuration name to OFBiz
    • Main tab:
      • Project: OFBiz
      • Main class: org.ofbiz.base.start.Start
    • Arguments:
      • VM arguments: -Xms128M -Xmx256M
      • Working directory: Use default working directory
    • Classpath
      • Bootstrap Entries: JRE System Library
      • User Entries: ofbiz.jar from OFBiz project
    • Environment
      • Add environment variable LC_ALL=C (Optional, Linux only)
  • Click on Apply and Run (or Debug)

...

Test Debugging

  1. Place a breakpoint on the line "Start start = new Start(args);" which is the first line in main() within the Start.java file
  2. Go to the OfBiz 'Run' menu and select 'Debug'
  3. If you hit the breakpoint and can step then you're all set. If you cannot then move onto the the Troubleshooting Section

    Troubleshooting Eclipse Breakpoints

    There is rumour around the Eclipse discussion groups that this has something to do with the Workspace configuration files when running Eclipse within the Windows environment. The Workaround I have found to be perfectly effective in resetting workspace files is as follows ;
    Use a shortcut to eclipse as follows:
    C:\eclipse\eclipse.exe -data c:\myworkspace -vm c:\j2sdk1.4.2_01\jre\bin\javaw
    This will put your project files in c:\myworkspace (create that directory first). This seems to work best for me, I didn't have much luck with the default project directory.
    (Thanks to Mike Bangham who discovered this) | |