Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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.

  1. Sun JDK 6.0+ (J2SE 1.6)
  2. Eclipse

...

  1. IDE for Java EE Developers, which is platform specific
  2. Apache Geronimo Eclipse Plugin 2.1.x
  3. Apache Geronimo Server

...

  1. 2.1.x

...

  1. Note

    Geronimo version 2.1.x, Java 1.5 runtime, and Eclipse Ganymede are used is used in this tutorial but other versions can be used instead (e.g., Geronimo version 2.2

...

  1. , Java 1.6, Eclipse Europa)

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.

  1. Select File --> New, select Project... and in the popup window select select Enterprise Application Project.

  2. In the EAR Application Project wizard type in SampleEAR as the Project name: and select Apache Geronimo v2.1 in Target Runtime. Leave the rest as it is.



  3. Click Next.

  4. In the J2EE Modules to Add to the EAR window select the Generate Deployment Descriptor checkbox and click Next.



  5. In the Geronimo Deployment Plan window enter the values as specified below. To find out more about what these values mean check the Deployment plans section.
    Section
    • Group Id: sampleear
    • Artifact Id: sample-ear
    • Version: 1.0
    • Artifact Type: ear


  6. Click Finish.

    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.


...

The next step is to create an EJB project to hold your EJBs.

  1. Select File --> New, select EJB Project.

  2. 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 and click Next.



  3. Unselect the Create an EJB Client JAR module to hold the client interfaces and classes checkbox. We're not interested in it. Click Next.



  4. Fill in the Geronimo Deployment Plan fields with the following values:
    Section
    • Group Id: sampleear
    • Artifact Id: sample-ejb
    • Artifact Type: ejb


  5. Click Finish.

You should now have the following project structure.


...

Now that you have EAR and EJB projects created the next step is to create a Dynamic Web project to hold your web application.

  1. Select File --> New, select Dynamic Web Project.

  2. 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 and click Next twice.



  3. Fill in the Geronimo Deployment Plan fields with the following values:
    Section
    • Group Id: sampleear
    • Artifact Id: sample-war
    • Artifact Type: war


  4. Click Finish.

...

  1. Right-click on the SampleEJB project and select New --> Interface and fill it in with the following values:
    Section
    • Package: sampleear
    • Name: RemoteBusinessInterface


  2. Click Finish.

...

  1. Right-click on the SampleEJB project and select New --> Class and fill it in with the following values:
    Section
    • Package: sampleear
    • Name: MyStatelessSessionBean
    • Interfaces: sampleear.RemoteBusinessInterface


  2. Click Finish.

...

  1. Right-click on the SampleWAR project and select New --> JSP. Name it index.jsp and click Finish.

  2. Change it so it executes the servlet upon form submission.
    Section
    Code Block
    html
    html
    borderStylesolid
    titleindex.jsp
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>5-minute Tutorial on Enterprise Application Development with Eclipse and Geronimo</title>
      </head>
      <body>
        <form action="${pageContext.request.contextPath}/sayHello">
          <input type="text" name="name" /><input type="submit" value="Press me!" />
        </form>
      </body>
    </html>
    

...

  1. Right-click on the SampleWAR project and select Properties. Go to J2EE Module Dependencies and select the checkbox next to SampleEJB.jar (it's in the J2EE Modules tab) and click OK.



  2. Right-click on the SampleWAR project and select New --> Servlet and fill it in with the following values:
    Section
    • Java Package: sampleear
    • Class name: MyServlet


  3. Click Next.

  4. Change the URL Mapping section so the servlet serves at /sayHello url mapping and click Finish.


...

  1. 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. Leave the rest as is.



  2. Click Finish.

  3. 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.1 Server at localhost and select Start.

  4. After a few seconds, Geronimo will be up and running with the enterprise application published. Open up the browser of your choice and go to http://localhost:8080/SampleWAR.



  5. Type in any name you want, e.g. John Doe and press Press me! button.