Getting started with JBoss Seam and Maven in 10 seconds!

akquinet has created and published a Maven Archetype which allows you to setup and run a JBoss Seam Sample-Application with a full Maven based build configuration in around 10 seconds.

Maven is a build-management tool for Java projects. Maven uses a declarative construct known as a Project Object Model (POM) to describe projects, dependencies, modules and the build process (build in the large as it includes compilation, packaging, tests, reporting and deployment/distribution). The process for building and distributing a particular artifact (project) is clearly defined. Maven Archetypes allows to easily create pre-configured project skeleton, and so speed up the bootstrap of project developments.

JBoss Seam is a powerful Java EE framework to build robust Enterprise Web-Application. The Seam distribution includes a command line utility called seam-gen. It makes it easy to create a simple Seam Application. But the generated project build relies on Apache Ant. If you embrace the Maven wave, you want to build your application with Maven instead of Ant. Generally, setting a Seam project with Maven is painful. You need to write your Maven Project Object Models (POM files) and must know all the names and versions of used artifacts.

The presented archetype reduce the pain by setting everything correctly for you.

To generate an application for the JBoss AS 5.1.0.GA, just execute the following command:

mvn archetype:generate \
  -DarchetypeGroupId=de.akquinet.jbosscc \
  -DarchetypeArtifactId=jbosscc-seam-archetype \
  -DarchetypeVersion=1.1 \
  -DarchetypeCatalog=http://seam-archetype.sourceforge.net/jbosscc-seam-archetype/1.1/archetype-catalog.xml

The generated application is a multi-module project, packaged as an ear archive as presented below.

Package diagram of the generated application
Package diagram of the generated application

The generated Maven configuration supports different profiles for development, test and production. It includes dummy EJB 3.0 components, JPA entities with generated test data. The sources shows the programming model of the seam framework. The POM includes dependencies of seam features e.g. seam mail, drools integration or JBPM.

Provided Empty Application
Provided Empty Application

For advanced information please refer the documentation on http://seam-archetype.sourceforge.net/

Just start today!

Feel free to contact us for feedback, ideas or questions.

