Skip to content

Latest commit

 

History

History
106 lines (79 loc) · 4.37 KB

README.adoc

File metadata and controls

106 lines (79 loc) · 4.37 KB

ejb-in-ear: Deployment of an EAR Containing a JSF WAR and EJB JAR

The ejb-in-ear quickstart demonstrates how to deploy an EAR archive that contains a JSF WAR and an EJB JAR.

What is it?

The ejb-in-ear quickstart demonstrates the deployment of an EAR artifact to WildFly Application Server. The EAR contains a JSF WAR and an EJB JAR.

This example consists of the following Maven projects, each with a shared parent.

Project Description

ejb

This project contains the EJB code and can be built independently to produce the JAR archive.

web

This project contains the JSF pages and the managed bean.

ear

This project builds the EAR artifact and pulls in the EJB and web artifacts.

The root pom.xml builds each of the subprojects in the above order and deploys the EAR archive to the server.

The example follows the common "Hello World" pattern, using the following workflow.

  1. A JSF page asks for a user name.

  2. On clicking Greet, the name is sent to a managed bean named Greeter.

  3. On setting the name, the Greeter invokes the GreeterEJB, which was injected to the managed bean. Notice the field is annotated with @EJB.

  4. The response from invoking the GreeterEJB is stored in a field (message) of the managed bean.

  5. 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.

Access the Application

The application will be running at the following URL http://localhost:8080/{artifactId}/.

Enter a name in the input field and click the Greet button to see the response.

For this quickstart, follow the special instructions to build Quickstarts Containing an EAR.

  1. Right-click on the {artifactId}-ear subproject, and choose Run AsRun on Server.

  2. Choose the server and click Finish.

  3. This starts the server, deploys the application, and opens a browser window that accesses the running application.

  4. To undeploy the project, right-click on the {artifactId}-ear project and choose Run AsMaven build. Enter wildfly:undeploy for the Goals and click Run.