Sunday, March 17, 2013

Upgrade JSF version in JBoss AS 7.1.1.Final

The JBoss AS 7.1.1 Final ships with Mojarra implementation of JSF versions 1.2 and 2.1.7. However sometimes developers need to change or upgrade the JSF version.
Prior to this JBoss version web applications could load their own JSF by placing the jar in WEB-INF/lib and adding the following context-param in web.xml.

   org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL
   true

But this doesn't work anymore for 7.1.1. Following is how you can do it.
At the time of this writing I have used version 2.1.19.
  • First you need to download the jsf-impl and jsf-api jars that you want. Here are the MVN Repository for jsf-impl and jsf-api.
  • Place the jsf-impl jar in the path modules/com/sun/jsf-impl/main.
  • Open the module.xml of that directory and change the value of path of resource-root as

  • Now place the jsf-api jar in the path modules/javax/faces/api/main.
  • Open the module.xml of that directory and change the value of path of resource-root as

  • Because jsf-api depends on jsf-impl you need to add the dependency in the module of jsf-api as

Now you are good to run you server. While running the server if you see the following line:
14:14:08,379 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-4) Initializing Mojarra 2.1.19 ( 20130213-1512 https://svn.java.net/svn/mojarra~svn/tags/2.1.19@11614) for context '/your-app'
Then everything is fine.
Good luck.

6 comments:

  1. Hi,

    Thanks for the post. We have an old application developed in JSF 1.2 with ICEFaces 1.8 and was running fine in Jboss 5.1 GA. Now,we need to migrate that app to JBoss 7.1.1. We want to use JSF 1.2 in JSF, instead of 2.1.7 which it supports by default. This is because if we upgrade to JSF 2.1.7 we need to upgrade the version of ICEFaces to 3.x from current version of 1.8.But, we are not supposed to migrate ICefaces version - rather downgrade JSF version.

    My question is how to downgrade to JSF 1.2 in JBoss 7.1.1?

    ReplyDelete
    Replies
    1. Hello Rajarshi,
      I have written another post http://tapas-tanmoy-bose.blogspot.in/2014/01/how-to-run-jsf-12-application-in-jboss.html on this topic. You can also find a sample application as attachment there.
      Regards,
      Tapas

      Delete
  2. i'm getting the following the error while deploying jsf webapplication into jboss as 7.1.1 final



    10:18:14,809 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.unit."eureQAWebApp.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."eureQAWebApp.war".POST_MODULE: Failed to process phase POST_MODULE of deployment "eureQAWebApp.war"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_01]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_01]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_01]
    Caused by: java.lang.NoClassDefFoundError: org/apache/commons/collections/Predicate
    at java.lang.Class.getDeclaredConstructors0(Native Method) [rt.jar:1.7.0_01]
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404) [rt.jar:1.7.0_01]
    at java.lang.Class.getConstructor0(Class.java:2714) [rt.jar:1.7.0_01]
    at java.lang.Class.getConstructor(Class.java:1674) [rt.jar:1.7.0_01]
    at org.jboss.as.web.deployment.jsf.JsfManagedBeanProcessor.deploy(JsfManagedBeanProcessor.java:108)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    ... 5 more
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.Predicate from [Module "deployment.eureQAWebApp.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
    ... 11 more

    ReplyDelete
    Replies
    1. Hi Laxmi, from your stacktrace it is clear that your application is unable to load a class org.apache.commons.collections.Predicate.

      Delete
    2. But the module (org/apache/commons/collections) is exist in jboss as 7.1.1
      Is there any procedure to load Predicate class

      Delete