The ejb-in-war
quickstart demonstrates how to package an EJB bean in a WAR archive and deploy it to {productName}. Arquillian tests are also provided.
The ejb-in-war
quickstart demonstrates the deployment of an EJB bean bundled in a WAR archive for deployment to {productNameFull}. The project also includes a set of Arquillian tests for the managed bean and EJB.
The example follows the common "Hello World" pattern using the following workflow.
-
A JSF page asks for the user name.
-
On clicking Greet, the name is sent to a managed bean named
Greeter
. -
On setting the name, the
Greeter
invokes theGreeterEJB
, which was injected into the managed bean. Notice the field annotated with@EJB
. -
The response from invoking the
GreeterEJB
is stored in a fieldmessage
of the managed bean. -
The managed bean is annotated as
@SessionScoped
, so the same managed bean instance is used for the entire session. This ensures that the message is available when the page reloads and is displayed to the user.
The application will be running at the following URL http://localhost:8080/{artifactId}/.
When you run the Arquillian tests, Maven prints summary of the performed tests to the console. You should see the following results.
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
If you are interested in more details, check target/surefire-reports
directory.
You can check console output to verify that Arquillian has really used the real application server.
Search for lines similar to the following ones in the server output log:
INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) WFLYSRV0027: Starting deployment of "test.war" (runtime-name: "test.war")
...
INFO [org.jboss.as.server] (management-handler-thread - 29) WFLYSRV0010: Deployed "test.war" (runtime-name : "test.war")
...
INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) WFLYSRV0028: Stopped deployment test.war (runtime-name: test.war) in 12ms
...
INFO [org.jboss.as.server] (management-handler-thread - 30) WFLYSRV0009: Undeployed "test.war" (runtime-name: "test.war")