Versions Compared

Key

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

So you've got 5 minutes and want to see how much you can do with Eclipse and Geronimo v2, huh? If so, you won't find much here, then unless you have already installed 2, don't you? Install Eclipse and Geronimo Eclipse plugin as described at Geronimo Eclipse Plugin Installation Instructions. It makes a huge difference. and 5 minutes seem quite enough. Let's check it out!

...

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.

Press Next twice.

In the New EAR Application Project window select the Generate Deployment Descriptor checkbox.

Image Added

Press Next three times.

Fill in the Geronimo Deployment Plan's fields with the following values (you want to know more why they're important? Read it on in the Geronimo documentation - http://cwiki.apache.org/GMOxDOC12/deployment-plans.html1.2 Documentation - Deployment plans):

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

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.

...

You should now have the following project structure.

Note

Don't worry about the error cvc-complex-type.2.4.b: The content of element 'application' is not complete... for now. You'll fix it in the next step when you define an ejb module (and webapp module afterwards).

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.

...

  • Group Id: sampleear
  • Artifact Id: sample-ejb
  • Artifact Type: ejb

Press Finish.

You should now have the following project structure.

Note

Remove ejbModule/META-INF/openejb-jar.xml file in the SampleEJB project as it leads to causes deployment issues.

Create Dynamic Web Project

...

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

Press Finish.

You should now have the following project structure.

...

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 introductionTutorial toon enterpriseEnterprise applicationApplication developmentDevelopment 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>

...

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));
    }
}

Create application.xml

Note

It appears that the file is not created by default and the application could not be deployed to any Java EE 5-compliant application server, Geronimo including. We need to define it manually. Don't know whether it's a bug in Eclipse or Geronimo Eclipse Plugin.

Create application.xml deployment descriptor in EarContent/META-INF directory of the SampleEAR project as follows.

Code Block
xmlxml
borderStylesolid
titleapplication.xml
<?xml version="1.0" encoding="ASCII"?>
<application xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd"
  version="5">
  <display-name>SampleEAR</display-name>
  <module>
    <ejb>SampleEJB.jar</ejb>
  </module>
  <module>
    <web>
      <web-uri>SampleWAR.war</web-uri>
      <context-root>/SampleWAR</context-root>
    </web>
  </module>
</application>

Run it!

After a very hard 4-minute development it's time to give it a shot and see if it works. Not much time left so hurry up!

...

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/SampleWARImage Removed.

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

...