THIS PAGE IS ARCHIVED FOR THE MOMENT AND WILL BE REMOVED LATER.

Life in 0.9.2

Some background on how a 0.9.2 installation behaves.

Basic layout

Basically, openejb.base is the source for 100% of all configuration information and third party config files (log4j, castor, instantdb, whatever). This includes finding where the, possibly many, <Deployment> entries in the openejb.conf point. The openejb.home is where the code loading OpenEJB will look for all the OpenEJB libraries. Usually openejb.base is not explicitly set and defaults to the value of openejb.home, so many people are used to only dealing with openejb.home.

The point of having and openejb.base and openejb.home was basically to allow several independently configured instances of OpenEJB running on a system (perhaps embedded in Swing apps, in Tomcat, running as a standalone Server, or even in Groovy as Mr. Strachan did!) but without the need to copy all the OpenEJB system libraries everywhere.

openejb.home

  • can be set explicitly via a system property.
  • if not set it default's to user.dir, which is the current working directory.
    See source code

openejb.base

  • can be set explicitly via a system property.
  • If not set it default's to openejb.home.
    See source code

openejb.configuration

  • can be set to explicitly point to the file containing your configuration.
  • If set to a relative path, we first look in user.dir/your-conf-file, then in openejb.base/your-conf-file
  • If not set we check in openejb.base/conf/openejb.conf
  • If no conf file is found, we create one in openejb.base/conf/openejb.conf
    See source code

relative paths in openejb.conf

Note: Both Containers and Resources are what OpenEJB thinks of as Services which have an init method. In hindsight, both hacks to the JDBC Resouces Adapter and Castor CMP Container could be removed if we simply guaranteed that a Service's init method is called "relative" to the openejb.base dir.

log files

  • The log4.configuration file is resolved relative to openejb.base. See code
  • The properties in the config file that point to files are also resolved relative to openejb.base. See code

OpenEJB libraries

Summary

A summary of the above in a different notation:

openejb.home = user.dir (can be set explicitly)
openejb.base = openejb.home (can be set explicitly)
openejb.conf = openejb.base/conf/openejb.conf (can be set explicitly)
logging.conf = openejb.base/conf/logging.conf (can be set explicitly)
deployments  = paths listed in openejb.conf (relative paths resolved from openejb.base)
Classpath includes openejb.home/lib and openejb.home/dist

Example layout

In this one the openejb.home and openejb.base are set, everything else is defaulted. The openejb.conf file as been updated to point to the ejb jars by name (abc-ejbs.jar and xyz-ejbs.jar).

An example layout:

/usr/local/openejb  (openejb.home)
/usr/local/openejb/lib  (in classpath)
/usr/local/openejb/dist (in classpath)
/home/jsmith/foo_app  (openejb.base)
/home/jsmith/foo_app/conf/openejb.conf
/home/jsmith/foo_app/conf/logging.conf
/home/jsmith/foo_app/abc-ejbs.jar (Deployment entry in openejb.conf)
/home/jsmith/foo_app/xyz-ejbs.jar (Deployment entry in openejb.conf)
/home/jsmith/foo_app/logs/  

Another Example layout

In this example openejb.home and openejb.base are setup as well as the explicit paths for the openejb and log4j configuration files.

An example layout:

/usr/local/openejb  (openejb.home)
/usr/local/openejb/lib  (in classpath)
/usr/local/openejb/dist (in classpath)
/home/jsmith/foo_app  (openejb.base)
/home/jsmith/foo_app/openejb.xml  (openejb.configuration)
/home/jsmith/foo_app/abc-ejbs.jar (Deployment entry in openejb.xml)
/home/jsmith/foo_app/xyz-ejbs.jar (Deployment entry in openejb.xml)
/home/jsmith/foo_app/log4j.conf  (log4j.configuration)
/home/jsmith/foo_app/mylogs/  (logging dir as defined in log4j.conf)

Possible and nice Tomcat setup.

Set openejb.base to be the same as catalina.home, then OpenEJB and Tomcat will share the same conf and logs directories.

Current OpenEJB 1.0 layout

In the current 1.0 code, user.dir and openejb.home and openejb.base are essentially aggregated together to create a larger layout for a single running OpenEJB instance. See code

openejb.home

  • can be set explicitly via a system property.
  • if not set it default's to user.dir, which is the current working directory.
    Same as 0.9.2

openejb.base

  • can be set explicitly via a system property.
  • If not set it default's to openejb.home.
    Same as 0.9.2

openejb.configuration

  • can be set to explicitly point to the file containing your configuration.
  • If set to a relative path, we first look in user.dir/your-conf-file, then in openejb.base/your-conf-file, openejb.home/your-conf-file.
  • If not set we check in openejb.base/conf/openejb.conf, then openejb.home/conf/openejb.conf
  • If no conf file is found, we create one in openejb.base/conf/openejb.conf

relative paths in openejb.conf

  • Deployment entries are resolved relative to openejb.base, then openejb.home. source code
  • Containers (such as the Castor CMP Container) use openejb.base to resolve their own config files. (Same as 0.9.2)
  • Resource adapters are loaded from the openeb.home, not openejb.base as in 0.9.2. See code.

log files

  • The log4.configuration file is resolved relative to openejb.base, then openejb.home.
  • Each property in the config file that point to files are also first resolved relative to openejb.base then openejb.home. See code

OpenEJB libraries

  • The jars in the directories under openejb.home are added to the classloader.

Example

An interesting note on this is that the openejb.home is only checked when the file or directory is not found in the openejb.base. So say you had the following entries in your openejb.conf.

 
<Deployment dir="beans" />
<Deployment jar="foobar.jar" />

Then say you have an openejb.home with the following files and directories:

/usr/local/openejb (openejb.home)
/usr/local/openejb/dist/(multiple jars)
/usr/local/openejb/lib/(multiple jars)
/usr/local/openejb/conf/openejb.conf
/usr/local/openejb/beans/widget.jar
/usr/local/openejb/beans/dohickey.jar
/usr/local/openejb/beans/gizmo.jar
/usr/local/openejb/logs/  (default logging dir)

And an openejb.base with the following files and directories:

/home/jsmith/foo_app (openejb.base)
/home/jsmith/foo_app/conf/openejb.conf (used for this app)
/home/jsmith/foo_app/foobar.jar
/home/jsmith/foo_app/log4j.conf  (log4j.configuration)
/home/jsmith/foo_app/logs/  (logging dir as defined in log4j.conf)

In this setup you will end up using your own conf file, your own logging file and logs directory. You will get the ejbs from foobar.jar located in your openejb.base and the ejbs from the widget.jar, dohickey.jar, and gizmo.jar files in openejb.home/beans.

Let's say that later on you decide you don't like having the foobar.jar listed in your conf file and decide to create a beans dir in your openejb.base and put it there. When you start up your openejb instance it will no longer contain the ejbs from the widget.jar, dohickey.jar, and gizmo.jar files. They are in the openejb.home and the openejb.home is only checked when the file or directory is not found in the openejb.base. By adding a beans directory to your openejb.base you also implicitly removed all the ejbs from openejb.home/beans.

By adding to your base you are potentially removing parts of your configuration at the same time.

  • No labels