EJB Grid Services

Globus Toolkit 3.0 - Last Updated 10/24/2003

Installation and Versioning Notes

Note this code is still of experimental nature and therefore the required build files and samples are only available in the source distribution of GT3 Core. We have tested all the samples with JBOSS 3.2.1 default server and WebSphere Adanced Single Server Edition v4.0. WebSphere requires an additional step to set up a database manually for the entity bean sample, and those scripts have only been tested on Windows. Both in JBOSS as well as in Websphere you can however customize the database to use as source for the sample yourself, please consult the respective product documentation for more information. We generate a gateway that is hosted by a Grid service container which then delegates to your EJB container of choice. The EJB gateway can run under Tomcat or our standalone container. We have tested the gateway with Tomcat 4.0.6.

Overall Design

The general design rational behind this functionality is to assume that you have an existing EJB application that you want to expose as a set of Grid services without having to change your application. Both Session and Entity EJBs can be exposed as grid services, we only require you to feed the tools with the EJB Home and Remote interfaces, in order to generate the required gateway. The Grid service is in itself stateless but will retrive all its application sate from the Bean. This means that you can recreate the Grid service instance after for example a server crash, and it will be mapped to the existing Bean state if you use the same primary key (which is mapped off to the GSH). 

For the tool to work you need to point it to a directory where you have extracted the contents of your EJB, and then point the tool to the Remote and Home interfaces through configuration before running the code generator. Below we show how this is done for JBOSS and WebShpere respectively for the provided samples. 

Common EJB Configuration

Open the ejb.properties file in your ogsa java build root directoy (ogsa/impl/java) and uncomment and/or change the following entries to match your environment:

ejb.dir - the absolute directory of where the contents of your EJB has been extracted
ejb.home - the class that contains the home interface
ejb.remote - the class that contains the remote interface
ejb.exposeHomeService - allows you to use the EJB Home interface to create services if true. If false you will need to use the standard OGSI interfaces (factory) to create your service.
tomcat.dir - the root of your tomcat installation

Configuration to Run EJBs in JBOSS

Open the ejb.properties file in your ogsa java build root directoy (ogsa/impl/java) and uncomment and/or change the following entries to match your environment:

containerType - should be "jboss"
jboss.deployedJar - the jar that is to be deployed in jboss
jboss.dir - should point to the root of your jboss installation

Configuration to Run EJBs in WebSphere

Open the ejb.properties file in your ogsa java build root directoy (ogsa/impl/java) and uncomment and/or change the following entries to match your environment:

containerType - should be "websphere"
websphere.deployedJar - a jar that was constructed by the WebSphere assembly tool to deploy the beans. Note this jar is only used to get client side stubs, it is not deployed in Websphere by our tools, they assume that this jar is already deployed as an application in the WebSphere server
websphere.dir - should point to the root of your websphere app server installation - typically /Websphere/AppServer
webspere.ejb.db - as noted above for websphere you need to set up the database as a separate step, on windows we automate this process for you if you point this property to an Enhydra instantDB script (the database comes with the WebSphere installation)
websphere.create.db.command - we have customized the samples create db script in Websphere for windows. To pick up our customization point this property to createDB.bat

Generating the Gateway

After configuring your environment of choice and setting up the mapping to the bean you want to expose as described above you only have to run:

ant ejbService
If that succeeds you are ready to start up your appserver and tomcat/or the standalone container. To start up the standalone container to host the EJB gateways run:
ant startEJBContainer -Dservice.port=<port>

The port defaults to 8080, which will clash with the default JBOSS port, so please pick another port if you are running JBOSS.

Running the Samples

Before deploying the samples make sure to compile the EJB classes first. To compile the EJB classes do:
ant -f build-ejb.xml samples
Lower Case Conversion Session Bean
After having deployed this service following the steps described above you can test it as follows:
  1. Make sure your EJB container is running as well as the standalone container or Tomcat
  2. Make sure your environment is set properly using setenv scripts
  3. Run java org.globus.ogsa.client.CreateService http://<gateway host>:<gateway port>/ogsa/services/org/someone/LowerCaseFactoryService
  4. Run java org.someone.LowClient <the handle returned by CreateService> myTestString
Person CMP Entity Bean
Make sure you have enabled the ejb.exposeHomeService property, then:
  1. Make sure your EJB container is running as well as the standalone container or Tomcat
  2. Make sure your environment is set properly using setenv scripts
  3. Run java org.good.PersonHomeClient http://<gateway host>:<gateway port>/ogsa/services/org/good/PersonHomeFactoryService myService
  4. Run java org.good.PersonClient http://<gateway host>:<gateway port>/ogsa/services/org/good/PersonHomeFactoryService/myService set myName
  5. Run java org.good.PersonClient http://<gateway host>:<gateway port>/ogsa/services/org/good/PersonHomeFactoryService/myService 

Notes on Exposing the Home Interface

You can expose the home interface as a factory service or you can rely on default create and find methods and only expose the remote interface.

If you don't expose the home interface then:

If you choose to expose a home service then all of the methods on your home interface that return a single instance of the remote interface will become a factory service. Generally this means all of the create() and find() methods that don't return an enumeration of remotes.

You can use it like an ordinary ejb:

    String serviceUrl = "http://127.0.0.1:8080/ogsa/services/org/yourpackage/PersonHomeFactoryService/myHome";
    PersonHome home = (PersonHome) EJBServiceClient.createHomeService("org.yourpackage.PersonHome", "org.yourpackage.Person", serviceUrl);
    Person remote = home.create(new Integer(123));
    
    or Person someOtherRemote = home.findBySomeMethod(blah, blah); or whatever you want
see org.globus.ogsa.client.EJBServiceClient for more information

Troubleshooting

If you have JNDI problems, or if tomcat can't find the home interface then look at the parameters in server-config.wsdd.

If you need to change the wsdl it generated you can run "ant -buildfile build-ejb.xml ejbToTomcat" to redeploy the ejb after changing the wsdl

If you have other problems try "ant ejbClean" and then "ant ejbService" again.