Configuring JOnAS

Once you have downloaded the JOnAS source distribution as described in the section called Getting the source distribution in the chapter called Getting and installing the software, you first have to compile it. Else, you have a binary distribution and you can directly jump to the section called Setting your environment.

Compiling the source distribution

Compiling with make

JOnAS can be compiled with the make utility that you can download from GNU web site.

Note

Windows users who want to compile JOnAS with make have to download and install the Cygnus tools that provides a Unix-like environment for Windows. If you want to avoid the installation of the Cygnus tools you should consider compiling JOnAS with Ant.

The compilation process needs to know where the source code resides and where to store the generated binary distribution. The OBJECTWEB environment variable must point to the root of your source distribution and JONAS_ROOT to the directory where the binary distribution will be generated.

Here are examples to set your environment for Unix and Windows platforms:

  • Unix platforms: Assuming that your source distribution is in /usr/src/objectweb and you want to generate a binary distribution JOnAS in the /usr/local/objectweb directory, you should set your environment as follows:

    bash>export OBJECTWEB_HOME=/usr/src/objectweb
    bash>export JONAS_ROOT=/usr/local/objectweb
    or
    tcsh>setenv OBJECTWEB_HOME /usr/src/objectweb
    tcsh>setenv JONAS_ROOT /usr/local/objectweb

  • Windows platforms: Assuming that your source distribution is in C:\src\objectweb and you want to generate a binary distribution JOnAS in the C:\objectweb directory, you should set your environment as follows:

    C:>set OBJECTWEB_HOME=C:\src\objectweb
    C:>set JONAS_ROOT=C:\objectweb

The next step before compiling is to edit the $OBJECTWEB_HOME/jonas/gmk/config.mk so that it suits your configuration. Check the instructions at the end of the file and update the location of your JDBC driver jar files if needed. To use the Java SDK you installed as described in the section called Setting up your Java environment, ensure that JDKDIR is defined as ${JAVA_HOME} by using one of the following command:

  • Unix plaforms:

    bash>export JDKDIR=${JAVA_HOME}
    or
    tcsh>setenv JDKDIR ${JAVA_HOME}

  • Windows platforms:

    C:>set JDKDIR=%JAVA_HOME%

To build a JOnAS binary distribution from the sources, you just have to run make from the $OBJECTWEB_HOME/jonas directory. Here is an example:

cd $OBJECTWEB_HOME/jonas
make install

You will find the equivalent of the binary distribution in the $JONAS_ROOT directory. Now check the section called Setting your environment to complete the setup of your environment.

Note

If you want to rebuild JOnAS on JEREMIE instead of RMI you have to set OBJECTWEB_ORB=JEREMIE in your environment. Thus, if you want a version of JOnAS ready to run with RMI and JEREMIE, you should do something like:

cd $OBJECTWEB_HOME/jonas
export OBJECTWEB_ORB=RMI
make install
export OBJECTWEB_ORB=JEREMIE
make install

Compiling with Ant

Contribution needed here

Setting your environment

Once you have installed your JOnAS distribution, you have to setup the JONAS_ROOT environment variable prior to use JOnAS or any of its tools. You will also have to update your PATH as well.

Here are examples to set your environment for Unix and Windows platforms:

Checking that everything is correct

JOnAS is provided with a tool called CheckEnv that checks if your environment is correctly set.

If everything is set correctly, just run CheckEnv and you should obtain an output like:

- Environment variables
   Java     : /usr/local/jdk1.3.1/bin/java
   Options  : 
   Classpath: /usr/local/objectweb/JONAS/examples/classes:\
/usr/local/objectweb/JONAS/config:/usr/local/objectweb/JONAS/lib/RMI_jonas.jar:\
/usr/local/objectweb/JONAS/config:/usr/local/pgsql/lib/jdbc7.0-1.2.jar

- OBJECTWEB_ORB value: 
   RMI

- JONAS_ROOT value: 
   /usr/local/objectweb/JONAS

- JOnAS Services:
   jtm,dbm,ejb

- Contents of 'jonas.properties':
  (
   /usr/local/objectweb/JONAS/config/jonas.properties
   /users/cecchet/jonas.properties
   jonas.properties
  )
   jonas.registry = remote
   jonas.service.jms.url = joram://localhost:16010
   jonas.service.security.class = \
org.objectweb.jonas.security.JonasSecurityServiceImpl
   jonas.service.jmx.class = org.objectweb.jonas.jmx.JmxServiceImpl
   jonas.service.ejb.class = org.objectweb.jonas.container.EJBServiceImpl
   jonas.service.jtm.remote = false
   jonas.service.resource.resources = 
   jonas.service.jtm.timeout = 60
   jonas.service.jms.class = org.objectweb.jonas.jms.JmsServiceImpl
   jonas.name = jonas
   jonas.orb.port = 0
   jonas.service.jms.mom = org.objectweb.jonas_jms.JmsAdminForJoram
   jonas.service.jms.threadpoolsize = 10
   jonas.service.jtm.class = org.objectweb.jonas.jtm.TransactionServiceImpl
   jonas.services = jtm,dbm,ejb
   jonas.service.ejb.descriptors = 
   jonas.service.dbm.class = org.objectweb.jonas.dbm.DataBaseServiceImpl
   jonas.service.jms.collocated = true
   jonas.service.dbm.datasources = 
   jonas.service.resource.class = \
org.objectweb.jonas.resource.ResourceServiceImpl

- Contents of 'trace.properties':
  (file:/usr/local/objectweb/JONAS/config/trace.properties)
   trace.header = false
   trace.level = 31
   trace.out = out

- Contents of 'jndi.properties':
  (file:/usr/local/objectweb/JONAS/config/jndi.properties)
   java.naming.factory.initial = \
com.sun.jndi.rmi.registry.RegistryContextFactory
   java.naming.provider.url = rmi://localhost:1099
   java.naming.factory.url.pkgs = org.objectweb.jonas.naming

- Contents of 'jonas-users.properties':
  (file:/usr/local/objectweb/JONAS/config/jonas-users.properties)
   cecchet = admin, user, client

The JOnAS environment seems correct.

Warning

CheckEnv usually reports explicit error messages if your environment is misconfigured. However, CheckEnv may report that your environment seems correct even if there is a problem in your CLASSPATH. You should avoid to include manually the RMI_jonas.jar or JEREMIE_jonas.jar in your CLASSPATH but use the . $JONAS_ROOT/bin/unix/config_env command instead, it will do the job for you.

Congratulations ! You are now ready to use JOnAS and run your first EJB application

Additional options at JOnAS startup

In some cases you may want to give some specific options to the JVM that will execute JOnAS or add jar files to JOnAS runtime CLASSPATH. This can be achieved by setting the XTRA_CLASSPATH and JAVA_OPTS environment variables before starting JOnAS.

Here is an example adding 2 jar files to JOnAS runtime CLASSPATH and setting Sun's JVM heap size to 768MB, thread stack size to 128KB and turning on cpu profiling:

bash>export XTRA_CLASSPATH=/users/me/some_jar.jar:/users/me/another_jar.jar
bash>export JAVA_OPTS="-Xmx768m -Xss128k -Xprof"
bash>EJBServer

Check your JVM documentation for a complete list of available options.