Geronimo_MoinMoin_wiki > EclipseDeployment
Added by Confluence Administrator, last edited by Confluence Administrator on Aug 02, 2006

Developing Geronimo in Eclipse

This section is written to help someone get Geronimo into the Eclipse workspace as an Eclipse project and start being able to use Eclipse to make code changes while debugging a server. For purposes of this discussion the development OS is Windows and CYGWin is used for Bash shell support. Please adjust these instructions for your environment.


Step 1 - Software Pre-requisites.

In this section the various tools you'll need are described and suggestions on where to locate them are made. The below are suggestions. You can find these tools on other sites and / or mirrors.

  • CYGWin
    • CVS (make sure to include it when installing CYGWin)
  • Maven 1.0.2 or 1.1-beta-2
  • Ant
  • SubVersion
  • J2SE 1.4.2 It is important to use the Sun JDK as Geronimo is currently using the Sun ORB for RMI. Using a different JDK or different version of the JDK may result in compilation errors.
  • Eclipse 3.1 You can use earlier versions of Eclipse but 3.1 has the nify feature of scanning a tree for all projects so if you can do it use the latest version.

The easiest thing to do to make sure these are available on the command line is update your environment entries after installing Maven and Ant.


Step 2 - Download Geronimo and other Components

The instructions for downloading Geronimo can be found here. I'm including the various commands here as well so you can avoid page hopping.

Enter the following on your command line. This will pull Geronimo down on your local harddrive. A subdirectory will be created in your current directory called geronimo.

$ svn checkout http://svn.apache.org/repos/asf/geronimo/trunk geronimo

The above command will checkout the Geronimo Source and get you ready for the subsequent build stages. It will run for a bit so get a cup of coffee.

Change to the geronimo directory.

$ cd geronimo

To pull the source for the other packages that make up Geronimo (OpenEJB) do this (it is suggested that you are using 1.x branch of Maven):

$ maven m:fresh-checkout

The source will be pulled. I have experienced errors periodically because of intermittent network problems. Unfortunately you'll just have to try a couple of times if there are problems.

Next you'll build a server runtime for execution. For Geronimo 1.0 or later, this is done by:

$ maven new -Dmaven.test.skip=true -Dmaven.itest.skip=true

Prior to the Geronimo 1.0 release, this was done by:

$ maven m:build -Dmaven.test.skip=true -Dmaven.itest.skip=true

The properties for skipping the tests are pretty much required to reduce build time. If there are compilation errors these should be investigated and the dev@geronimo.apache.org mailing list should be checked so you don't solve the same problem twice.

Next, the Eclipse projects can be generated by invoking:

$ maven -o m:eclipse

or, if you are not generating xmlbeans

$ maven -o -Dgoal=eclipse multiproject:goal

The -o option will do an offline build and this goes pretty quickly. You can optionally specify the following properties to add the Maven specific natures and builders for all projects by appending the following properties to the goal.

-Dmaven.eclipse.buildcommands=org.mevenide.ui.mavenbuilder -Dmaven.eclipse.projectnatures=org.mevenide.ui.mavennature

However, the Maven builder tremendously slows down the Eclipse build process. So it is recommended that you do not add the maven nature and builder to every project unless it is absolutley necessary. The recommended alternative is when the workspace is launched to right click on projects who wish to modify and select Maven --> Add Maven Nature. This will greatly improve performance and avoid invoking the Maven builder on unncessary projects.

The -D properties will add the necessary builders and natures to each of the projects for use by the Mavenide Eclipse Plugin.


Step 3 - Firing up Eclipse

At this point we'll assume that you've already pulled Eclipse and installed it.

You'll open a blank workspace and Import the Geronimo project. This is done by accessing the File -> Import -> Existing Projects into Workspace command. You can choose to import all geronimo and geronimo related projects by selecting the root folder of the Geronimo project. This is highly recommended for the first time users. Or, to import only the Geronimo modules, select the 'modules' folder from the root.

Once this is accomplished you should see something like:

