Using RAD 7.0 (Rational Application Developer) with EJB3 on Websphere 6.1
RAD 7.0 (Rational Application Developer) is a complete IDE from IBM to work with Java application. However the version 7.0 does not offer support for EJB3 (if you want to full support, you must try out the version 7.5 Beta), but you can use it to create your EJB3 project without problem. In this article I am going to show you how to do that in a simple way.
First of all, you must have installed the Websphere 6.1 with Service Pack for EJB 3. If you do not know how to install it, check out this post.
Creating the Enterprise Application Project
Open the RAD 7 and the J2EE Perspective. Then right-click on Package Explorer and go to New -> Enterprise Application Project
Put the Project name (in my case Test) and click on Finish button.

You are going to see on Package Explorer the project called Test, however RAD will complain about an error “A J2EE Enterprise Application must contain one or more modules. Test/META-INF application.xml”. It happens because none project have been added to EAR project yet.
Creating the EJB Project
Important: DO NOT CREATE AN EJB PROJECT USING RAD WIZARD!!!. If you create an EJB Project using RAD Wizard, it will create the files used for EJB 2.1, not 3.0.
So, what kind of project should I create? Answer: Create a simple Java Project.
You can go to Java perspective, right click on Project Explorer and go to New -> Project. In my case, I’ve created a Java project called TestEJB.
After the project is created, it is time to add it as a Project Utility in the EAR and also add it (manually) as a EJB module.
Adding the EJB Module to the EAR
Open the EAR Deployment Descriptor (application.xml) in J2EE Perspective. Click on Module tab and then Add the Java Project as Project Utility JARs.

After that, go to Source tab and insert the following code:
TestEJB.jar
Save the application.xml file and you will notify that RAD will not complain about the previous error anymore.
Using annotations
If you have Websphere 6.1 + EJB3 service pack installed, you will be able to use the EJB3 Annotations.
If you do not want to use the ejb-jar.xml file (it is recommended), you must provide, at least, one class ANNOTATED, otherwise Websphere will not start the application.
So, just for test, create an Interface (File -> New -> Interface). Put it into stateless package and give it a name: TestComponent. Its content is below:
package stateless; public interface TestComponent { public void doSomeStuff(); }
After that, let’s create a class that implements this interface. Go to File -> New -> Class, put in the same package (stateless) and put the name: TestComponentBean. The content is below:
package stateless; import javax.ejb.Remote; import javax.ejb.Stateless; @Stateless @Remote(TestComponent.class) public class TestComponentBean implements TestComponent { public void doSomeStuff() { System.out.println("Hello EJB3 World in Websphere 6.1 + RAD 7"); } }
Done! Our EJB Project is created and ready to be used. Also, a simple component has been developed.
As you can see, none XML file were configured, but if you want to map your component through a ejb-jar.xml file, you must create it within META-INF directory. A simple content is below:
TestEJB TestComponent stateless.TestComponentBean Stateless
Creating a Web Project as Client
To make sure our EJB Project, as well as our first component are working, let’s create a Web Project as client to call the EJB component.
Open the Web perspective and create a new Dynamic Web Project. In my case, I’ve created with the name TestWeb. Make sure to check the option Add project to an EAR and choose the Test ear.
Right after the Web project is created, you must associate it with the EJB project. To do that simply right click on TestWeb -> Properties -> J2EE Modules Dependencies. Check the EJB Project.

