This tutorial will take you through the steps required in developing, deploying and testing a EJB Stateless Session Bean Web Service in Apache Geronimo. After completing this tutorial you should be able to understand how to develop simple JAX-WS compliant EJB web services in Apache Geronimo using Eclipse development environment.
It is highly recommended that you go through the Developing a JAX-WS POJO Web Service tutorial before jumping into this. We will be using the same sample from the tutorial to develop a EJB Web Service.
To run this tutorial, as a minimum you will be required to have installed the following prerequisite software.
- Sun JDK 5.0+ (J2SE 1.5)
- Eclipse 126.96.36.199 (Eclipse Classic package of Europa distribution), which is platform specific
- Web Tools Platform (WTP) 2.0.1
- Data Tools Platform (DTP) 1.5.1
- Eclipse Modeling Framework (EMF) 2.3.1
- Graphical Editing Framework (GEF) 3.3.1
Details on installing eclipse are provided in the Development environment section. This tutorial will take you through the following steps:
Setting Up Eclipse for Application Development
- Create a Stateless Session EJB Project
- Select File->New->Project
- In the popup window, select EJB->EJB Project and then click Next
- Type jaxws-converterejb as the Project Name and click Next..
- The default option should work for Geronimo, so click Next
- Here also default options will work, but the service and wsdl file will be located at the URL specified by the annotations
- Modify the Group Id to org.apache.geronimo.samples.jaxws and the artifact id to jaxws-converterejb.
- Click Finish
This completes the configuration of Eclipse for application development.
Creating the Web Services Implementation code
To deploy the Converter EJB Service, we are going to create a remote interface and a stateless session bean that implements the interface. The steps required are as follows:
- Right click on ejbModule and select New->Package
- Name the package to org.apache.geronimo.samples.jaxws and click Finish
- Right click on the new package and select New->Interface
- Name the interface as Converter and click Finish
- Add the following code to the Converter class
- Right click on the new package and select New->Class
- Name the class as ConverterBean and click Finish
- Add the following code to the ConverterBean class
This completes the development of the Web Service Implementation code.
Setting Up the Deployment Descriptor and Deployment Plan
- Expand the META-INF directory present under ejbModule and add the following code to ejb-jar.xml
- Add the following code to ejb-jar.xml
- Also add the following code to the openejb-jar.xml present at the same location.
This completes the setting up of Deployment descriptor and Deployment Plan.
Deploy and Test the Web Service
Now, we will look into the steps involved in deploying and testing our web service without any clients.
- Right click on the Apache Geronimo Server Runtime present in the servers view and select Add or Remove Projects
- In the popup dialog, select the jaxws-converterejb project and click Add
- Make sure that jaxws-converter is in the configured projects list and then click Finish
- Wait for some time till the server status is changed to synchronized.
- Once the application is deployed on to the server, Launch a browser and go to the following url.
- Now you should see the screen telling that service is located at the following URL