Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Leveraging J2EE JNDI principles

Abstract

Java 2 Enterprise Edition (J2EE) provides several technologies that lets build J2EE-compliant applications that can be run in any J2EE-compliant application server. One of the several technologies is Java Naming and Directory Interface (JNDI). JNDI is a technology that provides a unified access to different naming and directory services. Regardless of the underlaying service, if it supports JNDI a client doesn't have to know what exactly application it's to talk to other than it adheres to JNDI concepts and interfaces.

...

The JNDI framework allows for object implementations to be loaded in dynamically via object factories. For example, when looking up a printer bound in the name space, if the print service binds printer names to References, the printer Reference could be used to create a printer object, so that the caller of lookup can directly operate on the printer object after the lookup.
Theorically, it seems to be possible to create a web application that makes use of EJBs, deploy these EJBs in OpenEJB, and the web application in Tomcat, set up an object factory and finally boot it up. The following sections are to outline what exactly the steps are in OpenEJB and Tomcat with description of why they are required at all.

Before we start

Before we start, ensure that OpenEJB and Tomcat are in appropriate releases.

...

Warning

It's assumed that Tomcat and OpenEJB are already installed and running properly as a separate products.

Referencing EJBs in web application

J2EE 1.3 specification says (page 57):

...

As it's shown in the sample JSP above, there is no direct reference to the EJB container to be used. The application component provider doesn't have to know what container the EJB is to be deployed to. What it does have to ascertain is that the name the JSP uses is actually an ejb reference. Moreover, the reference should be the one to HelloHome home interface or otherwise the application will fail.

Installing OpenEJB's EJB factory in Tomcat

Warning

CATALINA_HOME environment variable points to the directory where Jakarta Tomcat 4.x has been installed.

...

That's it. Tomcat is now fully configured to work with OpenEJB. Don't forget to start up OpenEJB instance if the factory's been configured with RemoteInitialContextFactory.

Example application

You can use the OpenEJB Hello World as an example EJB to test things out. You won't need to do anything differently. Deploy the myHelloEjb.jar just as described in http://www.openejb.org/hello-world.html

...