EJB Project Settings in RAD 7

Posted 362 days ago

Lately, I've been using IBM's Rational Application Developer 7 to develop J2EE applications targeting the WebSphere 6.1 platform... all in all, I have to say RAD is a phenomenal tool with excellent integration to the platform. My only real complaint after almost a year of use is it's default paths and settings when you create a project.

By default, your source folder is named "ejbModule" - this in and of itself is not an issue... but "ejbModule" is also used as the default output folder, AND is where the deploy tools output their generated code.

The result is that when you publish your application to a local test environment, you wind up with a very messy source folder.

My original "work-around" for this was to ignore the source folder completely, and just access my beans via the deployment descriptor hierarchy. This works out well most of the time, until you change the remote or local interface of a bean. Then the generated sources need to be recreated... and to recreate them, you need to delete them (why they're not deleted when you clean your project is beyond me)... since they're mingled in with your actual source files, this is a very dangerous thing to do. Several times, I've accidentally deleted source files, and got myself into irritating situations attempting to restore files out of my repositories and other backups.

But today, persistence paid off. I've finally managed to configure my projects to have a very clean structure in RAD. It's actually so simple and obvious, I can't believe it took me this long.

The key is to do two things:

  1. Create a second source folder, called "src". This is where I keep my sources. META-INF can, and should, stay in the ejbModule folder. RAD7 seems to get confused when you try to move this in an existing project.
  2. Go into your project settings and edit the Java Build Path. On the "Sources" tab at the bottom, you'll find the default output folder. Click browse, create a new folder in your project called "bin", and choose that.

Now, your structure should look something like this:

Project/
   source/
      com/
          timfanelli/
              <etc...>
   ejbModule/
      META-INF/
   bin/

When the deploy tool runs, your sources remain under source and generated code is created under the ejbModule folder. When you build your project, all the binaries go into bin. Cleanup is a snap then, when you want to delete the deploy tool's generated code, simply delete all source packages under ejbModule.

About

My name is Tim Fanelli, I am a software engineer in Northern NY. I spend most of my time working, and when I can, I try to post interesting things here.

Cigar Dossiers