Geronimo deployment plan for an EJB JAR is an XML document which is called "openejb-jar.xml".This document is defined by the openejb-jar-2.0.xsd schema,which can be found in the schema/subdirectory of the main Geronimo installation directory.The deployment plan for an EJB JAR may be included in the EJB JAR, in which case it should be named META-INF/openejb-jar.xml or included in an EAR (but outside of the EJB JAR) and referenced by an alt-dd element of the EAR deployment plan
Typically there are serveral steps to be taken to deploy EJBs in Geronimo
First it needs to create the EJB classes and interfaces
Create the standard ejb-jar.xml deployment descriptor
Create a Geronimo-specific openejb-jar.xml deployment plan
Package the EJBs and deployment descriptors into an EJB JAR, or a directory tree laid out like an EJB JAR
Use the deployment tool described in deployment plan "The Deploy Tool" to deploy the EJB JAR (or an EAR containing the EJB JAR) into the server or else the use can use the geronimo web console for it
This article is organized into the following sections : -
Deploying JAR containing Simple EJB application
This section will cover Geronimo v1.1 deployment plan for the simple helloworld ejb.
Here is the folder structure for the above simple application.Sample Application is available to download here
HelloWorld ejb Sample
HelloWorld |_ejbModule | |_org.geronimo.ejbsample | | |_HelloBean | | |_HelloHome | | |_HelloObject | | | |_org.geronimo.ejbsample.client | |_HelloWorld |_META-INF | |_ejb-jar.xml | |_openejb-jar.xml | |_dist |_build |_build.xml
Here is the ejb-jar.xml for the above sample
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd"> <ejb-jar> <enterprise-beans> <session> <ejb-name>HelloBean</ejb-name> <home>org.geronimo.ejbsample.HelloHome</home> <remote>org.geronimo.ejbsample.HelloObject</remote> <ejb-class>org.geronimo.ejbsample.HelloBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> </session> </enterprise-beans> <assembly-descriptor> <container-transaction> <method> <ejb-name>HelloBean</ejb-name> <method-name>*</method-name> </method> <trans-attribute>Required</trans-attribute> </container-transaction> </assembly-descriptor> </ejb-jar>
Geronimo v1.1 deployment plan for the above sample
<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1"> <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1"> <dep:moduleId> <dep:groupId>org.geronimo.</dep:groupId> <dep:artifactId>ejbsample</dep:artifactId> <dep:version>1.0</dep:version> <dep:type>car</dep:type> </dep:moduleId> <dep:dependencies/> <dep:hidden-classes/> <dep:non-overridable-classes/> </dep:environment> <enterprise-beans> <session> <ejb-name>HelloBean</ejb-name> <jndi-name>org.geronimo.ejbsample.HomeBean</jndi-name> </session> </enterprise-beans> </openejb-jar>
Steps to deploying the sample
There are two ways in which the sample can be deployed :-
1. The sample can be built from scratch using the build.xml and editing the geronimo_home as your directory. Obtain the helloworld-ejbs.jar from the dist directory and use the Geronimo web console. Browse for the helloworld-ejbs.jar file and click on the Install button.
2.Use the following command line code to deploy the application.
Running the Client to test the HelloWorld EJB service
org.geronimo.ejbsample.client.HelloWorld.java is the client code for the above application.Set the necessary class path to run client in your environment.
< <app-home>/org/geronimo/ejbsampleclient> >java HelloWorld
You will see the "Hello world" print on your command line
HelloWorld/org/geronimo/ejbsampleclient>
Hello World!
*Image needed to be upload.