24 thoughts on “Getting started with JBoss Seam and Maven in 10 seconds!

  1. The configuration doesn’t support integration tests yet. May you use the JBoss Embedded and SeamTest classes or make usage of the Maven Cargo plugin to bootstrap a JBoss AS instance for integration tests. For testing EJB 3 components without a EJB-Container Ejb3Unit is a good alternative.

  2. I tried to use the archetype with jboss-seam-2.1.2, but that does not work, it works with 2.2.0.GA.

    My next question is (of course) eclipse and seam-gen integration. The Eclipse Jboss Tools do not automatically recognize the project. Do you use JBoss Tools with this archetype at all?
    Do you use seam-gen to create new elements?

  3. The generated sources have a few xml problems.
    1. The persistence.xml in datamodel has the class element after properties, class must come before properties

    2. The -ds.xml causes this error in eclipse “The string “–” is not permitted within comments.” This is caused by —— within the comment in the file header stating that this is a PostGreSQL example.

    After fixing these two issues, eclipse still shows many warnings, but no errors. I am not sure about many of them, however, there are are few that are easy to fix:

    One warning says that Generator is a raw type and should be parameterized in PersonDBTest. Putting a ? in angled brackets after Generator and before [] resolves this.

    In war/../messages.xhtml there is an xmlns=”http://www.w3.org/1999/xhtml” on a div tag which should be removed.

  4. Hello, thanks for replying. The JBoss AS 5.1.0.GA with Seam 2.1.2 (and likely earlier versions): Can’t deploy an exploded ear / war. It causes 5.1.0.GA to constantly shutdown and redeploy the application. This is a known issue. May your configure your build/pom so that it doesn’t explode your archives. But there are no reason to use a older version of seam in a new project.

    The archetype doesn’t based on seam-gen. It is an alternative to seam-gen with maven support.

  5. The JBoss Application Server has support for hot deployment of war and ear archives. You need to have the application deployed to JBoss AS as an exploded ear. The war archive inside the ear is already exploded. Now you can change static web resources such xhtml or css files. With tools such the FileSync plugin for Eclipse you can keep the files inside the war achive in-sync with your Eclipse project files

  6. The Maven command line should be:
    mvn archetype:generate \
    -DarchetypeGroupId=de.akquinet.jbosscc \
    -DarchetypeArtifactId=jbosscc-seam-archetype \
    -DarchetypeVersion=1.1 \
    -DarchetypeCatalog=http://seam-archetype.sourceforge.net/jbosscc-seam-archetype/1.1

    Without “archetype-catalog.xml” in the end, since Maven will append it automatically.

  7. I’ve tried to run the example build on jboss7.1 and when I try to add a new content I get a null pointer exception

    Caused by: java.lang.NullPointerException
    at com.company.weblogic.BlogEntryServiceBean.getInstance(BlogEntryServiceBean.java:55) [myproject-ejb.jar:]

  8. Thank you. I’ve just deployed a new version with a bugfix.

    mvn archetype:generate \
    -DarchetypeArtifactId=jbosscc-seam-archetype \
    -DarchetypeGroupId=de.akquinet.jbosscc \
    -DarchetypeVersion=1.4 \
    -DarchetypeCatalog=http://seam-archetype.sourceforge.net/jbosscc-seam-archetype/1.4/archetype-catalog.xml

    With the maven m2e eclipse plugin you can easily import the generated maven project into your workspace as eclipse projects.

    By the way, if you begin with a new application from scratch, you can also use the Java EE 6 Archetype.

    mvn archetype:generate \
    -DarchetypeArtifactId=jbosscc-javaee6-modular-ear-archetype \
    -DarchetypeGroupId=de.akquinet.jbosscc \
    -DarchetypeVersion=1.0

    Regrads,
    Heinz

  9. Tnx for the bugfux…I have an old seam2.1 project and I’m looking to port it to jboss7 that is how I came to your blog, I will try to use your project as a skeleton to port my application to jboss7

  10. Hi I’he tried to import the seam2 maven project for jboss7 into eclipse via import ecisting maven project but I got some errors :

    my archetype is named fourPM and the group is si.arctur

    Description Resource Path Location Type
    BlogEntryDaoBean cannot be resolved to a type BlogEntryDaoTest.java /fourPM-ejb/src/test/java/si/arctur/logic/dao line 31 Java Problem
    BlogEntryDaoBean cannot be resolved to a type BlogEntryDaoTest.java /fourPM-ejb/src/test/java/si/arctur/logic/dao line 40 Java Problem
    BlogEntryDaoBean cannot be resolved to a type BlogEntryDaoTest.java /fourPM-ejb/src/test/java/si/arctur/logic/dao line 48 Java Problem
    BlogEntryDaoBean cannot be resolved to a type BlogEntryDaoTest.java /fourPM-ejb/src/test/java/si/arctur/logic/dao line 53 Java Problem
    CommentDao cannot be resolved to a type CommentEntryDaoTest.java /fourPM-ejb/src/test/java/si/arctur/logic/dao line 33 Java Problem
    CommentDao cannot be resolved to a type CommentEntryDaoTest.java /fourPM-ejb/src/test/java/si/arctur/logic/dao line 40 Java Problem
    CommentDao cannot be resolved to a type CommentEntryDaoTest.java /fourPM-ejb/src/test/java/si/arctur/logic/dao line 45 Java Problem
    CommentDaoBean cannot be resolved to a type CommentEntryDaoTest.java /fourPM-ejb/src/test/java/si/arctur/logic/dao line 32 Java Problem
    CurrentUserInjectionProvider cannot be resolved to a type BlogEntryServiceTest.java /fourPM-ejb/src/test/java/si/arctur/logic/weblogic line 30 Java Problem
    CurrentUserInjectionProvider cannot be resolved to a type CommentServiceTest.java /fourPM-ejb/src/test/java/si/arctur/logic/weblogic line 30 Java Problem
    The declared package “si.arctur.dao” does not match the expected package “si.arctur.logic.dao” BlogEntryDaoTest.java /fourPM-ejb/src/test/java/si/arctur/logic/dao line 1 Java Problem
    The declared package “si.arctur.dao” does not match the expected package “si.arctur.logic.dao” CommentEntryDaoTest.java /fourPM-ejb/src/test/java/si/arctur/logic/dao line 1 Java Problem
    The declared package “si.arctur.dao” does not match the expected package “si.arctur.logic.dao” UserDaoTest.java /fourPM-ejb/src/test/java/si/arctur/logic/dao line 1 Java Problem
    The declared package “si.arctur.injectionprovider” does not match the expected package “si.arctur.logic.injectionprovider” CurrentUserInjectionProvider.java /fourPM-ejb/src/test/java/si/arctur/logic/injectionprovider line 1 Java Problem
    The declared package “si.arctur.weblogic.security” does not match the expected package “si.arctur.logic.weblogic.security” AuthenticatorServiceBeanTest.java /fourPM-ejb/src/test/java/si/arctur/logic/weblogic/security line 1 Java Problem
    The declared package “si.arctur.weblogic” does not match the expected package “si.arctur.logic.weblogic” BlogEntryListServiceTest.java /fourPM-ejb/src/test/java/si/arctur/logic/weblogic line 1 Java Problem
    The declared package “si.arctur.weblogic” does not match the expected package “si.arctur.logic.weblogic” BlogEntryServiceTest.java /fourPM-ejb/src/test/java/si/arctur/logic/weblogic line 1 Java Problem
    The declared package “si.arctur.weblogic” does not match the expected package “si.arctur.logic.weblogic” CommentServiceTest.java /fourPM-ejb/src/test/java/si/arctur/logic/weblogic line 1 Java Problem
    The import si.arctur.injectionprovider cannot be resolved BlogEntryServiceTest.java /fourPM-ejb/src/test/java/si/arctur/logic/weblogic line 17 Java Problem
    The import si.arctur.injectionprovider cannot be resolved CommentServiceTest.java /fourPM-ejb/src/test/java/si/arctur/logic/weblogic line 17 Java Problem
    The java field for attribute “id” is final AbstractEntity.java /fourPM-datamodel/src/main/java/si/arctur/model line 22 JPA Problem
    UserDaoBean cannot be resolved to a type UserDaoTest.java /fourPM-ejb/src/test/java/si/arctur/logic/dao line 29 Java Problem
    UserDaoBean cannot be resolved to a type UserDaoTest.java /fourPM-ejb/src/test/java/si/arctur/logic/dao line 36 Java Problem
    UserDaoBean cannot be resolved to a type UserDaoTest.java /fourPM-ejb/src/test/java/si/arctur/logic/dao line 40 Java Problem

    I also noticed that eclipse after importing it generates an additional foulder named fourPM which hass all the contetn of the other projects, is this a normal behaviour of a maven import, mybe it is because off the pom on the root foulder of the project?

    I’m a maven newby I’m still lerning maven 🙂

  11. I’ve also noticed that if I deploy the project via eclipse, I got

    java.lang.NoClassDefFoundError: si/arctur/fourPM/model/AbstractEntity

    but when I build the project via “maven install” and then copy the built ear to the jboss7 it works

    Deployment via eclipse bothe as exploaded ear ar as packed ear gives me the mentioned error, it should be maybe a clasloading issue?

  12. I’ve resolved the problem with exploeaded ear deployment via eclipse.

    In the ear pom you shuld change :
    lib/

    to

    lib/

    elswere the eclipse deployment wil not make the lib foulder in ear and you finish with clasloading issues.

    I also have not found the defaultJavaBundleDir option in the maven-ear-plugin documentation so I supose it is a typo, the pluggin documentation could be found here
    http://maven.apache.org/plugins/maven-ear-plugin/generate-application-xml-mojo.html

  13. aha ok then mybe it is a problem in the eclipse maven plugin, looks like ti does not handle “defaultJavaBundleDir” param correctly mybe it understands only “defaultLibDir” … tnx for the explanation

  14. Hi,

    Using Maven 3, i used below commands to generate the seam project:

    mvn archetype:generate
    Choose 102 -> de.akquinet.jbosscc:jbosscc-seam-archetype (Maven Archetype to generate a Seam Application – running on JBoss AS7)
    Version: 1.7

    It worked okay as it is in JBoss 7. However, when I try to use
    Seam UI components like , it’s not being rendered.

    I think, the setup is not currently including jboss-seam-ui***.jar

    How to enable the project to use Seam UI?

    Thanks,
    Chris

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s