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

∥☆過路亽.° 提交于 2020-01-01 08:35:14

问题


I am trying to integrate Spring into a JSF application.

In faces-config.xml, I have included this:

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

but it shows a weird warning which I can't get rid of:

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

Any ideas?


回答1:


From the spring documentation, you will see that for org.springframework.web.jsf.el.SpringBeanFacesELResolver:

delegates to the Spring's 'business context' WebApplicationContext first, then to the default resolver of the underlying JSF implementation

and for org.springframework.web.jsf.DelegatingVariableResolver:

will first delegate value lookups to the default resolver of the underlying JSF implementation and then to Spring's 'business context' WebApplicationContext

As you can see, the behavior is very different. If you don't care about order, you are fine, but if you actually did intend to use org.springframework.web.jsf.el.SpringBeanFacesELResolver then all you have to do is ensure the version of el-api.jar in your dependencies is compatible with your version of spring. For me, I have this (in my 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:


To solve this type of problem you should extend project with javax prefix because Class ELResolver is an abstract class under javax.el package.

Here is code:

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

More information about ELResolver class you can get by link.




回答3:


This is possibly a ClassLoader configuration issue. If the SpringBeanFacesELResolver's parent class is from a different ClassLoader to the one used by the JSF classes doing the bootstrapping, the check to see if it is an instance of ELResolver will fail.

Problems like this can happen if you have a META-INF/faces-config.xml in the global classpath, but I suppose there could be other causes.

It would help if you posted information on what container you are using, the classloader policy for your application and where you've placed any third party libraries (such as the Facelets and Spring libs).




回答4:


Configure your Project facets. For run with your local server




回答5:


Please check the JAR files you are using in application. Again the class paths set in application. I think it is because of the class conflicts in application class paths.




回答6:


Well my problem disappeared substituting these lines by:

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

hope it helps!




回答7:


Thanks #saadi90, from mvnrepository.com I found this and it solved the problem:

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



回答8:


You need the el-impl dependency



来源:https://stackoverflow.com/questions/1201021/class-org-springframework-web-jsf-el-springbeanfaceselresolver-must-extend-the-t

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