Upgrade JSF / Mojarra in JBoss AS / EAP / WildFly
Asked Answered
J

1

34

How do I upgrade Mojarra in JBoss server and tell it use the given Mojarra 2.x JARs instead of JBoss own jboss-jsf-api_2.1_spec-2.0.1.Final.jar as indicated in startup log?

If that's relevant, I am currently using JBoss AS 7.1.

Jadejaded answered 13/6, 2013 at 11:15 Comment(0)
S
65

The below procedure applies to JBoss AS 7.2+, JBoss EAP 6.1+, and JBoss WildFly 8+ and assumes that you've full control over the server installation and configuration. This upgrades the server-wide default JSF version:

  • Download the individual Mojarra API and impl files (and thus not the single javax.faces.jar file). Current latest 2.1.x version is 2.1.29 and current latest 2.2.x version is 2.2.14. Let's assume that you want to upgrade to 2.2.x. You can download them individually from their Maven repository:
  • Make sure that JBoss is shutdown.
  • Update JSF API in /modules/system/layers/base/javax/faces/api/main:
    • Delete or backup the old JAR file (do NOT keep it in the same folder, even not renamed!).
    • Put jsf-api-2.2.14.jar file in there.
    • Open module.xml file and edit <resource-root> to specify the new file name as in <resource-root path="jsf-api-2.2.14.jar"/>
  • Update JSF impl in /modules/system/layers/base/com/sun/jsf-impl/main:
    • Delete or backup the old JAR file (do NOT keep it in the same folder, even not renamed!).
    • Put jsf-impl-2.2.14.jar file in there.
    • Open module.xml file and edit <resource-root> to specify the new file name as in <resource-root path="jsf-impl-2.2.14.jar"/>
  • Cleanup JBoss cache/work data just to make sure that there's no old copy of the JARs from previous deployments hanging in there which would potentially only collide with the new JARs:
    • Trash all contents of /standalone/data (except of custom data folders like folder containing uploaded files, of course)
    • Trash all contents of /standalone/deployments
    • Trash all contents of /standalone/tmp
  • Start JBoss. It should now use the new JSF version for all deployments.

The same procedure applies to JBoss AS 7.0/7.1 and JBoss EAP 6.0, you only need to browse in /modules/* instead of /modules/system/layers/base/*, and you need to explicitly delete the old .index file there, if any (JBoss will autocreate one). Also, if the module.xml in API folder misses <module name="com.sun.jsf-impl"/> inside <dependencies>, then you need to manually add it.

Important note is that Mojarra 2.2.x versions older than 2.2.7 will fail in AS/EAP during deployment with the following exception: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.faces.flow.builder.FlowDefinition. You've then basically 2 options: downgrade to Mojarra 2.1.x, or upgrade to at least 2.2.7 or newer.

In case you'd like to upgrade to Mojarra 2.3, which doesn't offer a 2-JAR variant anymore on Maven, you'd need to manually create the 2-JAR variant based on javax.faces.jar file as per this procedure: How to install one jar variant of JSF (javax.faces.jar) on WildFly.

Silvia answered 13/6, 2013 at 11:24 Comment(6)
I've folowed this instructions but I when I run jboss7.1 server I get the error Critical error during deployment: : java.lang.NoClassDefFoundError: com/sun/faces/spi/InjectionProvider, any hints?Indigene
I forgot to mention that i use jsf 2.2.3 version, I nead the @ViewScoped in CDI bean, as I understand this support was included in JSF2.2Indigene
I think instead of saying " individual Mojarra 2.x", it should be "individual Mojarra 2.1.x" because JSF2.2 requires different approach. 2.x may indicate users that 2.2.. also follows same steps.Sennet
@Nambari: above is also applicable on 2.2. At least, on WildFly which only doesn't have .index files anymore and already has the com.sun.jsf-impl module entry right. Haven't tried 2.2 on JBoss AS7/EAP6 yet.Silvia
You may be correct with WildFly. We are still with 7.1.1 Final. I came across this answer, about to do suggested changes, but comments said 2.2.. has different instructions, felt like answer and comments conveying different message. Thought to bring to your attention.Sennet
I added the jsfi-mpl module as dependency. See here: stackoverflow.com/questions/17138490/…Sen

© 2022 - 2024 — McMap. All rights reserved.