To run the EasyBeans container, a JDK 5.0 is required. A JDK 1.4.x will not work.
The EasyBeans container is provided as a .war file named ow_easybeans.war
which allows to add or remove it in a few steps.
The .war file needs to be copied into $CATALINA_BASE/webapps
directory.
Note : CATALINA_BASE
could be replaced by CATALINA_HOME
if CATALINA_BASE
is not defined.
This war file is specific to Tomcat. It will detect the Tomcat application server and register some libraries in Tomcat application server.
Also, the java: naming of EasyBeans will be redirected to Tomcat naming mechanism automatically.
By removing the war file of EasyBeans + ejb3s folder (and examples), all is removed (No libraries or configuration files are copied).
The examples provided in this preview need to be copied in the $CATALINA_BASE/examples_ejb3s/
directory. The resulting directory will be $CATALINA_BASE/examples_ejb3s
with subfolders like statelessbean
.
As usual, Tomcat is launched with the catalina start
or catalina run
command. Note that a JDK 5.0 is required
ow_easybeans.war
file located in $CATALINA_BASE/webapps
directory will be autoloaded at the tomcat startup.
The preview is bundled with some examples. The first one is a stateless bean
Here are the steps for launching this example :
Check that CATALINA_HOME (and maybe CATALINA_BASE) environment variables are defined before launching ant scripts
ant
needs to be launched in $CATALINA_BASE/examples_ejb3s/statelessbean
directory. This will compile the source code and copy the archive into the $CATALINA_BASE/ejb3s/stateless.jar/
directory.
$CATALINA_BASE/ejb3s
directory. The bean was loaded automatically.
Creating container for archive /home/xxx/xxx/stateless.jar.
ant run.client
run.client: [java] Calling helloWorld method... [java] Add 1 + 2... [java] Sum = '3'.
$CATALINA_BASE/webapps
directory.This example shows the use of JDK 5.0 annotations, the EJB3 interceptors and the EJB3 callbacks.
The SessionBean class is annotated with @Stateless
. This means that this class will be used as a stateless session bean.
The method trace
is annotated with @AroundInvoke
EJB3 annotation. This method will be called at each call on a business method. The business methods are defined in the interface implemented by the SessionBean
class.
As a new feature of the EJB3, the interface doesn't need to extend the Remote
interface. On the client side, there is no need to do a PortableRemoteObject.narrow()
call.
Some annotations are commented in the session bean example. To discover some new features like interceptors in other classes or the EJB3 callbacks, the comments can be removed and the example compiled again.
New methods can be added in the interface and implemented in the bean class, then the only step to do is to call ant
in $CATALINA_BASE/examples_ejb3s/statelessbean
directory. The EJB3 container will detect the changes and reload the bean.
As for the stateless session bean, the example needs to be compiled and deployed by calling ant
in the $CATALINA_BASE/examples_ejb3s/statefulbean
directory.
Once the bean is detected by the container and loaded, the client can be launched with ant run.client
command.
The output will be :
run.client: [java] org.objectweb.jotm.Current <init> [java] INFO: JOTM 2.0.11 [java] Start a first transaction [java] First request on the new bean [java] Second request on the bean [java] Commit the transaction [java] Start a second transaction [java] Buy 50 amount. [java] Rollback the transaction [java] after rollback, value = 30 [java] Request outside any transaction [java] Check that value = 30 [java] ClientStateful OK. Exiting.
The @Stateful
annotation is used to mark the bean as a stateful session bean.
State of the stateful session bean is notified by the transactions (default = REQUIRED), as the bean implements the SessionSynchronization
interface.
The example needs to be compiled and deployed by calling ant
in the $CATALINA_BASE/examples_ejb3s/entitybean
directory.
Once the bean is detected by the container and loaded, the client can be launched with ant run.client
command.
Note that Hibernate traces will be displayed as it will manage the Employee
entity class.
This example shows the use of an entity bean and using EJB3 persistence provider which is in this preview Hibernate. In a next version, the ObjectWeb Speedo product will provide an EJB3 persistence provider, so users will have the choice between these providers.
The Entity class is a POJO class annotated with @Entity
. The entities class are managed by the persistence provider, and in this case, by Hibernate.
As usual, ant
command needs to be launched in the $CATALINA_BASE/examples_ejb3s/messagedrivenbean
directory.
Once the bean is detected by the container and loaded, the client can be launched with ant run.client
command.
The output on the server side will be :
Receiving a message named '((org.objectweb.joram.client.jms.TextMessage...'. with the content 'Message0 Receiving a message named '((org.objectweb.joram.client.jms.TextMessage...'. with the content 'Message1 Receiving a message named '((org.objectweb.joram.client.jms.TextMessage...'. with the content 'Message2 Receiving a message named '((org.objectweb.joram.client.jms.TextMessage...'. with the content 'Message3 Receiving a message named '((org.objectweb.joram.client.jms.TextMessage...'. with the content 'Message4
The @MessageDriven
annotation is used to mark the bean as a message driven bean.
The client send 5 messages on the SampleQueue queue object that are received by the bean and displayed on the output.
On the client side, only the EJB3 libraries + bean's remote interface + client code is needed.
The generated code is done by using ASM which is faster than velocity + javac methods.
It detects automatically the changes in the class made by the user and reload the bean. This can be tried on the examples provided in this preview : Change the source code of a class, recompile and the EJB3 container will reload the bean.
The security is not yet managed
Some part of the deployment descriptors are not handled. env-entry are handled for example
The extended persistence context is not implemented. The Transaction-Scoped Persistence Context (default) has to be used.
No passivation on stateful
No timeout available
No support for @RemoteHome or @LocalHome backward interfaces
MDB support is partial : No MDB context injection or interceptors
Bugs or comments can be reported on JIRA Issue web site or to the EasyBeans mailing-list available at EasyBeans Mailing-List