Getting started with JBoss Seam and Maven in 10 seconds!

/

by

Reading Time: 2 Minuten

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.


Comments

24 responses to “Getting started with JBoss Seam and Maven in 10 seconds!”

  1. Christian

    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

  2. Thank you for another fantastic article. Where else could

    anyone get that kind of info in such a perfect way of writing?
    I’ve a

    presentation next week, and I am on the look for such info.

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

  4. The parameter defaultLibDir is an alias of defaultJavaBundleDir. It has been changed a long time ago (http://svn.apache.org/viewvc?view=revision&revision=471886). I’ll change it to defaultLibDir.

  5. SimonC

    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

  6. SimonC

    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?

  7. SimonC

    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 🙂

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

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

  10. 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:]

  11. How can I import the jboss7 project in Eclipse? Can you please describe the procedure?

  12. Hello,

    we migrated our Seam archetype, so that the sample application running now on JBoss AS 7.

    mvn archetype:generate \
    -DarchetypeArtifactId=jbosscc-seam-archetype \
    -DarchetypeGroupId=de.akquinet.jbosscc \
    -DarchetypeVersion=1.3

    You will find a short documentation on http://seam-archetype.sourceforge.net/jbosscc-seam-archetype/1.3/

    Maybe it will help you to migrate existing Seam 2 applications to JBoss AS 7.

    Regrads,
    Heinz

  13. hello,
    i am using maven3.0.3 and i am getting the error [ERROR] Non-resolvable parent POM: could not transfer artifact org.jboss.saem:parent:pom:2.2 from/to repository.jboss.org (http://repository.jboss.org/maven2) Access denied to http://repository.jboss.org/maven2/org/jboss/seam/parent/2.2/parent-2.2.pom and parent.relativePath points to no local POM

  14. Bradley

    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.

  15. […] Arquétipo do Akquinet – http://blog.akquinet.de/2009/09/14/getting-started-with-jboss-seam-and-maven-in-10-seconds/ – esse  é pra agredir mesmo! Na minha opinião, em questão de estrutura é o mais […]

  16. blog09ats

    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

  17. Does your project structure support hotdeploy?

  18. blog09ats

    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.

  19. Dietrich

    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.

  20. Dietrich

    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?

  21. […] 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 ArchetypRead more at http://blog.akquinet.de/2009/09/14/getting-started-with-jboss-seam-and-maven-in-10-seconds/ […]

  22. blog09ats

    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.

  23. oops, I actually meant integration tests not integration builds.

  24. Does your full build configuration also include integration builds?

Discover more from akquinet - Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading

WordPress Cookie Notice by Real Cookie Banner