Build the enterprise with EJB 3, JBoss Seam, and Maven 2

Enterprise resource management with JBoss Seam and Maven 2

1 2 3 4 5 6 7 Page 7
Page 7 of 7

Running the example

Having completely explored the structure of the example application, we can now run it from the command line and then deploy the application into JBoss to see the results. Begin by running the mvn clean package command, as shown in Figure 8.

Running mvn clean package
Figure 8. Running mvn clean package (click to enlarge)

You should see a message indicating that the build was successful, as in Figure 9.

Success!
Figure 9. Success! (click to enlarge)

There should be about 495 source files to compile in the jboss-seam project, as you can see from the snapshot of the Maven command-line output in Figure 10.

495 source files to compile
Figure 10. 495 source files to compile (click to enlarge)

Now, start up the JBoss application server and copy the EAR file to the deploy directory of the default server, as shown in Figure 11.

Copying the EAR file to JBoss
Figure 11. Copying the EAR file to JBoss (click to enlarge)

This shouldn't reveal any problems. You should see a message like the one in Figure 12.

JBoss started successfully
Figure 12. JBoss started successfully (click to enlarge)

Open up a browser page and enter http://localhost:8080/servlet-1.0 as the URL. You'll see the registration page, shown in Figure 13.

Sample application
Figure 13. Sample application (click to enlarge)

There's no real database behind the application. The source code reveals that state is stored within the EJB entity upon submission. Seam maps JSF's view components to the EJB session beans and simply uses bijection to print state values from the entity on the confirmation page. Enter jadams, John Adams, and Independence as the Username, Real Name, and Password respectively, as in Figure 14.

Sample application
Figure 14. Entering your registration values (click to enlarge)

Then click Register. You'll get the result shown in Figure 15.

Registration complete
Figure 15. Registration complete (click to enlarge)

In conclusion

Many Java developers balk at the more rigorous project structure of Maven 2 as compared to Ant, but in the long run Ant's simplicity is its undoing. This is particularly true for enterprise projects such as the example used for this article, which must be able to store, manage, and persist many different types of resources.

As you've seen in this article, it is not hard to use Maven 2 as the build tool for Seam-based applications. This is good to know because JBoss Seam is often used for integrating EJB 3 and JSF, in turn two of the most commonly used (if not always popular) frameworks in enterprise development. JBoss Seam played three important roles in the example application: First, it influenced the application through various JAR distributions; second, it acted as an EJB 3 component; third, it fed into controlling major parts of the Web application in general, alleviating much of the plumbing associated with JSF Web structures. In all of these roles Seam was an indispensable part of the application, and well worth integrating.

Though you might find the thought of integrating Seam into your Maven 2 build process daunting, actually doing it isn't so hard. There's nothing about Maven 2 or JBoss Seam that makes the two mutually exclusive. In fact, they work beautifully together -- once introduced.

Michael Nyika is an Agile/Lean consultant with Stelligent, Inc., a Northern Virginia-based agile consultancy firm specializing in testing. He develops software in a number of dynamic languages, such as Ruby and Groovy, and is a passionate advocate of open source software.

Learn more about this topic

1 2 3 4 5 6 7 Page 7
Page 7 of 7