Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

  1. Select File -> New, select Project... and in the popup window select select Enterprise Application Project in J2EE category and click Next. Image Removed
  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.
    Image Removed
    Image Added

  3. Click Next twice.
  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.

...

You should now have the following project structure.
Image Removed
Image Added

Note
titleError 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).

...

  1. Press Ctrl-N, select EJB Project in EJB category and click Next.
  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.
    Image Removed
    Image Added

  3. Make sure that 5.0 for the Java facet in the Project Facets popup window's selected and click Next.



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



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



  6. Click Finish.

You should now have the following project structure.
Image Removed
Image Added

Note
titleImportant

Remove When workng on versions pervious to Geronimo 2.1.7, 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. However, when using Geronimo 2.1.7, you must include this ejbModule/META-INF/openejb-jar.xml file or else you will encounter NullPointerException error due to a bug issue.

Create Dynamic Web Project

...

  1. Press Ctrl-N, select Dynamic Web Project in Web category and click Next.
  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.
    Image Removed
    Image Added

  3. Make sure that 5.0 for the Java facet in the Project Facets popup window's selected and click Next twice.



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



  5. Click Finish.

You should now have the following project structure.
Image Removed
Image Added

Create Stateless Session EJB

...

  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.
    Image Removed
    Image Added

  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.


...

Code Block
java
java
borderStylesolid
titleMyServlet.java
package sampleear;

import java.io.IOException;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
    static final long serialVersionUID = 1L;

    @EJB
    RemoteBusinessInterface remoteBusinessIntf;

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String name = request.getParameter("name");
        if (name == null || name.length() == 0) {
            name = "anonymous";
        }
        response.getWriter().write(remoteBusinessIntf.sayHello(name));
    }
}

Run it!

After a very hard 4-minute development All it's time to give it a shot and see if it works. Not much time left so hurry up!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.

  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.

...


  1. Image Added

...


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

Image Removed

  1. After a few seconds, Geronimo

...

  1. will be up and running with the enterprise application published. Open up the browser of your choice and go to http://localhost:8080/SampleWAR

...

  1. .

...


  1. Image Added

  2. Type in any name you want, e.g.

...

  1. John Doe and press Press me! button.

Image Removed

...


  1. Image Added