Overview

General

Configuration

Servers

Integrations

Community

Feeds

 

Overview

An error occurred: http://svn.apache.org/repos/asf/openejb/trunk/openejb3/examples/counter-stateful-pojo/README.txt. The system administrator has been notified.

The Code

In this example we develop a simple counter stateful session EJB.

Local business interface
@Local annotation

Note that it's not mandatory to annotate local business interfaces with the @Local annotation. If a business interface doesn't have any annotation, it's assumed to be local by the ejb container.

An error occurred: http://svn.apache.org/repos/asf/openejb/trunk/openejb3/examples/counter-stateful-pojo/src/main/java/org/apache/openejb/examples/counter/CounterLocal.java. The system administrator has been notified.
Remote business interface
An error occurred: http://svn.apache.org/repos/asf/openejb/trunk/openejb3/examples/counter-stateful-pojo/src/main/java/org/apache/openejb/examples/counter/CounterRemote.java. The system administrator has been notified.
Bean
An error occurred: http://svn.apache.org/repos/asf/openejb/trunk/openejb3/examples/counter-stateful-pojo/src/main/java/org/apache/openejb/examples/counter/CounterImpl.java. The system administrator has been notified.

Writing a unit test for the example

Writing an unit test for the stateful session EJB is quite simple. We need just to write a setup method to create and initialize the InitialContext, and then write our test methods

setUp

An error occurred: http://svn.apache.org/repos/asf/openejb/trunk/openejb3/examples/counter-stateful-pojo/src/test/java/org/apache/openejb/examples/counter/CounterImplTest.java. The system administrator has been notified.

Note the "openejb.deployments.classpath.include" parameter, which tells the ejb container to search for EJBs in the classpath, and specifies in which java packages they are to be located.

Test the local business interface

An error occurred: http://svn.apache.org/repos/asf/openejb/trunk/openejb3/examples/counter-stateful-pojo/src/test/java/org/apache/openejb/examples/counter/CounterImplTest.java. The system administrator has been notified.

Test the remote business interface

An error occurred: http://svn.apache.org/repos/asf/openejb/trunk/openejb3/examples/counter-stateful-pojo/src/test/java/org/apache/openejb/examples/counter/CounterImplTest.java. The system administrator has been notified.

Running

Running the example is fairly simple, just run:

$ cd counter-stateful-pojo
$ mvn clean install

Which should create output like the following.

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
[OPENEJB:surefire] Running org.apache.openejb.examples.counter.CounterImplTest
log4j:WARN No appenders could be found for logger (OpenEJB).
log4j:WARN Please initialize the log4j system properly.
Apache OpenEJB 3.0-incubating-SNAPSHOT    build: 20070105-12:45
http://incubator.apache.org/openejb
OpenEJB ready.
[OPENEJB:surefire] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 1.943 sec
[OPENEJB:INFO] [jar:jar]
[OPENEJB:INFO] Building jar: openejb3/examples/counter-stateful-pojo/target/simple-counter-statefuls-1.0-SNAPSHOT.jar
[OPENEJB:INFO] [install:install]
[OPENEJB:INFO] Installing openejb3/examples/counter-stateful-pojo/target/simple-counter-statefuls-1.0-SNAPSHOT.jar ... 
[OPENEJB:INFO] ------------------------------------------------------------------------
[OPENEJB:INFO] BUILD SUCCESSFUL
[OPENEJB:INFO] ------------------------------------------------------------------------

   

Apache OpenEJB is an project of The Apache Software Foundation (ASF)
Site Powered by Atlassian Confluence .
[ edit ]