java.lang.IncompatibleClassChangeError: Found interface org.jboss.as.web.common.WebInjectionContainer, but class was expected
Environment
- JBoss Enterprise Application Platform (EAP)
- 7.3
- 7.4
Issue
- Updating to JBoss EAP 7.3.10, JBoss EAP 7.4.2 or later, we see an error like:
2023-03-16 12:55:16,197 SEVERE [org.apache.myfaces.webapp.AbstractFacesInitializer] (ServerService Thread Pool -- 102) An error occured while initializing MyFaces: java.lang.reflect.InvocationTargetException: javax.faces.FacesException: java.lang.reflect.InvocationTargetException
at javax.faces.FactoryFinder.injectAndPostConstruct(FactoryFinder.java:420)
at javax.faces.FactoryFinder.newFactoryInstance(FactoryFinder.java:519)
at javax.faces.FactoryFinder._getFactory(FactoryFinder.java:361)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:225)
at org.apache.myfaces.application.ViewHandlerImpl.<init>(ViewHandlerImpl.java:91)
at org.apache.myfaces.application.ApplicationImpl.<init>(ApplicationImpl.java:271)
at org.apache.myfaces.application.ApplicationImpl.<init>(ApplicationImpl.java:254)
at org.apache.myfaces.application.ApplicationFactoryImpl.createAndLogNewApplication(ApplicationFactoryImpl.java:55)
at org.apache.myfaces.application.ApplicationFactoryImpl.<init>(ApplicationFactoryImpl.java:50)
...
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at javax.faces.FactoryFinder.injectAndPostConstruct(FactoryFinder.java:415)
... 44 more
Caused by: java.lang.IncompatibleClassChangeError: Found interface org.jboss.as.web.common.WebInjectionContainer, but class was expected
at org.jboss.as.jsf.injection.MyFacesInjectionProvider.postConstruct(MyFacesInjectionProvider.java:51)
... 49 more
Resolution
-
If updating to JBoss EAP 7.3.10/JBoss EAP 7.4.2+, you must repeat step 3 of How to configure the Multi-JSF feature in EAP 7.1 ?, copying the jars from the latest JBoss EAP 7.3/JBoss EAP 7.4 cumulative patch.
-
JBoss EAP 7.3:
$ cp EAP_HOME/modules/system/layers/base/.overlays/layer-base-jboss-eap-7.3.10.CP/org/jboss/as/jsf-injection/main/*.jar /path/to/org/jboss/as/jsf-injection/JSF_IMPL_NAME-JSF_VERSION -
JBoss EAP 7.4:
$ cp EAP_HOME/modules/system/layers/.overlays/layer-base-jboss-eap-7.4.<version>.CP/org/jboss/as/jsf-injection/main/*.jar /path/to/org/jboss/as/jsf-injection/JSF_IMPL_NAME-JSF_VERSION
Root Cause
- Steps were previously followed from How to configure the Multi-JSF feature in EAP 7.1 ? to provide a custom JSF implementation with a prior JBoss EAP version/update. That copies jsf-injection libraries that depend on
org.jboss.as.web.common.WebInjectionContainerinto a custom module. In JBoss EAP 7.3.10/JBoss EAP 7.4.2+,org.jboss.as.web.common.WebInjectionContaineris refactored from a class to an interface. So if you copy or reuse the same custom jsf module with prior EAP jsf-injection jars in EAP 7.3.10/7.4.2, it results in this conflict as your jsf module depends on aWebInjectionContainerclass but only sees aWebInjectionContainerinterface instead.
Diagnostic Steps
- Check version of any
wildfly-jsf-injection-INJECTION_VERSION.jarincluded in a customorg/jboss/as/jsf-injectionmodule
SBR
Components
Category
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.