Mavens EARs and Seam

Yesterday I was struggeling with Maven2 and JBoss . I had a few Seam-applications deployed on Glassfish, but due to the fact that jboss does not need SessionBeans (a.k.a. Seam-Actions in this case) to be defined in the Web-Deployment-Descriptor, i tried to deploy a fresh new Maven Project as a Prototype to JBoss.
The trouble I encountered was, that Seam was not able to locate the SessionBeans on the first glance. I had to use
this
really neat tool to have a look into the JNDI-Tree used by my Web-Application (see Screenshot) to see the obvious.
jndibrowser

What I forgot, was that using an EAR File, JBoss makes the Beans accessible in the global JNDI-Tree under the name of the EAR File which, at least within the current Build skeleton i use, is <artifactId>-ear-<version>.

Now that you have to declare the JNDI-Pattern Seam uses in order to resolve Action-names to SessionBeans, you this name is defined in /WEB-INF/components.xml of your webapp by default.
Obviously i did not want to hardcode any version into configfiles. The solution to this is Maven’s filtering capability. But wait! As you obviously do not want Maven to filter any resource in the webapp project , you’ll have to extract this information and isolate it.

Fortunately Seam is not that picky about where it gets this pattern from. Just leave this info out of components.xml and add a seam.properties file to your web project under

/src/main/resources/seam.properties

                    org.jboss.seam.core.init.jndiPattern /${pom.parent.artifactId}-ear-${project.version}/#{ejbName}/local
                

And make sure your pom contains the usual

xy-web-project/pom.xml

                    <build> <resources> <resource> <directory> src/main/resources </directory> <filtering> true </filtering> </resource> </resources> </build>
                

This’ll do. The seam.properties file will be filtered and copied to the /WEB-INF/classes dir, where Seam can find and use it.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>