Why is WildFly 10 + JSF 2.3 not working with Omnifaces 2.6.1?

你离开我真会死。 提交于 2019-12-04 11:57:01

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!