Preliminary Setup

If you have not already done so, import ofbiz into Eclipse with File > Import > "Existing Projects into Workspace". Note that the name of the project and its name in .project file must be the same.

The next step is to enable Eclipse to work on your .xml, .ftl, and .bsh files. First, install an XML editor such as the free XMLBuddy. Then, install the Freemarker Eclipse plug-in. Finally, go to Windows > Preferences > General > Editors > File Associations and add "*.bsh" and associate it with the Scrapbook editor.

You should also set your editors to be compatible with OFBiz coding convention. For Java files, go to Windows > Preferences > Java > Code Style > Formatter and create a new profile. Set your tabs to 4 spaces. Similarly, go to Windows > Preferences > XMLBuddy > Formatting and click on "Use spaces for tabs", or configure your XMLZ editor likewise.

You can toggle between code view and directory/file view by switching Eclipse from "Java Perspective" our "Java Browsing" and "Resources". If you have new components, add them to your .classpath file as a <classpathentry> so they can be viewed in the Java views.

Java Debugging with Eclipse

Click on the green bug icon on the Eclipse toolbar, or click on "Run" on the top menu bar, then "Debug". Then click on "Java Application", click on "New" to create a new configuration for OFBIZ.

Type in the start class name. Then click "Apply" and "Close".

Now you need to fix all of these problems Eclipse has found (see box at the bottom):

The most common problem involves missing class and libraries from the build classpath, which you add with Project > Properties > Java Build Path:

You may also have to exclude third party source file by editing .classpath in eclipse/workspace/ofbiz and adding <classpathentry excluding="org/ofbiz/securityext/thirdparty/truition/*" kind="src" path="applications/securityext/src"/>

You have to add the OFBiz base/config directory to your class path. Use Project > Properties > Java Build Path > Libraries > [Add Class Folder] and add the base/config directory:

This is what it looks like with base/config added:

Now you need to add your JDBC library JARs to the Eclipse classpath. Use Project > Properties > Java Build Path > Libraries > [Add External JARs] and select the JARs from ofbiz/framework/entity/lib/jdbc. Here, we add the JARs for the embedded derby database:

You also need to add the JARs for Tomcat from ofbiz/framework/catalina/lib. Note: Current versions of OFBiz have more JARs than on this screenshot. Add them all.

You may need to do this for compiling JSP's:

Now edit base/config/ofbiz-containers.xml and comment out both the rmi-dispatcher and the rmi-print-server (not shown here):

Now OFBiz should run in Eclipse. Here are some screenshots of debugging OFBiz with Eclipse:

Miscellaneous Notes

When you update your code with an $ svn update, Eclipse does not know that new files are available. Thus, you may start to have build problems. Do a File > Refresh from within Eclipse to bring it up to date.

Make sure that ofbiz/ is not in your Project > Properties > Java Build Path > Source. Only ofbiz/applications/.., ofbiz/framework/.., ofbiz/hot-deploy/.. directories should be there, or you'll get an error like:

Cannot nest output folder "hot-deploy/crmsfa/src" inside "ofbiz/"