Notice that there are a ton of errors. To correct these we'll have to setup the environment a bit. This includes:

  • Setting the Maven CLASSPATH variables
  • Selecting the right JDK
  • Setting the Java Compiler Options
  • Fixing problems in the current release (yup, I'll open bug reports unless you beat me to it

Setting the Maven Classpath variable

First order of business is to tell Eclipse where the Maven repository is. To do this select the settings in Window => Preferences

Click on New and a new Pop Up will appear. Enter the appropriate directory here.

A number of errors should disappear. There is still a bit of work to do...

Selecting the right JDK and its Options

Eclipse allows you to select from any number of installed JDKs. Assuming that you pulled a Sun JDK in the beginning selecting the compiler and setting the compile options should be simple. Again, selecting Window -> Preferences you can navigate to the following screen.

Make sure the Sun JRE is checked.

Next, we need to update the compiler settings.

Compiler Settings

The default settings for the compiler are not correct. Here is a snapshot of the compiler settings as the appear by default:

Make the changes as indicated in this snapshot and apply them.

This will eliminate a large number of compilation problems due to the wrong JDK compiler version and syntax checking being done. A few more warnings can be eliminated by:

Depending on your coding and development preferences you can eliminate many of the warnings in the task window. Unfortunately, there are other errors as well that will require changes to the build. For now they are documented here:

To prevent Eclipse from copying the .svn directories to the output folder of projects, do the following:

  • Expand the Java node in the preferences tree
  • Expand the Compiler node in the preferences tree
  • Click on the Building node
  • Click on the Output Folder Settings to expand it
  • Append ,*.svn to the Filtered Resources field.

If you plan on contributing code or patches to the project, please configure eclipse not to use tabs by doing the following:

  • Expand the Java node in the preferences tree
  • Expand the Code Style node in the preferences tree
  • Click on the Formatter node
  • Select the "Java Conventions built-in" profile, that uses 4 spaces for tabs.

The final look of the WorkSpace

Here is what the workspace should look like when your done with the above steps.


Creating Maven and Server Launch Configurations

NOTE: The supplied screenshots may not reflect the instructions. If there is a conflict, follow the instructions.

This section will explain configuring your Eclipse workspace to provide intergated Maven support. We will create a set of configurations that will assist in building and launching Geronimo.

To install Mevenide through the Eclipse Update Manager, create an Update Site pointing to the following site and follow the directions remembering to select both the Maven and Mevenide features.

http://mevenide.codehaus.org/release/eclipse/update/site.xml

Next, to avoid manually creating a set of Maven and Geronimo launch configurations by hand, you can import the a set of configurations and modify them for your customization. Download and extract eclipselaunchconfigs.zip into your $WORKSPACE\.metadata\.plugins\org.eclipse.debug.core\.launches folder and restart eclipse.

http://people.apache.org/~sppatel/eclipselaunchconfigs.zip

You will then automatically have the neccessary configurations needed to develop and debug Geronimo with eclipse. You can now skip ahead to the section entitled Debugging Geronimo as a Local Application

However, those who wish to better understand and create the configurations' by hand, the steps to create these configurations are...

After installing the Maven and Mevenide features, select geronimo project, create a new Maven Configuration by going to Project – >Maven --> Manage Configuration as shown below.

Hit New to create a custom configuration named Build. Select the Build is happening offline option. And for the goal to run specify…

default â€"Dmaven.test.skip=true â€"Dmaven.itest.skip=true

Select the Patterns tab define a new File Pattern of /.java. At the bottom, make sure that *Auto Build is selected.

Close the wizard. You have now created a maven configuration that will run automatically through the Eclipse build process whenever a java source file is changed. The specified goal will create the updated snapshot jar for one or more projects and will install them to you maven repository.

This maven configuration will be applied to all Geronimo projects since they contain the maven builder that was automatically added to the .project files with the maven m:eclipse goal run earlier. However, we want to disable this for the geronimo project. Right click on the geronimo project and choose Maven --> Remove Maven nature. This will prevent creating a full install snapshot with every build. Instead for geronimo, we will create a different launch configuration specicially for this project. Since building geronimo is relativaly time consuming, it will not be configured to be invoked as part of the eclipse auto-build process.

From the menu, select {{Run --> External Tools --> External Tools... }}

In the wizard, select Run Maven and hit New to create a custom configuration named Assemble Geronimo. Select the Build is happening offline option. And for the goal to run type:

default -Dgeronimo.assemble.clean=false -Dgeronimo.assemble.minimal=true -Dgeronimo.assembly.zip=false

Select the Main tab and specify the following base directory. Then close the wizard.

${workspace_loc:/geronimo}

The next configuration we want to create is a Server Launch configuration that runs as a local application rather then a remote application (as a later section will describe).

From the menu, select Run --> Run....

In the wizard, select Java Application and hit New to create a launch configuration named Geronimo - Server. For project choose:

geronimo-system

For main class select:

org.apache.geronimo.system.main.Daemon

Select the Classpath tab. Select Add Jars... to be added to the User Entries list. Add the following entry:

server.jar - \geronimo\target\geronimo-1.0-SNAPSHOT\bin\

You must remove all other entries in the User Entries list. Your screen should look like the following...

Next, select the source tab and add all Geronimo projects.

Debugging Geronimo as a Local Application

This section will explain launching Geronimo as a local java application within eclipse. Using the integrated Maven launch configurations described in the previous section, you will be able to make and debug changes to the Geronimo projects.

Whenever source file changes are made, an eclipse build is invoked, the maven builder will automatically be triggered to update the snapshot jars for each individual project that contained java source modifications for that build cycle. The jar will be created inside the project and will then be copied to the Maven repository.

Now in order for the server to use the updated snapshot(s), the repository from the geronimo project needs to be updated as well since this is the installation that we pointed to in our Geronimo - Server launch configuration. This is done by launching the external tool configuration Assemble. This will regenerate the install image so that the repository is updated with the latest snapshot jars. Be sure the server is not running before running this operation.

Now you are ready to launch server and your changes will be in affect.

For subsequent changes you simply stop the server, run Assemble, and relaunch Geronimo - Server.

_Note: Running Assemble is a long running operation since the maven assemble goal is doing alot of work. Secondly, the entire image is being rebuilt, so any installed applications or any other configuration changes to the server will be lost. You can modify the supplied parameters for the assemble goal to not delete the target and do the minimum amount of work, however this seems to cause random failures when the server is relaunched. So to be safe, the default is to do run the full assemble maven goal.

Debugging Geronimo as a Remote Java Application

In a next step you need to start Geronimo for debugging in Eclipse:

java -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar %GERONIMO_HOME%/bin/server.jar %1

In Eclipse set the breakpoint in the class you are debugging and then select Run -> Debug right click on Remote Java Application and select 'New'. Select the module which you would like to debug. Change the port number from 8000 to 5005.

Select the 'Source' tab and Add -> Java Project. Select all previously imported Geronimo Projects. This way Eclipse can find the source codes of all classes you come across during debugging.

Then, press 'Debug' and change to the Debugging perspective within Eclipse. On the upper-left side you should be able to see the threads and stack traces, in the upper-right side you can see all class variables, and on the lower-left side you can see the source code.

Changes you make during the debug session will be reflected in that session. However, if you cycle the server and restart it the changes will be lost and your source tree will be out of sync with the running server.

How to solve this issue will be posted here soon