Versions Compared

Key

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

...

  1. Right click under project explorer and select New->Enterprise Application Project.





  2. Name the project as StatefulApp and select Next.





  3. Keep the default values and select Next.





  4. On the next screen check StatefulBean and StatefulClient and check Generate Deployment Descriptor. Select Next.





  5. Keep the default values and Select Finish.





Modifying openejb-jar.xml and web.xml

  1. In StatefulBean project select META-INF/openejb-jar.xml and replace the existing code with following code
    {code:title=openejb-jar.xml|borderStyle=solid)
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.2" xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.2"
    xmlns:pkgen="http://www.openejb.org/xml/ns/pkgen-2.0"
    xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.2" xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2">
    <environment>
    <moduleId>
    <groupId>default</groupId>
    <artifactId>StatefulBean</artifactId>
    <version>1.0</version>
    <type>car</type>
    </moduleId>
    <sys:dependencies>
    <sys:dependency>
    <sys:groupId>console.dbpool</sys:groupId>
    <sys:artifactId>jdbc%2Fuserds</sys:artifactId>
    </sys:dependency>
    </sys:dependencies>
    </environment>
    </openejb-jar>
    Code Block
    
    The above deployment plan is different from the above one in the following way
    #* The namespace generated by geronimo eclipse plugin are not to AG 2.1 level. This is due to some limitation which will be fixed soon.
    #* Since the ejb bean class refers to jdbc/userds datasource a *<dependency>* element has to be added in EJB deployment plan.
    # In *StatefulClient* project select WEB-INF/web.xml and replace the existing code with the following 
    {code:title=web.xml|borderStyle=solid}
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
      <display-name>StatefulClient</display-name>
      <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
      </welcome-file-list>
      <servlet>
        <description></description>
        <display-name>Controller</display-name>
        <servlet-name>Controller</servlet-name>
        <servlet-class>ejb.stateful.Controller</servlet-class>
      </servlet>
      <servlet>
        <description></description>
        <display-name>Controller1</display-name>
        <servlet-name>Controller1</servlet-name>
        <servlet-class>ejb.stateful.Controller</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>Controller</servlet-name>
        <url-pattern>/Controller</url-pattern>
      </servlet-mapping>
      <servlet-mapping>
        <servlet-name>Controller1</servlet-name>
        <url-pattern>/Controller1</url-pattern>
      </servlet-mapping>
    </web-app>
    
    The above code is different from the original one in the sense that we have added another <servlet> for Controller1 which is mapped to the same servlet class. Similarly adding a <servlet-mapping> element for the Controller1 servlet. This feature is basically mapping of more than one servlet with same servlet class. This helps in routing each call from jsp in the Controller servlet.