Why is WildFly 10 + JSF 2.3 not working with Omnif

2019-04-12 13:25发布

I've been trying to get an app up and running using jsf 2.3, primefaces 6 and omnifaces 2.6.1 on Wildfly 10.

I have already splitted the jsf 2.3 (api and impl) and completed the set up for WildFly.

The applications starts smoothly without omnifaces 2.6.1. But right when I add the omnifaces jar to the application classpath (/lib) this one fails at start up, giving the next exception:

13:21:52,024 SEVERE [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 78) Critical error during deployment: : com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:457)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:237)
at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)
at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:200)
at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:171)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:234)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
    Caused by: java.lang.UnsupportedOperationException
at javax.faces.application.Application.getSearchExpressionHandler(Application.java:2001)
at javax.faces.application.ApplicationWrapper.getSearchExpressionHandler(ApplicationWrapper.java:815)
at com.sun.faces.config.processor.ApplicationConfigProcessor.setSearchExpressionHandler(ApplicationConfigProcessor.java:738)
at com.sun.faces.config.processor.ApplicationConfigProcessor.process(ApplicationConfigProcessor.java:382)
at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:155)
at com.sun.faces.config.processor.LifecycleConfigProcessor.process(LifecycleConfigProcessor.java:138)
at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:155)
at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:246)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:443)
... 21 more
    13:21:52,031 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 78) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./: java.lang.RuntimeException: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
    Caused by: java.lang.RuntimeException: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:236)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
... 6 more
    Caused by: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:315)
at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)
at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:200)
at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:171)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:234)
... 8 more
    Caused by: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:457)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:237)
... 20 more
    Caused by: java.lang.UnsupportedOperationException
at javax.faces.application.Application.getSearchExpressionHandler(Application.java:2001)
at javax.faces.application.ApplicationWrapper.getSearchExpressionHandler(ApplicationWrapper.java:815)
at com.sun.faces.config.processor.ApplicationConfigProcessor.setSearchExpressionHandler(ApplicationConfigProcessor.java:738)
at com.sun.faces.config.processor.ApplicationConfigProcessor.process(ApplicationConfigProcessor.java:382)
at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:155)
at com.sun.faces.config.processor.LifecycleConfigProcessor.process(LifecycleConfigProcessor.java:138)
at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:155)
at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:246)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:443)
... 21 more

    13:21:52,059 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 2) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "processmanagement-1.0-SNAPSHOT")]) - failure description: {
"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./: java.lang.RuntimeException: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
    Caused by: java.lang.RuntimeException: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
    Caused by: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
    Caused by: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
    Caused by: java.lang.UnsupportedOperationException"},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.undertow.deployment.default-server.default-host./"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined}
    13:21:52,066 ERROR [org.jboss.as.server] (management-handler-thread - 2) WFLYSRV0021: Deploy of deployment "processmanagement-1.0-SNAPSHOT.war" was rolled back with the following failure message: 
    {"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./: java.lang.RuntimeException: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
Caused by: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
Caused by: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
Caused by: java.lang.UnsupportedOperationException"},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.undertow.deployment.default-server.default-host./"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined}

The stack trace show that the method javax.faces.application.Application.getSearchExpressionHandler is entering inside the 'else' block

    public SearchExpressionHandler getSearchExpressionHandler() {

    if (defaultApplication != null) {
        return defaultApplication.getSearchExpressionHandler();
    } else {
        throw new UnsupportedOperationException();
    }

    }

Which obviously means defaultApplicatoin is null. Any reason why? Am I missing any important configuration for omnifaces 2.6.1/jsf 2.3?

Thanks in advance!

1条回答
对你真心纯属浪费
2楼-- · 2019-04-12 14:00

This is a bug in WildFly. I've already reported it: http://issues.jboss.org/browse/WFLY-8815.

To the point, its builtin WeldApplication has hardcoded JSF 2.2 dependencies. It should actually have extended from JSF javax.faces.application.ApplicationWrapper which has all default delegate methods already predefined such as getSearchExpressionHandler(), but the JSF 2.2-tied WeldApplication didn't have that one and hence the exception you faced.

OmniFaces wasn't at fault, it was just a trigger. You would have faced exactly the same problem with any other JSF-targeted library having a custom javax.faces.application.Application implementation.

If downgrading JSF back to 2.2 is not an option, and you don't have patience to wait for WildFly guys to get it fixed, then you could as below modify WildFly fix its broken WeldApplication.

  1. Find source code of org.jboss.as.jsf.injection.weld.WeldApplication (note: thus not org.jboss.weld.environment.servlet.jsf.WeldApplication which indeed has this bug already fixed! That's only for things like Tomcat).

  2. Adjust class signature from

    public class WeldApplication extends ForwardingApplication {
    

    to

    public class WeldApplication extends ApplicationWrapper {
    
  3. Replace 1st line in constructor

    this.application = application;
    

    by

    super(application);
    
  4. Remove this method

    @Override
    protected Application delegate() {
        init();
        return application;
    }
    
  5. Replace two occurrences of

    application.getExpressionFactory()
    

    by

    getWrapped().getExpressionFactory()
    
  6. Compile it, you will get two classes: WeldApplication.class and WeldApplication$AdjustableELResolver.class.

  7. Go to /modules/system/layers/base/org/jboss/as/jsf-injection/main folder of your WildFly installation.

  8. Unzip wildfly-jsf-injection-10.1.0.Final.jar there.

  9. Browse and remove all three WeldApplication***.class files in /org/jboss/as/jsf/injection/weld subfolder of the unzipped JAR, and put the two newly compiled files in there.

  10. Rezip the folder into a new wildfly-jsf-injection-10.1.0.Final.jar, overriding the old one.

  11. Profit.

查看更多
登录 后发表回答