Geronimo_MoinMoin_wiki > PetStore
Added by Confluence Administrator, last edited by Confluence Administrator on Aug 02, 2006

Contents


Deploying Java Pet Store Demo 1.4

This section of the page is about deploying Java Pet Store Sample Application 1.4 onto Apache Geronimo. The application is part of J2EE 1.4 SDK Samples 2005Q2 UR2 in the samples\blueprints\petstore1.4 directory.

The home directory of the Geronimo-specific configuration files of Pet Store Demo application in Geronimo source tree is sandbox/petstore.

Prerequisites

Deployment

The deployment steps are as follows:

  1. Go to sandbox/petstore directory
  2. Copy samples/blueprints/petstore1.4 to the current directory
  3. Patch the resulting directory with the patch src/etc/petstore1.4.diff
    • $ patch -p0 < src/etc/petstore1.4.diff
      
  1. Build the Pet Store Demo
    • ant -Dpetstore.module.home=c:/projs/geronimo/sandbox/petstore -Dmaven.repo.dir=~/.maven -f petstore1.4/src/build.xml
      
  1. Distribute the Java Pet Store Demo application maven -o

Once installed, the Pet Store Demo application is started and stopped with maven -o petstore:start and maven -o petstore:stop, respectively.

To access the Java Pet Store application, point your browser to http://localhost:8080/petstore/. You can also use the admin and supplier enterprise applications at http://localhost:8080/admin and http://localhost:8080/supplier, respectively.

TODO:

  • Explanations on the Geronimo specific configurations.
  • Improve the PetStore build procedure - the properties should not be necessary

NOTE:

  • There're a lot of steps to be done that require creating files manually. Most, if not all, files will be created by a JSR-88-compliant tool during the deployment process;
  • maven -u can be used to display the available commands
...
[petstore]                          ( NO DEFAULT GOAL )
  deploy  ......................... Deploys PetStore
  start  .......................... Starts PetStore
  stop  ........................... Stops PetStore
...

Deploying Java Pet Store Demo 1.3.2

  • The demo application has several issues with JSP EL and without much changes it seemed to be impossible to run it successfully. It can be deployed, though, but some pages aren't displayed properly. Fortunatelly, Java Pet Store Demo 1.4 is available and doesn't contain such errors.
    

This section of the page is about deploying Java Pet Store Sample Application 1.3.2 onto Apache Geronimo.

The Java Pet Store Demo is a sample application brought to you by the Java BluePrints program at Java Software, Sun Microsystems.

The home directory of the Geronimo-specific configuration files of Pet Store Demo application in Geronimo source tree is sandbox/petstore.

Prerequisites

Deploying Pet Store Demo

Before going on, please keep in mind that "whom ever wrote petstore should be hunted down...". It's been said during one IRC session and I couldn't resist to include it.

The installation steps are:

  1. Go to sandbox/petstore directory
  2. Unzip petstore-1_3_2.zip
  3. Patch the resulting directory with the patch src/etc/petstore1.3.2.diff
    • $ patch -p0 < src/etc/petstore1.3.2.diff
      patching file petstore1.3.2/src/apps/petstore/src/docroot/CatalogDAOSQL.xml
      patching file petstore1.3.2/src/apps/petstore/src/docroot/WEB-INF/web.xml
      patching file petstore1.3.2/src/apps/petstore/src/docroot/populate/PopulateSQL.xml
      patching file petstore1.3.2/src/components/catalog/src/ejb-jar.xml
      patching file petstore1.3.2/src/components/customer/src/ejb-jar.xml
      
  1. Build the Pet Store Demo. It boils down to executing build.sh or build.bat in petstore1.3.2/src directory, possibly with some additional modifications in the build.properties file. See petstore1.3.2/docs/building.html for a complete information.
  2. Distribute the Java Pet Store Demo application maven -o.

Once installed, the Pet Store Demo application is started and stopped with maven -o petstore:start and maven -o petstore:stop, respectively.

To access the Java Pet Store application, point your browser to http://localhost:8080/petstore/.

TODO:

  • Explanations on the Geronimo specific configurations.

NOTE:

  • There're a lot of steps to be done that require creating files manually. Most, if not all, files will be created by a JSR-88-compliant tool during the deployment process;
  • maven -u can be used to display the available commands