Now the Web Project will recognize the TestComponent interface from TestEJB project.
Create an Servlet to call the EJB Component, for instance: TestServlet and insert the following code:
package servlets; import java.io.IOException; import javax.ejb.EJB; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import stateless.TestComponent; public class TestServlet extends javax.servlet.http.HttpServlet { private static final long serialVersionUID = 1L; @EJB private TestComponent testComponent; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //Call the method from EJB component testComponent.doSomeStuff(); } }
To run the code, right-click on TestServlet, go to Run As -> Run on Server. After the server is started, you should see on the Console the phrase:

The article is over. Any question, comment, feedback are welcome. I hope this article be useful for anyone else.

Brazilian guy, IT Specialist, Linux User, IBM Certified SOA Fundamentals, Rational Developer, Sun Certified Java Associate 1.0, Sun Certified Java Programmer 1.4, Sun Certified Web Component Developer 1.4 and Sun Certified Business Component Developer 5. Also Ruby and Python enthusiastic.
This article is a very useful article, it helps me to start working with EJB3 on webSphere.
I have only one comment, on TestServlet class, the session should be initialized before you can use it, in the current code a nullPointerException will be thrown.
Thanks,
Shadi
Unfourtately the jndi lookup doesn’t work (that#s why Shadi gets the NullPointerExcetion).
I tried both ways:
1. Through the JNDI, you still have the portability:
//get the default JNDI initial context
Context ctx=new InitialContext();
//get the bussiness interface
Object obj=ctx.lookup(TestComponent .class.getName());
//convert obj
TestComponent testComponent=(TestComponent )obj;
2. Through the @EJB annotiation:
@EJB
private TestComponent testComponent;
Both haven’t worked - any ideas?
Weird, because here the example, as well as other EJB3 projects are working fine.
Are you sure the EJB3 Feature Package is installed on Websphere Application Server 6.1?
Try to check out the following link: http://jairrillo.wordpress.com/2008/06/06/applying-ejb3-service-pack-on-websphere-61/
Feature Package is installed:
WebSphere Platform 6.1 [EJB3 6.1.0.17 cf170821.02] [BASE 6.1.0.17 cf170821.07]
I’m using RAD 7.0.0.6 by the way.
But I forgot to manually add the EJB project - now I get an error after the validation of the application descriptor:
The deployment descriptor of the module ‘Blb_EJB30_Sample_Ejb’ cannot be loaded.
Any ideas?
Did you add EJB Module as Utility JARs and then add it manually into application.xml file?
Also, check if you have the ejb-jar.xml file within EJB Module. If so, remove it. RAD 7 does complain about that file. Use annotations instead.
Hi jrjuniorsp,
can you send me your sample as an EAR File (joern_kolberg@yahoo.de)?
having the same “The deployment descriptor of the module ‘*.jar’ cannot be loaded” error in RAD (7.0.0.7)
When deploying it to WAS (app server, Web service and ejb feature packs all at version 6.1.0.17)
Also getting this error when i attempt to deploy it to the server:
[14/08/08 16:09:56:271 BST] 00000013 wtp E IWAE0006E Archive is not a valid EJB JAR File because the deployment descriptor can not be found (case sensitive): META-INF/ejb-jar.xml
IWAE0006E Archive is not a valid EJB JAR File because the deployment descriptor can not be found (case sensitive): META-INF/ejb-jar.xml
Archive_is_not_a_valid_EJB_EXC_
Any ideas? Does WAS\RAD not support JEE 5 yet to allow deploying without ejb-jar.xml?
Or is there a setting somewhere I need to change?
Hey John,
Actually, RAD 7 doesn’t allow JEE 5 yet (only RAD 7.5 Beta), but WAS 6.1 with EJB feature back allows.
You do not need to use the ejb-jar.xml file, however YOU MUST, at least, have one SESSION BEAN annotated with annotations.
Cheers. I managed to get it working in RAD7 by creating an EJB project and replacing the ejb-jar.xml to an empty EJB3 versionand seems to work ok.
Contenst of ejb-jar.xml file:
ejb2ejb
ejb2ejb
Hi Guys,
Does anyone tried using @Webservice annotation in an EJB3 and made it work as webservice.
thanks
Vish
Hi Vish,
You must install the EJB3 Feature Pack + WebService Features Pack. After that, you will have the @Webservice annotation available.
I hope to write a topic about it in the future
Hi Guys,
you hav eto turn off the EAR validation option for the enterprise application project, then the error message
“The deployment descriptor of the module ‘Test_Ejb3’ cannot be loaded.”
disappears an dthings work out fine
ak0z8uzr7dh8bdcq
your computer should received some data from the website in order to turn on videos.go to>control panel>internet options>advance tab,enable options there pertaining to multimedia.or check out security tab.good luck.
________________
unlock iphone 3gs
Thanks a lot, I tried this tutorial out and was able to get it working.
I just wanted to add some notes on the problems I faced. I am running RAD 7.0.0 with WAS EJB3 fixpack (WebSphere Platform 6.1 [EJB3 6.1.0.21 cf210844.04] [BASE 6.1.0.21 cf210844.13])
One problem I faced was that when I created a Java and the Web Project, the dependency on the j2ee.jar (which contains the EJB3 annotations related .class files) had to be added manually. This took care of the compilation error shown with the annotations in the “EJB” and the servlet.
Also, in the source tab of the applcation.xml I had to add this piece of code to add the module dependency:
TestEJB30.jar
The listing in the article says - add “TestEJB.jar” to the XML, does not mention which element in the XML it needs to be added.
Thanks again for the fine article.
Raks
Ok i have to take back the second comment of mine. Seems like whatever s/w is running this blog, strips out all ‘HTML tags’ from the comments and the article. This was the code I was talking about that needs to be added to application.xml:
Try1:
<module id=”EjbModule_1257934486729″>
<ejb>TestEJB30.jar</ejb>
</module>
Try2:( Replace [lt] and [gt] with ‘less than’ and ‘greater than’ symbols.)
[lt]module id=”EjbModule_1257934486729″[gt]
[lt]ejb[gt]TestEJB30.jar[lt]/ejb[gt]
[lt]/module[gt]
Thanks
Raks
Thanks for your feedback raks81. I’ve been working with RAD 7.0 for a while and unfortunatelly it wasn’t implemented for EJB3. If you want full support, I advice you to migrate to RAD 7.5 + WAS 7.0
Ok. So we are planning to kick off a project that will use EJB3 and we are planning to use RAD 7.0 with WAS 6.1 + EJB3 fixpack, just because its easier as we already have licenses for this setup. I understand that 7.0 + 6.1 was not intended for EJB3 development, but do you mind sharing the issues you had faced with this combo?
Thanks, Raks
I do not have RAD 7.0 and WAS 6.1 in my computer anymore, but as far as I remember, I had problem only with the ejb-jar.xml file. Even you’re not using it, it must be placed into ejb module. In WAS 7.0 it is not required.
Ok. Thanks!
Can you please tell me how to access the enterprise bean from stand alone java client application using RAD7.0 and WAS 6.1…I will be thankful to you if you could provide me similar tutorial for that too..
hi Jair,
I am just trying to invoke a EJB deployed in a remote machine. @EJB is working fine in case of local look up but when i am trying to invoke it using a servelet from a a different machine it is failing.
Can you help ?
it will be indeed a great help to me
Hi Pragna,
In this case you must use a remote EJB. Usually, the AS has a properties file that you can indicate where your remote components live. Also, you can do a JNDI lookup and inform the address there. Try to google about EJB3 and Remote component and hopefully you’re gonna find a article useful