EJBs in a WAR - Simplified packaging defined by EJB 3.1, Available in GlassFish v3

An enterprise bean class
with a component-defining annotation defines an enterprise bean
component when packaged within the WEB-INF/classes directory or in a
.jar file within WEB-INF/lib.

In simple English it means, an EJB can be a POJO annotated with EJB
annotations (such as @javax.ejb.Stateless) and bundled within
WEB-INF/classes inside a WAR.

This feature is available in GlassFish v3 for
href="http://blogs.sun.com/MaheshKannan/entry/ejb_3_1_in_glassfish">some
time now.

Imagine the ramifications, you now have Container Managed Persistence,
Transacations, Security, and all other standard benefits of EJB - only
this time in a WAR file.

The default configuration of GlassFish v3 Prelude does not include an
EJB container. Lets first install it!

The EJB container in GlassFish v3 Prelude can be installed in couple of
ways:

Using Update Center as described
href="http://blogs.sun.com/MaheshKannan/entry/installing_ejb_container_in_glassfish">here.

Or using the "pkg" command which is described below

The "pkg" command shipped with GlassFish is platform-independent and
runs on all the supported platforms. You can use the standard "pkg-get"
command with OpenSolaris but that requires more options to be
specified. For simplicity, we'll use the "pkg" command bundled with
GlassFish as shown below:

If the application is pre-deployed then saving this file will
auto-deploy it as shown in
href="http://blogs.sun.com/arungupta/entry/screencast_27_simple_web_application">screencast
#27. Otherwise right-click on the project and select "Deploy".

And finally invoking the servlet at
"http://localhost:8080/ReallySimpleEJB/EJBClient" shows the following
output: