Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Pictures in

...

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.PNGImage Added

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.PNGImage Added

Press Next twice.

...

  • Group Id: sampleear
  • Artifact Id: sample-ear

geronimo-sample-ear-plan.PNGImage Added

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.PNGImage Added

You should now have the following project structure.

geronimo-sample-ear-created.PNGImage Added

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.PNGImage Added

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.PNGImage Added

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.PNGImage Added

Press Next.

Unselect the Create an EJB Client JAR module to hold the client interfaces and classes checkbox.

geronimo-sample-ejb-details-clientintfs.PNGImage Added

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.PNGImage Added

Press Finish.

You should now have the following project structure.

geronimo-sample-ejb-created.PNGImage Added

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.PNGImage Added

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.PNGImage Added

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.PNGImage Added

Press Next twice.

...

  • Group Id: sampleear
  • Artifact Id: sample-war

geronimo-sample-war-plan.PNGImage Added

Press Finish.

You should now have the following project structure.

geronimo-sample-war-created.PNGImage Added

Create Stateless Session EJB

...

Right-click on the SampleEJB project and select New > Interface and fill it in as follows:

geronimo-sample-ejb-RemoteBusinessInterface.PNGImage Added

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.PNGImage Added

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.PNGImage Added

Press OK.

Right-click on the SampleWAR project and select New > Servlet and fill it in as follows.

geronimo-sample-war-MyServlet.PNGImage Added

Press Next.

Change the URL Mapping section so the servlet serves at /sayHello url mapping.

geronimo-sample-war-url-mapping.PNGImage Added

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.PNGImage Added

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.PNGImage Added

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.

...