Mavenizing a JBoss Seam Project

Posted by Jiehuan Li

Jul 30, 2010 12:00:00 AM Open Source, Seam, Java, DevOps

By the time this post is written, Red Hat-JBoss has not officially supported Seam project with full Maven support. Meanwhile a third-party solution is available at http://www.glxn.net/seam-maven-refimpl/doc/tutorial/01-gettingstarted.html, and this solution is being sanctioned by Seam team. The future release of Seam 3 supposedly will fully support Maven. Before Seam 3 release this third-party solution is the endorsed solution for Maven integration with Seam 2.

We’ll outline below the steps we would need to take to create a Seam 2 project with full Maven support. By following instructions at http://www.glxn.net/seam-maven-refimpl/doc/tutorial/01-gettingstarted.html a baseline project named “seam-refimpl” will be ready for developers to further develop on. Our instructions below focus on how to create a fully Mavenized Seam project based on the template “seam-refimpl” project.

1. Export http://seam-maven-refimpl.googlecode.com/svn/trunk/seam-refimpl to your local workspace.

2. On file system, navigate to your local workspace, rename directory name “seam-refimpl” to your project name, update and of the parent POM file to reflect the new project name, also update and on the child POM files to reflect the new project name.  In the example the project name is changed to “vizuri-seam-maven”, the lines should read “com.vizuri.seam.maven”, and the lines should read “vizuri-seam-maven-XXX” where “XXX” is “ear”, “war”, or “ejb” depending on which POM file you are working on.

3. Import “vizuri-seam-maven” as “Existing Maven Projects” into your workspace.

Four projects now should show up in your workspace, they are “vizuri-seam-maven”, “vizuri-seam-maven-ear”, “vizuri-seam-maven-ejb”, and “vizuri-seam-maven-war”.

The build would fail at this point because we have more changes to make to fit the template to our use.

4. Open the pom.xml file under “vizuri-seam-maven” project root.
Replace the following lines:

			<app>refimpl</app><br>
			<app.context>seam-refimpl</app.context>
 

with:

			<app>vizuri-seam-maven</app><br>
			<app.context>vizuri-seam-maven</app.context>
 

5. Make a copy of vizuri-seam-maven/src/main/filters/filter-prod.properties under the same directory and name it “filter-dev.properties”.  Modify it to your needs.  In most case you just need to copy and paste the right sections from the commented out area to replace existing sections and uncomment.

6. A couple more changes you’ll have to make if you are using JBoss version 5 and above:

Open vizuri-seam-maven/pom.xml.  Replace the following line:

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

with:

			<version>5</version>
 

Open vizuri-seam-maven-ear/pom.xml.  Replace the following line:

			<data-source>META-INF/ds/${ds.xml}</data-source>
 

with:

			<data-source>META-INF/ds/${app.context}-ds.xml</data-source>
 

properties-maven-plugin from org.codehaus.mojo did not provide the neccessary properties for the plugins involved here.

Also open vizuri-seam-maven/pom.xml.  Replace the following line:

<app.jndi.pattern>${app.context}-ear/#{ejbName}/local</app.jndi.pattern>
 

with:

<app.jndi.pattern>${app.context}-ear-${project.version}/#{ejbName}/local</app.jndi.pattern>
 

This is the default JBoss 5 jndi pattern.

8. Create your own datasource file, in this case, “vizuri-seam-maven-ds.xml” under vizuri-seam-maven-ear/src/main/resources/.  You can remove the datasource file that came with the template.

9. Now you can remove the sample code that you don’t need, and start creating your own code under the projects.

10.  During development process, you may need to add more dependencies in the pom.xml files.  In our case, we need to add extended ejb3 annotation support, and we need to add drools support.

On vizuri-seam-maven/pom.xml, add the following dependencies in the element:

			<dependency>
			    <groupId>org.jboss.ejb3</groupId>
			    <artifactId>jboss-ejb3-common</artifactId>
			    <classifier>client</classifier>
			    <version>1.0.3</version>
			    <scope>provided</scope>
			</dependency>
			<dependency>
			    <groupId>org.jboss.ejb3</groupId>
			    <artifactId>jboss-ejb3-core</artifactIds>
			    <classifier>client</classifier>
			    <version>1.3.1</version>
			    <scope>provided</scope>
			</dependency>
			<dependency>
			    <groupId>org.jboss.ejb3</groupId>
			    <artifactId>jboss-ejb3-proxy</artifactId>
			    <classifier>client</classifier>
			    <version>1.0.0</version>
			    <scope>provided</scope>
			</dependency>
			<dependency>
			    <groupId>org.jboss.ejb3</groupId>
			    <artifactId>jboss-ejb3-proxy-clustered</artifactId>
			    <classifier>client</classifier>
			    <version>1.0.3</version>
			    <scope>provided</scope>
			</dependency>
			<dependency>
			    <groupId>org.jboss.ejb3</groupId>
			    <artifactId>jboss-ejb3-security</artifactId>
			    <classifier>client</classifier>
			    <version>1.0.2</version>
			    <scope>provided</scope>
			</dependency>
 

On vizuri-seam-maven-ear/pom.xml, uncomment the JBoss Rules dependencies and dependencies on “antlr-runtime”.

11. Customize vizuri-seam-maven-ejb/testng.xml file to fit your needs.  Remove unnecessary entries.

12. Customize vizuri-seam-maven-ejb/src/main/resources/META-INF/import.sql to fit your needs.  Remove unnecessary SQL statements.

13. Run “mvn clean install -Penv-dev” to clean, build, test, and deploy your application.

Posted by Jiehuan Li

Mr. Li has 15+ years experience in designing and implementing customized IT solutions for customers in various industries in both private sector amd public sector.

    

Posts by Topic

see all
Request a Complimentary Docker Consultation

An Open View

Vizuri Blog

Subscribing to our blog is a great way to stay up to date with the latest information from Vizuri, as well as our strategic partners. We focus on providing a range of content that is practically useful and relevant from both a technical and business perspective.

We promise to respect your privacy.

×