...
Start from creating an enterprise application project. Select File > New
, select Project...
(or alternatively press Ctrl-N
) and in the popup window select select Enterprise Application Project
in J2EE
category.
geronimo-sample-ear.PNG
Press Next
.
In the EAR Application Project wizard type in SampleEAR as the project name and select Apache Geronimo v2.0 in Target Runtime
. Leave the rest as is.
geronimo-sample-ear-details.PNG
Press Next
twice.
...
- Group Id: sampleear
- Artifact Id: sample-ear
geronimo-sample-ear-plan.PNG
Press Finish
.
When asked about changing to the Java EE perspective, press Yes. You may want to select the Remember my decision
checkbox to avoid dealing with it in the future.
geronimo-sample-ear-javaee-perspective.PNG
You should now have the following project structure.
geronimo-sample-ear-created.PNG
Create EJB project
The next step is to create an EJB project to hold your EJBs. Press Ctrl-N
and select EJB Project
in EJB
category.
geronimo-sample-ejb.PNG
Press Next
.
In the EJB Project wizard type in SampleEJB as the project name and select Add project to an EAR checkbox. Leave the rest as is.
geronimo-sample-ejb-details.PNG
Press Next
.
Make sure that 5.0
for the Java
facet in the Project Facets
popup window's selected.
geronimo-sample-ejb-details-project-facets.PNG
Press Next
.
Unselect the Create an EJB Client JAR module to hold the client interfaces and classes
checkbox.
geronimo-sample-ejb-details-clientintfs.PNG
Press Next
.
Fill in the Geronimo Deployment Plan fields with the following values (want more why they're important? Read it on in the Geronimo documentation - http://cwiki.apache.org/GMOxDOC12/deployment-plans.html):
- Group Id: sampleear
- Artifact Id: sample-ejb
geronimo-sample-ejb-plan.PNG
Press Finish
.
You should now have the following project structure.
geronimo-sample-ejb-created.PNG
Note |
---|
Remove META-INF/openejb-jar.xml file as it leads to deployment issues. |
...
The next step is to create a Dynamic Web project to hold your web application. Press Ctrl-N
and select Dynamic Web Project
in Web
category.
geronimo-sample-war.PNG
Press Next
.
In the Dynamic Web Project wizard type in SampleWAR as the project name and select Add project to an EAR checkbox. Leave the rest as is.
geronimo-sample-war-details.PNG
Press Next
.
Make sure that 5.0
for the Java
facet in the Project Facets
popup window's selected.
geronimo-sample-war-details-project-facets.PNG
Press Next
twice.
...
- Group Id: sampleear
- Artifact Id: sample-war
geronimo-sample-war-plan.PNG
Press Finish
.
You should now have the following project structure.
geronimo-sample-war-created.PNG
Create Stateless Session EJB
...
Right-click on the SampleEJB
project and select New > Interface
and fill it in as follows:
geronimo-sample-ejb-RemoteBusinessInterface.PNG
Press Finish
.
Add a business method and mark the interface as a remote one.
...
Right-click on the SampleEJB
project and select New > Class
and fill it in as follows. Don't forget to add the interface RemoteBusinessInterface
.
geronimo-sample-ejb-MyStatelessSessionBean.PNG
Press Finish
.
Implement the business method sayHello
and mark the class as a stateless session bean.
...
Right-click on the SampleWAR
project and select Properties
. Go to J2EE Module Dependencies
and select the checkbox next to SampleEJB.jar
in the J2EE Modules
tab.
geronimo-sample-war-dependency.PNG
Press OK
.
Right-click on the SampleWAR
project and select New > Servlet
and fill it in as follows.
geronimo-sample-war-MyServlet.PNG
Press Next
.
Change the URL Mapping section so the servlet serves at /sayHello url mapping.
geronimo-sample-war-url-mapping.PNG
Press Finish
.
Change it to call off the ejb when executed.
...
Right-click on the SampleEAR
project and select Run As > Run on Server
. When Run On Server popup window comes up, select the Always use this server when running this project checkbox.
geronimo-sample-ear-definenewserver.PNG
Press Finish
.
The server's stopped so nothing happens (from a user's perspective at least). Open up the Servers tab and right-click on Apache Geronimo v2.0 Server at localhost and select Start
.
geronimo-sample-ear-geronimostart.PNG
After a few seconds, Geronimo should be up and running with the enterprise application published. Open up the browser of your choice and go to http://localhost:8080/SampleWAR.
...