Dúvida em configuração Hibernate+Spring+JSF

4 respostas
superpri

O erro que acontece na minha aplicação é o seguinte: javax.servlet.ServletException: ${wizardBean.next}: javax.el.PropertyNotFoundException: /jsp/start.xhtml @16,62 action="${wizardBean.next}": Target Unreachable, identifier ‘wizardBean’ resolved to null.
Isso, pra mim, diz que não existe mapeamento pro WizardBean.
Estou usando Spring IoC com annotations. Dessa forma, meu WizardBean tem um @Controller(“wizardBean”).

Eu acredito que a configuração está correta (os arquivos estão todos abaixo), mas eu acho que a aplicação está com os beans controlados pelo JSF e não pelo Spring. Então a aplicação procura um mapeamento no faces-config.xml. Como esse mapeamento não existe, o erro levanta.

Alguém pode, por favor, me apontar o que está errado/faltando na minha configuração?

applicationContext.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
		http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context
		http://www.springframework.org/schema/context/spring-context-2.5.xsd">

	<context:annotation-config />

	<context:component-scan base-package="br.com.sistemas.saque.dao">
		<context:include-filter type="annotation"
			expression="org.springframework.stereotype.Repository" />
	</context:component-scan>

	<context:component-scan base-package="br.com.sistemas.saque.service">
		<context:include-filter type="annotation"
			expression="org.springframework.stereotype.Service" />
	</context:component-scan>

	<context:component-scan base-package="br.com.sistemas.saque.controller">
		<context:include-filter type="annotation"
			expression="org.springframework.stereotype.Controller" />
	</context:component-scan>

</beans>

faces-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
	<application>
		<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
		<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
	</application>
</faces-config>

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
	<description>Sistema Saque - beta java version</description>
	<display-name>Sistema Saque</display-name>
	
	<context-param>
		<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
		<param-value>.xhtml</param-value>
	</context-param>

	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/applicationContext.xml</param-value>
		<param-value>/WEB-INF/persistence.xml</param-value>
	</context-param>

	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener
		</listener-class>
	</listener>
	
	<listener>
		<listener-class>
			org.springframework.web.context.request.RequestContextListener
		</listener-class>
	</listener>

	<filter>
		<display-name>Ajax4jsf Filter</display-name>
		<filter-name>ajax4jsf</filter-name>
		<filter-class>org.ajax4jsf.Filter</filter-class>
	</filter>
	
	<filter-mapping>
		<filter-name>ajax4jsf</filter-name>
		<servlet-name>Faces Servlet</servlet-name>
		<dispatcher>REQUEST</dispatcher>
		<dispatcher>FORWARD</dispatcher>
		<dispatcher>INCLUDE</dispatcher>
	</filter-mapping>

	<servlet>
		<servlet-name>Faces Servlet</servlet-name>
		<servlet-class>javax.faces.webapp.FacesServlet
		</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<servlet-mapping>
		<servlet-name>Faces Servlet</servlet-name>
		<url-pattern>*.jsf</url-pattern>
	</servlet-mapping>
	
</web-app>

4 Respostas

mgarcia

já tentou usar #{wizardBean.next}?

superpri

sim, já tentei usar #{wizardBean.next} quanto ${wizardBean.next} no meu xhtml.
o erro continua subindo.

lucianotome

Não sei se isso vai resolver seu problema, mas tenta colocar default-autowire="byName" na tag <beans

No meu caso fica assim:

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd" default-autowire="byName" default-lazy-init="false">

superpri

coloquei o default-autowire no beans, mas o erro continua levantando… :frowning:

Criado 17 de fevereiro de 2010
Ultima resposta 18 de fev. de 2010
Respostas 4
Participantes 3