...
[petstore]                          ( NO DEFAULT GOAL )
  deploy  ......................... Deploys PetStore
  start  .......................... Starts PetStore
  stop  ........................... Stops PetStore
...

Deploying Java Pet Store Sample Application 1.1.2

This section is based on Rajesh Ravindran's post to user@geronimo.apache.org on 2004-09-24:

First of all I would like to state that I did not work on the latest version of petstore i.e. 1.3.2 . I used the petstore that comes with Weblogic 6.1. (which i believe is 1.1.2) I got that working on geronimo. In doing this I got a lot of help from Gianny & a lot of guys on the mailing lists & friends who worked with me on this: Sai,Prem & Vandana. I hope this would be of some help. Please respond with any queries and feedbacks. This is not a detailed list of changes, but just an overview. So you can push me for details.

I had to make the following changes to get petstore running.

Had to provide the ejb-link ...

... at all places wherever extenal ejb's were being referenced. It seems it doesnt work at least in geronimo-web.xml if we just give the ejb-ref & give the target-name. Faced problems there.

For instance, in the web.xml

  • <ejb-ref>
        <ejb-ref-name>ejb/catalog/Catalog</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <home>com.sun.j2ee.blueprints.shoppingcart.catalog.ejb.CatalogHome</home>
        <remote>com.sun.j2ee.blueprints.shoppingcart.catalog.ejb.Catalog</remote>
    <!---------------------------------------------------------------->
        <ejb-link>TheCatalog</ejb-link>
    
        <!--This had to be added as geronimo requires the links to be available-->
    <!----------------------------------------------------------------->
    </ejb-ref>
    

NOTE

[David Blevins in a post to user@geronimo.apache.org on 2004-10-27]: (...) we shouldn't need the ejb-link section anymore as Geronimo will try and match the home and remote interfaces up with an ejb defined in the jar. This works fine unless there are two or more ejbs sharing the same interfaces.

You need to get ride of the Japanish screen definitions ...

... defined by the Pet Store Web application. More accurately, drop the element

  • <screen-definition url="/WEB-INF/xml/ja/screendefinitions.xml"
    language="ja_JP"/>
    

defined by petstore.war!/WEB-INF\xml\requestmappings.xml.

Two setters & getters in the petstore code ...

... were giving me errors.

These were the setNumItems & setStartIndex. This was due to the fact that the setter accepted String & the getter was returning an int. Had to change the setter to accept int.

  •  public void setNumItems(String numItemsStr) {
        numItems = Integer.parseInt(numItemsStr);
      }
    
      public void setStartIndex(String startIndexStr) {
        startIndex = Integer.parseInt(startIndexStr);
      }
    

had to be changed to

  •   public void setNumItems(int numItems) {
        this.numItems = numItems;
      }
    
      public void setStartIndex(int startIndex) {
        this.startIndex = startIndex;
      }
    

This has to be done in the following files:

Had to use an adapter (tranql generic adapter) ...

... & had to write the corresponding geronimo-web.xml to use the oracle database (or cloudscape if you are using that) from where to access the inventory and other databases used by petstore. The adapter jar had to be packed along with the ra.xml, geronimo-ra.xml & the required drivers.

Pack it up in a *.rar archive.

To get the petstoreAdmin.ear working:

Had to create the petstore realm (this was for getting the petstoreAdmin working)

the following user & group properties files had to be created

  • # groups.properties
    gold=
    cust=j2ee
    admin=jps_admin
    
# users.properties
j2ee=j2ee
jps_admin=admin

A petstore-plan.xml to be created for security

The petstore security plan had to be added to maven.xml, & then build it.

In web.xml changed the realm from default to petstore-realm

  • <login-config>
        <auth-method>FORM</auth-method>
        <realm-name>petstore-realm</realm-name> <!--changed from default
    to petstore-realm-->
        <form-login-config>
          <form-login-page>/login.jsp</form-login-page>
          <form-error-page>/error.jsp</form-error-page>
        </form-login-config>
    </login-config>
    

In the ejb-jar.xml had to make the following change:

  • <env-entry>
          <env-entry-name>user/AdminId</env-entry-name>
          <env-entry-type>java.lang.String</env-entry-type>     
    <env-entry-value>petstore-realm:[org.apache.geronimo.security.realm.providers.PropertiesFileGroupPrincipal:admin]</env-entry-value>
          <!-changed the value from jsp_admin to the whole nested name of
    the principal-->