Home > Documentation > Developing > Tutorials > Developing EJB applications > 5-minute Tutorial on Enterprise Application Development with Eclipse and Geronimo |
This tutorial walks you through configuring, developing and deploying an enterprise application with Eclipse and Geronimo. To run this tutorial, as a minimum you will be required to have installed the following prerequisite software.
To run this tutorial, as a minimum you will be required to have installed the following prerequisite software.
Geronimo version 2.1.x, Java 1.5 runtime, and Eclipse Ganymede are used in this tutorial but other versions can be used instead (e.g., Geronimo version 2.2, Java 1.6, Eclipse Galileo)
Details on installing eclipse are provided in the Development environment section. This tutorial is organized in the following sections:
Start from creating an enterprise application project from the eclipse workspace.
If asked about changing to the Java EE perspective, click Yes. You may want to select the Remember my decision checkbox to avoid dealing with it in the future.
You should now have the following project structure.
Error message
Don't worry about the error cvc-complex-type.2.4.b: The content of element 'application' is not complete... for now. We'll fix it in the next step when you define an ejb module (and webapp module afterwards).
The next step is to create an EJB project to hold your EJBs.
You should now have the following project structure.
Important
Remove ejbModule/META-INF/openejb-jar.xml
file in the SampleEJB project as it causes deployment issues. See the file highlighted in the image above.
Now that you have EAR and EJB projects created the next step is to create a Dynamic Web project to hold your Web application.
You should now have the following project structure.
Every stateless session EJB has its own business interface. There are three types of business interfaces - @Remote
, @Local
and @WebService
- and combinations of these three. EJB development starts from defining a business interface and implementing it in a bean implementation class. We do this in the next steps.
Now we need to add a business method and mark the interface as a remote one with @Remote
annotation.
Implement the business method sayHello and mark the class as a stateless session bean with the @Stateless annotation.
The time has come to use the EJB in the Web application. In this section we create a jsp index.jsp
page that executes a servlet MyServlet that in turn executes the ejb MyStatelessSessionBean.
index.jsp
index.jsp
and click Finish.
Since the servlet calls the EJB, the Web project the servlet is in depends on the EJB project. Let's define the dependency.
MyServlet.java
opens up automatically for editing after creation, update the servlet as shown below to call off the ejb when executed.
All it's left before we test this sample it to deploy it. This task is done automatically for you when you choose to run the application directly from the eclipse workspace.
John Doe
and press Press me! button.
Bookmark this on Delicious Digg this | Privacy Policy - Copyright © 2003-2011, The Apache Software Foundation, Licensed under ASL 2.0. |