I met a problem when injecting spring bean into jsf bean, which causes javax.faces.FacesException(Can't instantiate class), javax.faces.el.EvaluationException
Here is my xml files:
File WEB-INF/components.xml defines spring beans
<beans>
<bean id="rambo.api.VideoService"
class="rambo.impl.VideoServiceImpl">
<!-- some properties ... -->
</bean>
</beans>
File WEB-INF/faces-config.xml define jsf beans
<managed-bean>
<description>Video Home Bean</description>
<managed-bean-name>videoBean</managed-bean-name>
<managed-bean-class>rambo.tool.VideoBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<description>videoService</description>
<property-name>videoService</property-name>
<value>#{Components["rambo.api.VideoService"]}</value>
</managed-property>
<!-- Other properties -->
</managed-bean>
File videoMain.jsp:
In resourceToolExists: the videoBean uses some methods of videoService
<h:panelGroup rendered="#{! videoBean.resourceToolExists" >
<%@ include file="videoNoResource.jsp" %>
</h:panelGroup>
Here gets: javax.faces.FacesException(Can't instantiate class rambo.impl.VideoServiceImpl), javax.faces.el.EvaluationException
You need to config a spring elresolver in you faces-config.xml file. The spring elresolver will evaluate your el express and acquire the bean object defined in spring Please check http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/web/jsf/el/SpringBeanFacesELResolver.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.