Hibernate + Spring MVC + JSF 2.0

0 respostas
by_stoco

Salve a todos!

Estou iniciando uma nova aplicação e estou querendo trabalhar com essas 3 tecnologias: Hibernate + Spring MVC + JSF 2.0

Porém eu acho que está faltando alguma configuração, pois o Spring MVC e JSF não estão funcionando juntos.
A requisição Spring no controler, não renderiza os componentes JSF.

Segue os arquivos de configuração:

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	id="WebApp_ID" version="2.5">
	<display-name>IETAV</display-name>
	
	<context-param>
		<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
		<param-value>.xhtml</param-value>
	</context-param>
	<context-param>
		<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
		<param-value>true</param-value>
	</context-param>
	
	<context-param>
		<param-name>contextConfigLocation</param-name>
			<param-value>
				/WEB-INF/config/app-config.xml
			</param-value>
	</context-param>
	
	<listener>
		<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
	</listener>
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<servlet>
		<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>
				/WEB-INF/config/app-config.xml
			</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
		<url-pattern>*.jsp</url-pattern>
	</servlet-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>*.faces</url-pattern>
	</servlet-mapping>

	<servlet>
		<servlet-name>Resource Servlet</servlet-name>
		<servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>Resource Servlet</servlet-name>
		<url-pattern>/primefaces_resource/*</url-pattern>
	</servlet-mapping>

	<welcome-file-list>
		<welcome-file>index.xhtml</welcome-file>
		<welcome-file>index.html</welcome-file>
		<welcome-file>index.htm</welcome-file>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>
</web-app>

e o app-config.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"
	xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:sec="http://www.springframework.org/schema/security"
	xsi:schemaLocation="
		http://www.springframework.org/schema/beans	http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
		http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
	    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
	    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
	    http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
	    
	<context:component-scan base-package="br.com.ietav.cadeconcursos" />
	<mvc:annotation-driven/>
	<context:annotation-config />
	    
	 
	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<!-- <property name="viewClass" value="org.springframework.faces.mvc.JsfView" / -->
		<property name="prefix" value="/WEB-INF/views/" />
		<property name="suffix" value=".xhtml" />
	</bean>
	
	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.connection.url">jdbc:mysql://localhost/cadeconcursos_desenv</prop>
				<prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
				<prop key="hibernate.connection.username">root</prop>
				<prop key="hibernate.connection.password"></prop>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.format_sql">true</prop>
				<prop key="hibernate.hbm2ddl">create-drop</prop>
			</props>
		</property>
		<property name="annotatedClasses">
			<list>
				<value>br.com.ietav.cadeconcursos.entity.Curso</value>
				<value>br.com.ietav.cadeconcursos.entity.CursoModulo</value>
				<value>br.com.ietav.cadeconcursos.entity.GrauEscolar</value>
				<value>br.com.ietav.cadeconcursos.entity.Modulo</value>
				<value>br.com.ietav.cadeconcursos.entity.NivelCurso</value>
				<value>br.com.ietav.cadeconcursos.entity.PerfilAcesso</value>
				<value>br.com.ietav.cadeconcursos.entity.Professor</value>
				<value>br.com.ietav.cadeconcursos.entity.Tipo</value>
				<value>br.com.ietav.cadeconcursos.entity.Usuario</value>
			</list>
		</property>
	
	</bean>
	
	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
	
	<tx:annotation-driven/>
	
	<bean id="template" class="org.springframework.orm.hibernate3.HibernateTemplate" autowire="byType" />
		
</beans>

faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>

<faces-config version="2.0" xmlns="http://java.sum.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_2_0.xsd">

	<application>

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

	</application>


</faces-config>

Alguem sabe me dizer o que está errado???

Vlw

Criado 28 de fevereiro de 2011
Respostas 0
Participantes 1