How to use primefaces with Wildfly

This tutorial will teach us how to use primefaces with jboss 7.1.3.

Requirements:
 1.) primefaces 3.5
 2.) jboss 7.1.3
 3.) maven javaee6 generated project (ear, war, ejb)

Steps:
1.) Add primefaces module in jboss.
  a.) In JBOSS_HOME/modules directory create org/primefaces/main folder.
  b.) Copy primefaces.jar to the folder that has just been created.
  c.) Create module.xml.
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.primefaces">
 <resources>
  <resource-root path="primefaces-3.5.jar"/>
 </resources>
 
 <dependencies>
  <module name="javax.faces.api" />
 </dependencies>
</module>

2.) Add primefaces dependency to ejb/pom.xml
<dependency>
 <groupId>org.primefaces</groupId>
 <artifactId>primefaces</artifactId>
 <version>3.5</version>
</dependency>

3.) In web/pom.xml, exclude primefaces jar in ejb dependency:
<dependency>
 <groupId>com.czetsuya</groupId>
 <artifactId>xxx-ejb</artifactId>
 <type>ejb</type>
 <scope>provided</scope>
 <exclusions>
  <exclusion>
   <groupId>org.primefaces</groupId>
   <artifactId>primefaces</artifactId>
  </exclusion>
 </exclusions>
</dependency>

4.) Add jboss-deployment-structure.xml in ear/src/main/resources/META-INF:
<jboss-deployment-structure>
 <ear-subdeployments-isolated>true</ear-subdeployments-isolated>
  the EAR's lib folder -->
 <deployment>
  <dependencies>
   <module name="org.primefaces" />
   <module name="javax.faces.api" />
  </dependencies>
 </deployment>
</jboss-deployment-structure>

5 Comments

  1. We do not have access to the jboss 7.1 server, is there a
    way to do it within ear using depeencies in
    deployment-structure.xml? Thanks

    ReplyDelete
  2. Unfortunately, this procedure requires that you have access to your JBOSS module folder because it needs to create the primefaces module.

    With primefaces dependency and without modifying the JBOSS module, I was not able to make ear deployment work. But it works fine in war, so if you don't have a problem with war try it.

    ReplyDelete
  3. I have problem with primfaces when I added it to jboss 7.1. I could not deploy it. I tried your tutorial but I did not know where is pom.xml and where i had to create module.xml.
    Can you use picture to perform your tutorial? please ?
    thank you very much

    ReplyDelete
  4. it is possible to generate with maven jboss-deployment-structure.xml files to add under ear/src/main/resources/META-INF path ??
    Thanks in advance.
    Manuel

    ReplyDelete

Post a Comment

Post a Comment

Previous Post Next Post
NERV Open Source

Building production Spring Boot systems?

Explore NERV — open-source Java libraries for audit trails, persistence, exception handling, and reliable event-driven architecture.

Explore NERV on GitHub →