Spring 3 + Spring MVC + Hibernate

Olá galera, estou com um probleminha no @AutoWired
Bom eu tenho a seguinte 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:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"  
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd  ">
    
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
        <property name="locations">  
            <list>  
                <value>classpath:/db.properties</value>  
            </list>  
        </property>  
    </bean>

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${database.driver}" />
        <property name="url" value="${database.url}" />
        <property name="username" value="${database.user}" />
        <property name="password" value="${database.pass}" />
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="packagesToScan" value="${database.baseModel}" />
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${database.dialect}</prop>
                <prop key="hibernate.show_sql">${database.show_sql}</prop>
                <prop key="hibernate.hbm2ddl.auto">${database.hbm2ddl}</prop>
            </props>
        </property>
    </bean>
    
    <tx:annotation-driven />
    
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

    <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /> 

        <context:component-scan base-package="*"/>  
</beans>

dispatcher-servlet.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:p="http://www.springframework.org/schema/p"
	    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
	    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">

    <mvc:resources mapping="/js/**" location="/js/" />

    <context:component-scan base-package="br.com.projgado.controller" />

    <mvc:annotation-driven />

    <bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"
          p:prefix="/WEB-INF/jsp/"
          p:suffix=".jsp" /> 


</beans>

Bom, quando eu tento iniciar um dao automaticamente com o @AutoWired, ele me retorna esse erro …

GRAVE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'indexController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: public br.com.projgado.DAO.impl.PessoaDaoImpl br.com.projgado.controller.IndexController.dao; nested exception is java.lang.IllegalArgumentException: Can not set br.com.projgado.DAO.impl.PessoaDaoImpl field br.com.projgado.controller.IndexController.dao to $Proxy31
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:377)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:278)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4681)
	at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5184)
	at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5179)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: public br.com.projgado.DAO.impl.PessoaDaoImpl br.com.projgado.controller.IndexController.dao; nested exception is java.lang.IllegalArgumentException: Can not set br.com.projgado.DAO.impl.PessoaDaoImpl field br.com.projgado.controller.IndexController.dao to $Proxy31
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:504)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
	... 21 more
Caused by: java.lang.IllegalArgumentException: Can not set br.com.projgado.DAO.impl.PessoaDaoImpl field br.com.projgado.controller.IndexController.dao to $Proxy31
	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
	at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
	at java.lang.reflect.Field.set(Field.java:657)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:500)
	... 23 more
31/10/2011 22:28:47 org.apache.catalina.core.StandardContext startInternal
GRAVE: Error listenerStart

Meu DAO

package br.com.projgado.DAO;


import java.io.Serializable;
import java.util.List;
import java.lang.reflect.ParameterizedType;

import org.hibernate.Query;  
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository("dao")
public abstract class HibernateDAO<T, ID extends Serializable> implements GenericDAO<T, ID> {

        @Autowired
	private SessionFactory sessionFactory;

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	private final Class<T> oClass;

	@SuppressWarnings("unchecked")
	public HibernateDAO() {
		this.oClass = (Class<T>) ((ParameterizedType) (getClass()
				.getGenericSuperclass())).getActualTypeArguments()[0];

	}

	@Override
	public Class<T> getObjectClass() {
		return this.oClass;
	}

	@Transactional
	@Override
	public void salvarOuAtualizar(T obj) {
		sessionFactory.getCurrentSession().saveOrUpdate(obj);

	}

	@Transactional
	@Override
	public void excluir(T obj) {
		sessionFactory.getCurrentSession().delete(obj);

	}

	@SuppressWarnings("unchecked")
	@Transactional(readOnly = true)
	@Override
	public T bucarPorId(Integer id) {
		return (T) sessionFactory.getCurrentSession().get(oClass, id);
	}

	@SuppressWarnings("unchecked")
	@Transactional(readOnly = true)
	@Override
	public List<T> buscarTodos() {
		Query q = sessionFactory.getCurrentSession().createQuery(
				"from " + oClass.getName());
		return q.list();
	}
}

e no Controller do Spring framework tento usalo …

package br.com.projgado.controller;

import br.com.projgado.DAO.impl.PessoaDaoImpl;
import br.com.projgado.model.Pessoa;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class IndexController {

    //Aqui está meu problema ... Com esta annotation da o erro que coloquei acima, e sem ela não tenho o erro ... 
    @Autowired
    public PessoaDaoImpl dao;
    
    @RequestMapping(value = "/index")
    public ModelAndView lista() {
        
        Pessoa p = new Pessoa();
               p.setEmail("teste");
               p.setNascimento(new Date());
               p.setNome("Fabio");
        
        
        
        return new ModelAndView("/index", "indexInfo", "teste");
    }
    
}

Alguém consegue me ajudar ? Já quebre a cabeça e não acho o erro …
Acredito que os arquivos que postei sao suficientes …

Olá wakko, serei sincero, encontrei muitos panes como essa quando usava spring, sei que vc deve estar procurando uma resposta precisa e imediata (pois eu sempre estava correndo atrás disso), porém ao utilizar JSF2 que possui injeção de dependências entre outras muitas utilidades confesso que me aposentei de vez com o Spring… desde então minha vida foi muito melhor !!! :smiley:

