Problema na injeção do EntityManager

Não estou conseguindo usar a injeção de EntityManager e o OpenEntityManagerInViewFilter do Spring.
Ja estou a 3 dias tentando e nada :cry:

Onde eu to errando aqui ? :?

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>Fusion</display-name>
  
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>home.xhtml</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  
  <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>*.xhtml</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>
  
  <context-param>  
    <param-name>primefaces.skin</param-name>  
    <param-value>none</param-value>  
  </context-param>
  
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  
  <filter>
    <filter-name>OpenEntityManagerInViewFilter</filter-name>
    <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>OpenEntityManagerInViewFilter</filter-name>
    <url-pattern>*.xhtml</url-pattern>
  </filter-mapping>

</web-app>

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:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
					       http://www.springframework.org/schema/beans/spring-beans-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">
		
		<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
		
		<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"/>
		
		<bean class="org.springframework.orm.jpa.JpaTransactionManager">
		  <property name="entityManagerFactory" ref="entityManagerFactory"/>
		</bean>

</beans>

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  <persistence-unit name="fusionnet" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    
    <properties>
      <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/as"/>
      <property name="javax.persistence.jdbc.user" value="root"/>
      <property name="javax.persistence.jdbc.password" value=""/>
      
      <property name="hibernate.hbm2ddl.auto" value="update"/>
      <property name="hibernate.show_sql" value="true" />
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
    </properties>
    
  </persistence-unit>
</persistence>

DAO.java

public class DAO<T> {
	
	private final Class<T> classe;
	@PersistenceContext
	private EntityManager em;
	
	public DAO(Class<T> classe) {
		this.classe = classe;
	}

	public void add(T t) {
		
		em.persist(t);
		
	}

	public void delete(T t) {
		
		em.remove(em.merge(t));
		
	}

	public void update(T t) {
		
		em.merge(t);
		
	}

	public List<T> listAll() {
		
		CriteriaQuery<T> query = em.getCriteriaBuilder().createQuery(classe);
		query.select(query.from(classe));
		List<T> lista = em.createQuery(query).getResultList();
		
		return lista;
	
	}
			
}

Erro ao chamar qualquer metodo do DAO (Neste caso eu chamei o listAll())

Oct 18, 2010 11:46:02 PM com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
SEVERE: Error Rendering View[/cadastro.xhtml]
javax.el.ELException: /cadastro.xhtml @57,107 value="#{ufBean.ufs}": Error reading 'ufs' on type br.com.fusionnet.mb.UfBean
	at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111)
	at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190)
	at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178)
	at javax.faces.component.UISelectItems.getValue(UISelectItems.java:125)
	at com.sun.faces.renderkit.SelectItemsIterator.initializeItems(SelectItemsIterator.java:198)
	at com.sun.faces.renderkit.SelectItemsIterator.hasNext(SelectItemsIterator.java:131)
	at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOptions(MenuRenderer.java:758)
	at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:840)
	at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:294)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879)
	at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:308)
	at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:181)
	at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:125)
	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643)
	at javax.faces.render.Renderer.encodeChildren(Renderer.java:164)
	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:389)
	at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:127)
	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:309)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
	at br.com.fusionnet.dao.DAO.listAll(DAO.java:44)
	at br.com.fusionnet.mb.UfBean.getUfs(UfBean.java:31)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
	at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
	at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:71)
	at org.apache.el.parser.AstValue.getValue(AstValue.java:123)
	at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
	at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:106)
	... 41 more
Oct 18, 2010 11:46:02 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
java.lang.NullPointerException
	at br.com.fusionnet.dao.DAO.listAll(DAO.java:44)
	at br.com.fusionnet.mb.UfBean.getUfs(UfBean.java:31)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
	at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
	at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:71)
	at org.apache.el.parser.AstValue.getValue(AstValue.java:123)
	at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
	at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:106)
	at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190)
	at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178)
	at javax.faces.component.UISelectItems.getValue(UISelectItems.java:125)
	at com.sun.faces.renderkit.SelectItemsIterator.initializeItems(SelectItemsIterator.java:198)
	at com.sun.faces.renderkit.SelectItemsIterator.hasNext(SelectItemsIterator.java:131)
	at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOptions(MenuRenderer.java:758)
	at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:840)
	at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:294)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879)
	at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:308)
	at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:181)
	at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:125)
	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643)
	at javax.faces.render.Renderer.encodeChildren(Renderer.java:164)
	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:389)
	at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:127)
	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:309)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	at java.lang.Thread.run(Thread.java:619)

Esqueci de especificar que estou usando Jsf 2 e Spring 3.

:?:

tente colocar isso no seu web.xml:

       &lt;listener&gt;
		&lt;listener-class&gt;
			org.springframework.web.context.request.RequestContextListener
		&lt;/listener-class&gt;
	&lt;/listener&gt;

e no appContext:

	&lt;!-- Classe responsável pela gestão das entidades  --&gt;
	&lt;bean id="entityManagerFactory"
		 class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"&gt;
		&lt;property name="persistenceUnitName" value="fusionnet" /&gt;
	&lt;/bean&gt;

E ai Pablouu.

Eu tentei fazer isso que me mostrou, mas continuou com o mesmo erro, até tentei tirar o trecho do org.springframework.web.context.ContextLoaderListener

Mas mesmo assim, o erro continua :?

Não consegui muita ajuda aqui nesse forúm, mas obrigado para quem tentou ajudar.

Consegui resolver utilizando filtros.