...
Step-by-step migration
Anchor | ||||
---|---|---|---|---|
|
The same EJB jar file that was created and deployed in jboss may be deployed in Geronimo with no changes to its contents but you still need to edit the jndi properties of sample application. Edit the jndi.properties file located in in the <cmp_home>/jndi directory as shown in the following example:
No Format | ||||
---|---|---|---|---|
| ||||
####################################################################
### JBoss Settings
####################################################################
#java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
#java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
#java.naming.provider.url=localhost
####################################################################
### Geronimo Settings
####################################################################
java.naming.factory.initial=org.openejb.client.RemoteInitialContextFactory
java.naming.provider.url=localhost:4201
java.naming.security.principal=username
java.naming.security.credentials=passwd |
The following example shows the customer-ejb.xml deployment plan used for deploying the EJB application, this deployment plan in located in the <cmp_home>/dd directory.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version="1.0" encoding="UTF-8"?>
<openejb-jar
xmlns="http://www.openejb.org/xml/ns/openejb-jar"
xmlns:naming="http://geronimo.apache.org/xml/ns/naming"
xmlns:security="http://geronimo.apache.org/xml/ns/security"
xmlns:sys="http://geronimo.apache.org/xml/ns/deployment"
configId="CustomerEJB"
parentId="org/apache/geronimo/SystemDatabase">
<enterprise-beans>
<entity>
<ejb-name>CustomerEJB</ejb-name>
<jndi-name>CustomerHomeRemote</jndi-name>
<local-jndi-name>CustomerRemote</local-jndi-name>
<resource-ref>
<ref-name>jdbc/ibm-demo</ref-name>
<resource-link>SystemDatasource</resource-link>
</resource-ref>
</entity>
</enterprise-beans>
</openejb-jar> |
This plan sets org/apache/geronimo/SystemDatabase as the parent. What follows is the definition of the entity bean. The jndi-name element indicates the jndi name of the entity bean's home interface CustomerHomeRemote. This is the name that the Loan CMP sample application will lookup in the jndi context. The element local-jndi-name indicates the jndi name of the local interface, which in this case happens to be a remote interface, CustomerRemote. Next, a reference to the SystemDatasource is defined giving the application access to the database.
The Web Application client can be direclty deployed in Geronimo. This is because the build step packages both the JBoss jboss-web.xml and Geronimo geronimo-web.xml specific deployment plans in the war file. You can see both of these files in the <cmp_home>\src\webapp\WEB-INF directory.
The geronimo-web.xml deployment plan should look like the following example.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<web-app xmlns="http://geronimo.apache.org/xml/ns/web"
xmlns:naming="http://geronimo.apache.org/xml/ns/naming"
configId="EntityDemoWebApp"
parentId="CustomerEJB">
<context-root>entity-ejb</context-root>
<ejb-ref>
<ref-name>ejb/CustomerHome</ref-name>
<target-name>geronimo.server:EJBModule=CustomerEJB,J2EEApplication=null,J2EEServer=geronimo,j2eeType=EntityBean,name=CustomerEJB</target-name>
</ejb-ref>
</web-app> |
Build the Loan BMP application by typing maven from the <bmp_home> directory. This will create the entity-ejb-SNAPSHOT.jar and entity-ejb.war in the <bmp_home>/target directory.
Deploy the migrated application
To deploy the migrated Loan BMP application, make sure the Geronimo server is up and running.
From a command line, change directory to <geronimo_home> and type the following command:
java -jar bin/deployer.jar --user system --password manager deploy <bmp_home>/target/entity-ejb-SNAPSHOT.jar <bmp_home>/dd/customer-ejb.xml
With this command you first tell the deployer tool where is the module to deploy, then you tell the deployer tool how to deploy the application by specifying the deployment plan.
Deploy the Web Application by typing the following command:
java -jar bin/deployer.jar --user system --password manager deploy <bmp_home>/target/entity-ejb.war
From the command line change the the <bmp_home> directory and type the following command:
maven run:client
You should see something similar to the following example:
No Format bgColor #000000 borderStyle solid
E:\loan-bmp>maven run:client
__ __
| \/ |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \ ~ intelligent projects ~
|_| |_\__,_|\_/\___|_||_| v. 1.0.2
build:start:
run:client:
[java] creating customer...
[java] done.findByPrimaryKeyTest... 1
[java] customer name: Customer 1
[java] customer sss no: 2323232
[java] customer loan amount: 0.0
[java] customer annual salary: 0.0
[java] customer birthdate: Thu Oct 27 00:00:00 EDT 2005
[java] updating ejb...
[java] done.findBySssNoTest... 2323232
[java] customer name: Customer 2
[java] customer sss no: 2323232
[java] customer loan amount: 0.0
[java] customer annual salary: 0.0
[java] customer birthdate: Thu Oct 27 00:00:00 EDT 2005
BUILD SUCCESSFUL
Total time: 4 seconds
Finished at: Thu Oct 27 18:59:44 EDT 2005
E:\loan-bmp>
Test the applications the same way you tested on JBoss.
Summary
Anchor | ||||
---|---|---|---|---|
|
...