【问题标题】:Class org.springframework.web.jsf.el.SpringBeanFacesELResolver must extend the type javax.el.ELResolverorg.springframework.web.jsf.el.SpringBeanFacesELResolver 类必须扩展 javax.el.E​​LResolver 类型
【发布时间】:2010-11-15 02:53:35
【问题描述】:

我正在尝试将 Spring 集成到 JSF 应用程序中。

faces-config.xml 中,我包含了这个:

<application>       
  <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
  <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
</application>

但它显示了一个我无法摆脱的奇怪警告:

Class org.springframework.web.jsf.el.SpringBeanFacesELResolver must extend the type javax.el.ELResolver

有什么想法吗?

【问题讨论】:

    标签: spring jsf el facelets


    【解决方案1】:

    spring documentation,您将看到 org.springframework.web.jsf.el.SpringBeanFacesELResolver:

    委托给 Spring 的“业务上下文”WebApplicationContext 首先,然后到底层 JSF 的默认解析器 实施

    对于 org.springframework.web.jsf.DelegatingVariableResolver:

    将首先将值查找委托给 底层 JSF 实现,然后到 Spring 的“业务上下文” WebApplicationContext

    如您所见,行为非常不同。如果您不关心顺序,那很好,但如果您确实打算使用 org.springframework.web.jsf.el.SpringBeanFacesELResolver 那么您所要做的就是确保您的 el-api.jar 的版本依赖项与您的 spring 版本兼容。对我来说,我有这个(在我的 maven pom 中):

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>3.0.5.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>el-api</artifactId>
        <version>6.0.32</version>
        <type>jar</type>
        <scope>provided</scope>
    </dependency>
    

    【讨论】:

      【解决方案2】:

      这可能是 ClassLoader 配置问题。如果 SpringBeanFacesELResolver 的父类与执行引导的 JSF 类使用的 ClassLoader 不同,则检查它是否是 ELResolver 的实例将失败。

      如果您在全局类路径中有 META-INF/faces-config.xml,则可能会发生此类问题,但我想可能还有其他原因。

      如果您发布有关您正在使用的容器、应用程序的类加载器策略以及您放置任何第三方库(例如 Facelets 和 Spring 库)的位置的信息,将会有所帮助。

      【讨论】:

        【解决方案3】:

        要解决此类问题,您应该使用javax prefix 扩展项目,因为Class ELResolverabstract classjavax.el package 下的一个abstract class

        代码如下:

            <application>
              <javax.el-resolver>
                org.springframework.web.jsf.el.SpringBeanFacesELResolver
              </javax.el-resolver>      
            </application>
        

        您可以通过link获取有关 ELResolver 类的更多信息。

        【讨论】:

          【解决方案4】:

          配置您的项目方面。使用本地服务器运行

          【讨论】:

            【解决方案5】:

            请检查您在应用程序中使用的 JAR 文件。再次在应用程序中设置类路径。我认为这是因为应用程序类路径中的类冲突。

            【讨论】:

              【解决方案6】:

              我的问题消失了,用以下几行代替:

              <!-- variable/property resolver registration -->
                  <application>
                      <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
                      <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
                  </application>
              

              希望对你有帮助!

              【讨论】:

                【解决方案7】:

                感谢#saadi90,来自mvnrepository.com 我找到了这个并解决了问题:

                <dependency>
                   <groupId>org.glassfish.web</groupId>
                   <artifactId>el-impl</artifactId>
                   <version>2.2</version>
                </dependency>
                

                【讨论】:

                  【解决方案8】:

                  您需要 el-impl 依赖项

                  【讨论】:

                    猜你喜欢
                    • 1970-01-01
                    • 1970-01-01
                    • 2021-04-07
                    • 1970-01-01
                    • 2018-05-24
                    • 2019-05-18
                    • 1970-01-01
                    • 1970-01-01
                    • 2023-03-10
                    相关资源
                    最近更新 更多