Home > Documentation > Sample applications > How to get JNDI working in Geronimo 2.0 |
Javaâ„¢ Naming and Directory Interface (JNDI) is an interface to connection pools in the Apache Geronimo application server. Through this interface, developers have access to all Java objects, including Enterprise Java Beans (EJBs).
The following article provides concept-rich documentation on how to use JNDI to access connection pools for data sources, Java Messaging Services (JMS), mail sessions, and URL connections: Apache Geronimo JNDI naming and Java resource connection pools, Part 1: Data source connections. URL: http://www-128.ibm.com/developerworks/opensource/library/os-ag-jndi1
It was a nice article, but was written for Geronimo 1.x, rather than Geronimo 2.0.
There were some additional configurations that were not mentioned, but are necesary in order to get the sample J2EE enterprise application up and running.
Note: The working environment for this information is Windows XP Professional, Version 5.1.2600 Service Pack 2 Build 2600.
The following steps will guide you to a successful deployment of the Customer Service J2EE enterprise application, which can be downloaded here: http://www.ibm.com/developerworks/views/download.jsp?contentid=175237&filename=CustomerService-part1.zip&method=http&locale=worldwide
1) Add j2ee.jar file to your classpath.
A j2ee.jar file, which can be found in the lib directory of an application server such as WebSphere or WebLogic, must be added to the classpath, or you will get the following error when attempting to run the ant build script:
2) Use the Geronimo/Tomcat distribution.
Use the Tomcat distribution because the Jetty (geronimo-jetty6-jee5-2.0-M1) distribution currently does not display any items in the "Database Types" dropdown list in the Geronimo Server Console | Services | Database Pools | Database Wizard.
3) Create the database pool (CustomerServicePool). Even the Tomcat distribution has problems creating a new database pool. For exampe, when you attempt to create a new database pool, select "Derby embedded" from the database type and then test the connection. That works, but no new database pool is created. The <GERONIMO_HOME>\var\log\geronimo.log file will have the following entry:
3.a) Manually create and deploy the deployment test plan file.
Geronimo is not creating the deployment plan for the "Derby embedded" connection pool. So, you must manually create a deployment plan and deploy it as follows:
Create a the following deployment plan file (CustomerServicePool_test_plan.xml)
Run the following at the command prompt in the <GERONIMO_HOME>\bin directory:
deploy --verbose --user system --password manager deploy D:\appsData\GERONIMO\JNDIApp\CustomerService.ear
3.b) Update deployment version for the CustomerServicePool.
Running the previous deploy command will expose another configuration opportunity:
Notice the following:
This highlights the fact that the files in the article are targeted for an earlier (1.0) deployment of the CustomerServicePool (a Derby embedded database pool).
3.c) Update dependency version number.
You can fix this by changing the "dep:version" tag in the dependencies section of the CustomerEJB-openejb.xml file from "1.0" to "2.0" as follows:
Re-run the following at the command prompt in the <GERONIMO_HOME>\bin directory:
deploy --verbose --user system --password manager deploy D:\appsData\GERONIMO\JNDIApp\CustomerService.ear
3.d) Update deployment descriptor.
Modify application.xml deployment descriptor file to be compatible with Geronimo 2.0 requirements.
After running the previous deploy command, yet another error can then be found in the geronimo.log file:
Remove the "description: and "display-name" tags from the application.xml file and save it back into the CustomerService.ear file.application.xml file:
This time, the CustomerService.ear file will successfully deploy.
deploy --verbose --user system --password manager deploy D:\appsData\GERONIMO\JNDIApp\CustomerService.ear
4) Deploy and test the application.
Using the following steps, we can successfully deploy the J2EE enterprise application in a running Geronimo 2.0 instance:
1) Add j2ee.jar file to your classpath.
2) Use the Geronimo/Tomcat distribution.
3) Create the database pool (CustomerServicePool).
a. Manually create and deploy the deployment test plan file.
b. Update deployment version for the CustomerServicePool.
c. Update dependency version number.
d. Update deployment descriptor.
4) Deploy and test the application.
Bookmark this on Delicious Digg this | Privacy Policy - Copyright © 2003-2009, The Apache Software Foundation, Licensed under ASL 2.0. |