1 Reply Latest reply on Jul 6, 2010 8:29 PM by Snjezana Peco

    Observations Regarding JBoss Tools 3.1.1 Maven-Enabled Seam Web Project.

    Alex Thomas Newbie

      I've spent a few evenings evaluating the new JBoss Tools Seam module with Maven integration, and I've a few points that may save others some time and effort.  I've included a copy of my pom below for reference.  My environment:

       

      Eclipse 3.5.2 32-bit Cocoa build on MAC OS X 10.6 (Snow Leopard)

      Java 6 64-bit JVM

      JBoss Tools 3.1.1 installed from update site.

      JBoss AS 5.1-GA

      Seam 2.2.0-GA

       

      My observations relate to the use of the Seam Web Project wizard: File->New->Seam Web Project.

       

      First, the skeleton project generated by the wizard produced a dynamic web project that successfully deployed to the target container; I was able to direct my browser to localhost:8080/testing and view the seam-gen page.  It was the Maven piece that required some modification.

       

      First, the project pom did not include a path to the parent pom.  To build the .war artifact, I had to manually enter the parent pom location in the project pom.  Once that was done, the .war file built fine, but it did not deploy properly.

       

      Second, the pom produced by the project builder lists the source directory as “${basedir}/src/”.  This corrupts the package name in the output directory by prepending the fully qualified class name with “hot” or “main”.  To get around this problem, I leveraged the build-helper-maven-plugin to create two separate source directories of  “${basedir}/src/hot/” and  “${basedir}/src/main/”.

       

      Third, I had to use the maven-war-plugin and add <warSourceExcludes>WEB-INF/dev/**</warSourceExcludes> to avoid the nasty java.lang.IllegalStateException: Two components with the same name and precedence - component name: authenticator, component classes: org.domain.testing.session.Authenticator, org.domain.testing.session.Authenticator.  This is caused—I assume—by the maven builder copying the dev directory into the war file, which creates identical class hierarchies.  I suspect the dev directory is a mechanism for supporting the dynamic web project hot deploy in seam.  Embedded in the maven artifact, it causes an error.

       

      Once I'd made these changes, I was off and running.  Ultimately, I like the Seam/Maven integration and plan to continue using it.  The benefits of maven, in my mind, outweigh the initial setup quirks.  Ideally, the eclipse-seam-maven integration would account for these differences programatically, but until then, some manual configuration appears to be required.

       

      In short, you must make three modifications to get your Maven artifact to build and depoly on Jboss 5.1-GA (and probably other platforms):

       

      1. Add      the relative path of the parent pom to the project pom.

      2. Leverage      the build-helper-maven-plugin to modify the source directories.

      3. Configure      the maven-war-plugin to exclude the WEB-INF/dev directory content      from the maven war artifact.

       

      I hope this helps point others in the right direction.

       

      This is an example skeleton pom that actually builds and deploys successfully:

       

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

      <parent>

      <artifactId>testing-parent</artifactId>

      <groupId>org.remilya.test</groupId>

      <version>0.0.1-SNAPSHOT</version>

      <relativePath>../testing-parent</relativePath>

      </parent>

      <modelVersion>4.0.0</modelVersion>

      <groupId>org.remilya.test</groupId>

      <artifactId>testing</artifactId>

      <version>0.0.1-SNAPSHOT</version>

      <packaging>war</packaging>

      <name>testing</name>

      <description />

      <build>

      <sourceDirectory>${basedir}/src/main/</sourceDirectory>

      <outputDirectory>${basedir}/build/classes</outputDirectory>

      <resources>

      <resource>

      <directory>${basedir}/src/main/</directory>

      <excludes>

      <exclude>**/*.java</exclude>

      </excludes>

      </resource>

      </resources>

      <plugins>

      <plugin>

      <artifactId>maven-war-plugin</artifactId>

      <executions>

      <execution>

      </execution>

      </executions>

      <configuration>

      <warSourceDirectory>${basedir}/WebContent</warSourceDirectory>

      <warSourceExcludes>WEB-INF/dev/**</warSourceExcludes>

      </configuration>

      </plugin>

      <plugin>

      <groupId>org.codehaus.mojo</groupId>

      <artifactId>build-helper-maven-plugin</artifactId>

      <version>1.5</version>

      <executions>

      <execution>

      <id>add-source</id>

      <phase>generate-sources</phase>

      <goals>

      <goal>add-source</goal>

      </goals>

      <configuration>

      <sources>

      <source>${basedir}/src/hot/</source>

      </sources>

      </configuration>

      </execution>

      </executions>

      </plugin>

      </plugins>

      </build>

      <dependencies>

      <dependency>

      <groupId>org.hibernate</groupId>

      <artifactId>hibernate-validator</artifactId>

      </dependency>

      <dependency>

      <groupId>org.hibernate</groupId>

      <artifactId>hibernate-annotations</artifactId>

      </dependency>

      <dependency>

      <groupId>org.hibernate</groupId>

      <artifactId>hibernate-entitymanager</artifactId>

      </dependency>

      <dependency>

      <groupId>org.jboss.seam</groupId>

      <artifactId>jboss-seam</artifactId>

      </dependency>

      <dependency>

      <groupId>org.jboss.seam</groupId>

      <artifactId>jboss-seam-ui</artifactId>

      <exclusions>

      <exclusion>

      <artifactId>jboss-seam</artifactId>

      <groupId>org.jboss.seam</groupId>

      </exclusion>

      </exclusions>

      </dependency>

      <dependency>

      <groupId>org.jboss.seam</groupId>

      <artifactId>jboss-seam-ioc</artifactId>

      <exclusions>

      <exclusion>

      <artifactId>jboss-seam</artifactId>

      <groupId>org.jboss.seam</groupId>

      </exclusion>

      </exclusions>

      </dependency>

      <dependency>

      <groupId>org.jboss.seam</groupId>

      <artifactId>jboss-seam-debug</artifactId>

      <version>${seam.version}</version>

      </dependency>

      <dependency>

      <groupId>org.jboss.seam</groupId>

      <artifactId>jboss-seam-mail</artifactId>

      </dependency>

      <dependency>

      <groupId>org.jboss.seam</groupId>

      <artifactId>jboss-seam-pdf</artifactId>

      </dependency>

      <dependency>

      <groupId>org.jboss.seam</groupId>

      <artifactId>jboss-seam-remoting</artifactId>

      </dependency>

      <dependency>

      <groupId>javax.servlet</groupId>

      <artifactId>servlet-api</artifactId>

      </dependency>

      <dependency>

      <groupId>org.richfaces.ui</groupId>

      <artifactId>richfaces-ui</artifactId>

      </dependency>

      <dependency>

      <groupId>org.richfaces.framework</groupId>

      <artifactId>richfaces-api</artifactId>

      </dependency>

      <dependency>

      <groupId>org.richfaces.framework</groupId>

      <artifactId>richfaces-impl</artifactId>

      </dependency>

      <dependency>

      <groupId>javax.faces</groupId>

      <artifactId>jsf-api</artifactId>

      </dependency>

      <dependency>

      <groupId>javax.faces</groupId>

      <artifactId>jsf-impl</artifactId>

      </dependency>

      <dependency>

      <groupId>javax.el</groupId>

      <artifactId>el-api</artifactId>

      </dependency>

      <dependency>

      <groupId>org.drools</groupId>

      <artifactId>drools-compiler</artifactId>

      </dependency>

      <dependency>

      <groupId>org.jbpm</groupId>

      <artifactId>jbpm-jpdl</artifactId>

      </dependency>

      <dependency>

      <groupId>commons-digester</groupId>

      <artifactId>commons-digester</artifactId>

      </dependency>

      </dependencies>

      </project>