I have seen that Mojarra 2.3 was released in June. What is the right way to make the upgrade?
In my pom.xml? Where basically I only have
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
Or in my server? I am using TomEE 7 plume, so should I manually download the JAR, delete lib/tomee-mojarra-7.0.0.jar
(which is JSF 2.2 compliant) and place the new JAR there? I am actually not sure this is appropriate, so I fear an answer that tells to wait until TomEE updates its library.
JSF 2.3 isn't released yet. The final release is scheduled for H1 2017, along with Java EE 8. Perhaps you're referring to a milestone (beta) version which should be recognizable by mXX
suffix in the file name such as javax.faces-2.3.0-m06.jar
for the current one. JSF 2.3 is currently still a work in progress. E.g. CDI producers for JSF artifacts such as @Inject FacesContext
were only added in m04
, new JSF 2.3 <f:websocket>
was only added in m05
, new JSF 2.3 <h:commandScript>
was only added in m06
and the upcoming m07
will feature among others the new <f:importConstants>
. And so on.
Basically, you need to wait for Java EE 8 to be released and that your server vendor offers a Java EE 8 compatible server. In case of TomEE, that would be the fictive future TomEE 8 version. In this case, you can simply upgrade the server and update the Java EE version in pom.xml
to 8.0
.
Manually upgrading Mojarra in the server is however also possible. How to do that depends on the server used. In case of TomEE 7.0.1 Plume, it should theoretically be a matter of replacing the existing /lib/javax.faces-2.2.12.jar
file with the newer one. Theoretically, because when I tried it, it appears that OpenWebBeans didn't like it. I got the below exception when deploying a JSF enabled project (just an empty WAR with an empty faces-config.xml
file).
java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1011)
at java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:1006)
at org.apache.webbeans.portable.AnnotatedElementFactory.setAnnotatedType(AnnotatedElementFactory.java:154)
at org.apache.webbeans.container.BeanManagerImpl.addAdditionalAnnotatedType(BeanManagerImpl.java:1292)
at org.apache.webbeans.portable.events.discovery.BeforeBeanDiscoveryImpl.addAnnotatedType(BeforeBeanDiscoveryImpl.java:134)
at com.sun.faces.cdi.CdiExtension.beforeBean(CdiExtension.java:95)
... 29 more
It appears that more work is necessary in order to figure out if this is an issue in OWB or in Mojarra. So far, Mojarra's CDI functionality has only been tested with Weld (in GlassFish/Payara and WildFly). For now, you unfortunately can't use JSF 2.3 on TomEE 7 yet.
Note that in such case editing the pom.xml
is not necessary. Only in order to have proper sources auto-attached during debugging in the IDE, you'd need to explicitly add the desired coordinate with target scope set to provided
.
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.3.0-m06</version>
<scope>provided</scope>
</dependency>
This applies to any Mojarra version nonetheless.