
Example Overview:
-----------------

This example shows how to access an EJB deployed in a JOnAS EJB container, from 
a servlet deployed in a Tomcat/Jetty container. 

It also shows how to use security in Tomcat or Jetty to authentificate the user and in JOnAS 
to authorize the user to access the EJB methods. This aspect is described in details 
in the "Use Security in JOnAS with TOMCAT" howto of the JOnAS documentation.

Besides, this example shows the uniform naming resource access supported in JOnAS.
The servlet gets a javax.transaction.UserTransaction object reference from the JNDI
using the "java:comp/UserTransaction" name. Moreover, it gets a reference on the
bean's home using an environment entry: "java:comp/env/ejb/".

This sample contains an example of using ejb-link which allows to link the EJB to the 
servlet. It is used in the web.xml file for both the ejb-ref and
ejb-local-ref tags. It implies that when the servlet performs a lookup on the bean,
the web classloader has got the visibility of the ejb class.
This is due to the classloader hierarchy between the ear classloader, ejb 
classloader and the web classloader.

The "src" directory contains
 - An EJB that mimics $JONAS_ROOT/examples/src/sb with the addition of
     security access to the bean methods.
 - The servlet source of ServletOp.

The "etc" directory contains
 - the "xml" directory which contains all the deployment descriptors used for this example :
     * application.xml (ear file)
     * ejb-jar.xml and jonas-ejb-jar.xml (jar file)
     * web.xml, jonas-web.xml and web-jetty.xml (war file)
 - the "resources" directory which contains all the resources for this application
     * "web" directory contains all resources used by the servlet


Compiling this example creates an .ear file that represents an application including :
 - a session bean used by the web application
 - a web application that will be used by Tomcat or Jetty to run the servlet.

Prerequisites
-------------
First, you must have installed a web container (ie : Catalina or Jetty) 
as the web container service

You have to set the environment variables
   CATALINA_HOME and CATALINA_BASE as indicated in the Tomcat 4.1.x documentation.
or JETTY_HOME for Jetty 4.2.x

Compiling and installing this example:
--------------------------------------
 ant install

Running this example:
--------------------
Commands are given for an Unix system. 
(Similar commands can be done on Windows)

1) Run a jonas server:
	cd $JONAS_ROOT/examples/earsample
	jonas start

2) Run your web browser (e.g., netscape):
	netscape http://<hostname>:<port>/earsample
	where <hostname> is the name of your machine (localhost by default)
	and <port> the port number (8080 by default)

3) Stop the jonas server
	jonas stop
