Jee6 Cpt 6a Client Example

From the book:
"The application client container (ACC) includes a set of Java classes, libraries, and other
files required to bring injection, security management, and naming service to Java SE applications
(Swing, batch processing, or just a class with a main() method). ACC communicates with
the EJB container using RMI-IIOP and the web container with HTTP (e.g., for web services)."

"The Main class (shown earlier in Listing 6-7) is a stand-alone application that runs outside
the GlassFish container, yet it uses the @EJB annotation, which needs a container to inject a
reference of the BookEJBRemote interface. The Main class has to be executed in an ACC. A JNDI
lookup could have been used instead of the ACC, but the ACC can wrap a jar file and gives it
access to the application server resources. To execute the ACC, use the appclient utility that
comes with GlassFish and pass the jar file as a parameter as follows:
appclient -client chapter06-1.0.jar"

In the author's latest release of source code on 7/25, he included a MainContainer class which uses JNDI lookup and can be run on its own without using the GlassFish ACC.
You can still use Maven to make an executable jar file, but it doesn't have to be deployed in GlassFish.

Chapter 6a code, with directory structure:

. JavaEE6
. pom.xml
. . Chapter06a
. . pom.xml
… . src
… … main
… … . . java
… … … . com
… … … … apress
… … … … . . javaee6
… … … … … . chapter06a
… … … … … … Book.java
… … … … … … BookEJBRemote.java
… … … … … … BookEJB.java
… … … … … … MainContainer.java
… … . . resources
… … … . META-INF
… … … … persistence.xml

Compile results

Package the Executable Jar

Run MainContainer Class

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License