Monday, August 4, 2008

Creating a J2EE Project in WebSphere Rational Application Developer: A JEE Tutorial

Creating a J2EE Project and Web Module

1. Once the WSAD has started, from the menu select File à New à Enterprise Application Project.

2. You will be asked if you wish to create a J2EE 1.2 or J2EE 1.3 compliant application. Pick your poison, but I'm going with a J2EE 1.3 project.

Click ‘Next >’

3. Your application needs a name.

I'm going to call mine PulpJava, after my fabulous website.

Resist the temptation to click finish. We may have established an ear, but we still need to add our web module.

Click ‘Next >’

NOTE: when we add a web module, the word 'Web' will be appended to the end of your application name, so mine will be called PulpJavaWeb. If you named your enterprise project, say, StrutsWeb, then your web module would be StrutsWebWeb. Now that'll work fine, but it'll look stupid. Always try your best not to look stupid.

At this point, you have an enterprise application, but you don't have any web or ejb modules associated with it.

4. To add a little spice to your application, click the New Module button.

Magically, after hitting the 'New Module' button, the WSAD asks to create four new modules, a client, EJB, web and connector module. We only want a web module.

5. Deselect the checkboxes next to every project option except "Web module." Look to the diagram for further clarification.

Notice the name of the Web Project is PulpJavaWeb.

Click ‘Finish’

NOTE: Whenever you're learning, I always suggest clicking every button on the screen and see what flies. Think outside of the box and explore!

However, in this situation, it is very important NOT to select the EJB project option. There's a little quirk with the spec that says every EJB module must have at least one EJB in it. If it doesn't, it won't deploy properly. As a result, if you create an EJB project, but do not add an EJB to it, your application, which includes your web module, won't run.

This can be a frustrating problem to troubleshoot. But bear this warning: if you're not going to immediately create an EJB, which we are not going to do, do NOT create an EJB module.

After clicking 'Finish' on the New Module Project window, you won't actually be finished. To be finished, you must again click the Finish button, although this time it is the 'Finish' button on the "EAR Module Projects" window.

6. Click the ‘Finish’ button to create your enterprise application and web module.

If clicking 'Finish' twice seems confusing or strange, it is because you are confused and strange. Clicking 'Finish' twice to complete a task makes perfect sense, and I'm surprised it isn't seen in applications more often.

7. Explore your project in the J2EE Hierarchy view.

From the J2EE Hierarchy view of the J2EE perspective, looking under the ‘Enterprise Applications’ directory, you can see that one J2EE project named PulpJava that contains a web module named PulpJavaWeb.


No comments: