Tuesday, May 15, 2007

JBoss 4.2 with Seam 1.2 using MyFaces

JBoss stopped using MyFaces in JBoss 4.2 and started using a JSF 1.2 compliant deployment.
This creates problems when using Seam 1.2.1 and JBoss 4.2 together. The fix is quite simple and can be remedied in three easy steps.

Step One:
Remove the MyFaces entry in web.xml by commenting out the MyFaces listener as shown below by adding the blue text below:
<!--
<listener> <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
-->

Step Two:
Edit application.xml (usually in the project's resources directory) and remove by either deletion or comment the el-api.jar module.

You can comment it out as shown below:
<!--
<module>
<java>el-api.jar</java>
</module>
-->

Step Three:
The final step is to make sure the build.xml copies commons-digester and commons-beanutils to the WEB-INF/lib directory of the web application's war file.

Add the following two lines to build.xml that are highlighted below in blue in the build files "war" target:
<target name="war" depends="compile"
description="Build the distribution .war file">
<copy todir="${war.dir}">
<fileset dir="${basedir}/view" />
</copy>
<copy todir="${war.dir}/WEB-INF">
<fileset dir="${basedir}/resources/WEB-INF">
<include name="*.*"/>
<include name="classes/**/*.*"/>
<exclude name="classes/**/*.class"/>
</fileset>
<filterset>
<filter token="debug" value="${debug}" />
<filter token="jndiPattern" value="${project.name}/#{ejbName}/local" />
<filter token="embeddedEjb" value="false" />
</filterset>
</copy>
<copy todir="${war.dir}/WEB-INF">
<fileset dir="${basedir}/resources/WEB-INF">
<include name="lib/*.*"/>
<include name="classes/**/*.class"/>
</fileset>
</copy>
<copy todir="${war.dir}/WEB-INF/lib">
<fileset dir="${lib.dir}">
<include name="ajax4jsf*.jar" />
<include name="richfaces*.jar" />
<include name="oscache*.jar" />
<include name="jsf-facelets.jar" />
<include name="jboss-seam-*.jar" />
<include name="commons-digester-*.jar"/>
<include name="commons-beanutils-*.jar"/>
<exclude name="jboss-seam-gen.jar" />
</fileset>
</copy>
<copy todir="${war.dir}/WEB-INF/classes">
<fileset dir="${basedir}/resources">
<include name="messages*.properties"/>
</fileset>
</copy>
</target>

That should be sufficient to run the seam-gen generated applications to run on JBoss 4.2.0GA.

No comments:

Contributors