Apenas alguma considerações,
Não eh o JSF2 que possui a injeção de dependecia, e sim o CDI.

O principal motivo para usar injecao de dependencia é diminuir o acoplamento ente as classes, injetando uma um objeto que implemente uma interface.
Pelo que vi, vc esta injetando a implementação diretamente… deixando pouco flexivel

@Autowired
public PessoaDaoImpl dao;

Pra mim, da no mesmo que nao usar injeção.

voce deveria injetar apenas o DAO, possibilitando a mudança para qualquer outro dao de forma flexivel.

Acho que temos que pensar antes de sair consumido essa tecnologia toda.

espero ter ajudado um pouco…

Então tente separá-los… Como não é necessário explicar várias outras tecnologias que já vem embutidas dentro do JSF2…
Um abra

Obs, não sou contra JSF, pelo contrário, gosto muito!

Não eh uma questão de tentar, eles já são separados!

JSF é uma coisa Injeção de Dependencia é outra coisa. Separadas.
:slight_smile: nao confunda as bolas ora bolas.
:slight_smile:

Gosto muito do Spring TB. acho o esquema de DI melhor que o do CDI.
Estou experimentandto o Wicket 1.5.2, estou gostanod muito da experiencia. - Vide Bruno Borges…

Recomendo…

Não caia na besteira de se apaixonar pelo framework…
abraço.

Concordo, tb não sou apaixonado por nenhum framework, mas de todos eles acho o Spring pesado, complicado e desnecessário na grande maioria dos casos (substituível por outros mais simples/leves ou até mesmo um engodo). Apenas saliento que se puder simplificar sem a utilização do Spring é um bom começo. Pergunte-se, para que e por quê estou utilizando o Spring ? Se realmente for necessário e insubstituível, utilize-o…

E a sua classe PessoaDaoImpl, anotou ela como Repository ?
Lembre-se que no seu controler está tentando injetar a classe PessoaDaoImpl e não HibernateDAO.

Sim …

package br.com.projgado.DAO.impl;

import br.com.projgado.DAO.HibernateDAO;
import br.com.projgado.DAO.PessoaDao;
import java.io.Serializable;
import org.springframework.stereotype.Repository;

@Repository
public class PessoaDaoImpl extends HibernateDAO<Object, Serializable> implements PessoaDao {

    
}

Bom, aparentemente então não deveria dar erro.
A única coisa estranho que vejo é que você usa no applicationContext.xml e dispatcher-servlet.xml a tag: &lt;context:component-scan base-package="" /&gt;

Talvez o spring não esteja encontrando as anotações fora do pacote controller. Não precisa fazer assim como você fez, adicione apenas no arquivo applicationContext.xml:

Outra coisa, no controller troque

@Autowired public PessoaDaoImpl dao;
por

@Autowired  
private PessoaDaoImpl dao; 

Cara realmente era isso do …

<context:component-scan base-package="br.com.projgado" />

Muito obrigado …

Agora quando eu recupero o dao e tento salvar um objeto ele me retorna este erro …
Por exemplo meu salva está anotado com @Transactional, e o erro ate onde entendi é que para executar esta operação, ela deve ser isolada por uma transaction … Correto ?

Preciso configurar este @Transactional de alguma maneira ?

GRAVE: Servlet.service() for servlet [dispatcher] in context with path [/projGado] threw exception [Request processing failed; nested exception is org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here] with root cause
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
	at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:64)
	at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:544)
	at br.com.projgado.DAO.HibernateDAO.salvarOuAtualizar(HibernateDAO.java:39)
	at br.com.projgado.controller.IndexController.lista(IndexController.java:29)
	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 org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:185)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:100)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:502)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:465)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:863)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:851)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:756)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)

EDIT …
Adicionei a linha “thread” a configuração do hibernate e agora tenho esse erro

GRAVE: Servlet.service() for servlet [dispatcher] in context with path [/projGado] threw exception [Request processing failed; nested exception is org.hibernate.HibernateException: saveOrUpdate is not valid without active transaction] with root cause
org.hibernate.HibernateException: saveOrUpdate is not valid without active transaction
	at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:297)
	at $Proxy32.saveOrUpdate(Unknown Source)
	at br.com.projgado.DAO.HibernateDAO.salvarOuAtualizar(HibernateDAO.java:39)
	at br.com.projgado.controller.IndexController.lista(IndexController.java:29)
	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 org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:185)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:100)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:502)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:465)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:863)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:851)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:756)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)

transacione o teu metodo salvarOuAtualizar com

@Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
salvarOuAtualizar(xyz)

Não resolveu … continua dando ERRO …

org.hibernate.HibernateException: saveOrUpdate is not valid without active transaction at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:297) at $Proxy45.saveOrUpdate(Unknown Source) at br.com.projgado.DAO.HibernateDAO.save(HibernateDAO.java:41) at br.com.projgado.controller.IndexController.lista(IndexController.java:30) 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 org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:185) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:100) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:502) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:465) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:863) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:851) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:756) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662)

Pessoal, estou com o mesmo problema.
Alguem conseguiu resolver ?

wakko
Conseguiu resolver ?