Vraptor + Spring + Hibernate

13 respostas
W

Bom dia a todos, estou com o seguinte problema: Quando vou salvar / Editar / Remover algum "Produto" ele não faz o comite e então não faz nada. Meu DAO esta assim:

@Component
public class HibernateProdutoDao implements ProdutoDao {

	private Session session;

	public HibernateProdutoDao(Session session) {
		this.session = session;
	}

	@Transactional
	public void salva(Produto produto) {
		session.save(produto);
	}

	@Transactional
	public void remover(Produto produto) {
		session.delete(produto);
	}

	@Transactional
	public void atualizar(Produto produto) {
		session.update(produto);
	}

	@SuppressWarnings("unchecked")
	public List<Produto> listaTudo() {
		return this.session.createCriteria(Produto.class).list();
	}

	public Produto carrega(Long id) {
		return (Produto) this.session.load(Produto.class, id);
	}
Meu arquivo de Session esta assim:
@Component
public class CriadorDeSession implements ComponentFactory<Session> {

	private final SessionFactory factory;
	private Session session;
	private final Proxifier proxifier;

	public CriadorDeSession(SessionFactory factory, Proxifier proxifier) {
		this.factory = factory;
		this.proxifier = proxifier;
	}

	@PostConstruct
	public void open() {
		System.out.println("Enter open Session");
		this.session = proxifier.proxify(Session.class,
				new MethodInvocation<Session>() {
					public Object intercept(Session proxy, Method method,
							Object[] args, SuperMethod superMethod) {
						Session sessionDoSpring = SessionFactoryUtils
								.doGetSession(factory, true);
						return new Mirror().on(sessionDoSpring).invoke()
								.method(method).withArgs(args);
					}
				});

	}

	public Session getInstance() {
		return this.session;
	}

	@PreDestroy
	public void close() {
		System.out.println("Enter close Session");
		this.session.close();

	}

}

O problema é que não aparece nenhum erro no console. A única coisa que aparece são os SQL do hibernate como se estive tudo feito com sucesso.

13 Respostas

G

Precisa melhorar o log cara. Dê uma olhada no log4j

W

O que tem haver o log4J com isso?

Eu debuguei e ele entra nos metodo
@Transactional  
    public void salva(Produto produto) {  
        session.save(produto);  
    }  
  
    @Transactional  
    public void remover(Produto produto) {  
        session.delete(produto);  
    }  
  
    @Transactional  
    public void atualizar(Produto produto) {  
        session.update(produto);  
    }

Inclusive o objeto produto vem correto também, para poder excluir / atualizar ou cadastrar... Só que me parece que o session.update / session.delete / session.save não faz o commite!!!

C

Algum motivo para usar o @Transactional?

W

Estou fazendo o exemplo da apostila FJ28. E gostaria que funcionasse da maneira que esta lá…

As unicas coisas que não esta funcionando com o Transaction é o delete e o editar, o inserir esta funcionando normalmente.

G

wellington fernandes da s:
O que tem haver o log4J com isso?

isso:

Como você não postou log nenhumnão tem como deduzir nada. Algum problema pode estar sendo camuflado e usando log4j você pode configurar corretamente seu log.

Como está teu web.xml?

L

vc configurou o spring transaction no applicationContext.xml?

W

Nossa eu configurei aqui o LOG4J e já me trouxe algumas coisas que eu não esperava… vou ver se resolvo e depois te falo… Valeu!!

W

Esta ai o Log do erro, esse erro acontece sempre quando eu vou editar ou deletar alguma coisa… Quando eu vou inserir alguma coisa ou listar não dá erro…

19:31:59,964 DEBUG [OpenSessionInViewFilter] Using SessionFactory 'sessionFactory' for OpenSessionInViewFilter
19:31:59,964 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'sessionFactory'
19:31:59,965 DEBUG [OpenSessionInViewFilter] Opening single Hibernate Session in OpenSessionInViewFilter
19:31:59,965 DEBUG [SessionFactoryUtils ] Opening Hibernate Session
19:31:59,965 DEBUG [VRaptor             ] VRaptor received a new request
19:31:59,967 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'br.com.caelum.vraptor.http.EncodingHandlerFactory'
19:31:59,968 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'encodingHandlerFactory'
19:31:59,975 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'enhancedRequestExecution'
19:31:59,976 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultInterceptorStack'
19:31:59,976 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'defaultInterceptorHandlerFactory'
19:31:59,977 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultInterceptorStack'
19:31:59,977 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'topologicalSortedInterceptorRegistry'
19:31:59,977 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'enhancedRequestExecution'
19:31:59,978 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'commonsUploadMultipartInterceptor'
19:31:59,979 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletRequestProvider'
19:31:59,979 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletRequestProvider'
19:31:59,980 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'defaultMultipartConfig'
19:31:59,981 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultValidator'
19:31:59,981 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultResult'
19:31:59,982 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletRequestProvider'
19:31:59,983 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'br.com.caelum.vraptor.ioc.spring.SpringBasedContainer'
19:31:59,984 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultExceptionMapper'
19:31:59,985 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'cglibProxifier'
19:31:59,985 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultExceptionMapper'
19:31:59,985 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'defaultTypeNameExtractor'
19:31:59,985 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultResult'
19:31:59,986 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultValidationViewsFactory'
19:31:59,987 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'cglibProxifier'
19:31:59,987 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultValidationViewsFactory'
19:31:59,988 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'replicatorOutjector'
19:31:59,989 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultMethodInfo'
19:31:59,990 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultMethodInfo'
19:31:59,990 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'paranamerNameProvider'
19:31:59,991 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'replicatorOutjector'
19:31:59,991 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'cglibProxifier'
19:31:59,992 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'JSR303Validator'
19:31:59,992 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'jstlLocalization'
19:31:59,993 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'VRaptorRequestProvider'
19:31:59,993 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'jstlLocalization'
19:31:59,994 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'br.com.caelum.vraptor.validator.JSR303ValidatorFactory'
19:31:59,994 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'JSR303ValidatorFactory'
19:31:59,995 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'br.com.caelum.vraptor.validator.MessageInterpolatorFactory'
19:31:59,996 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'messageInterpolatorFactory'
19:31:59,996 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'JSR303Validator'
19:31:59,997 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultValidator'
19:31:59,997 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultServletFileUploadCreator'
19:31:59,997 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultServletFileUploadCreator'
19:31:59,998 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'commonsUploadMultipartInterceptor'
19:31:59,998 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'resourceLookupInterceptor'
19:31:59,999 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'defaultResourceTranslator'
19:32:00,000 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'defaultResourceNotFoundHandler'
19:32:00,000 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'defaultMethodNotAllowedHandler'
19:32:00,001 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'VRaptorRequestProvider'
19:32:00,001 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'resourceLookupInterceptor'
19:32:00,001 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor ResourceLookupInterceptor
19:32:00,002 DEBUG [DefaultResourceTranslator] trying to access /produtos/remove
19:32:00,002 DEBUG [DefaultResourceTranslator] found resource [DefaultResourceMethod: ProdutosController.removeProdutosController.remove(Long)]
19:32:00,003 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'parametersInstantiatorInterceptor'
19:32:00,004 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'iogiParametersProvider'
19:32:00,004 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'paranamerNameProvider'
19:32:00,005 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletRequestProvider'
19:32:00,006 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'VRaptorInstantiator'
19:32:00,006 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'defaultConverters'
19:32:00,007 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'VRaptorDependencyProvider'
19:32:00,008 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'VRaptorParameterNamesProvider'
19:32:00,008 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'paranamerNameProvider'
19:32:00,009 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'VRaptorParameterNamesProvider'
19:32:00,009 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletRequestProvider'
19:32:00,009 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'VRaptorInstantiator'
19:32:00,010 DEBUG [IogiParametersProvider] IogiParametersProvider is up
19:32:00,010 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'iogiParametersProvider'
19:32:00,012 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletRequestProvider'
19:32:00,012 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'sessionFlashScope'
19:32:00,013 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpSessionProvider'
19:32:00,013 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'sessionFlashScope'
19:32:00,013 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'parametersInstantiatorInterceptor'
19:32:00,014 DEBUG [LazyInterceptorHandler] Invoking interceptor ParametersInstantiatorInterceptor
19:32:00,014 DEBUG [JstlLocalization    ] couldn't find message bundle, creating an empty one
19:32:00,014 DEBUG [ParanamerNameProvider] Found parameter names with paranamer for ProdutosController.remove(Long) as [id]
19:32:00,014 DEBUG [IogiParametersProvider] getParametersFor() called with parameters Parameters(Parameter(id -> 14)) and targets [Target(name=id, type=class java.lang.Long)].
19:32:00,015 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'longConverter'
19:32:00,015 DEBUG [ParametersInstantiatorInterceptor] Parameter values for [DefaultResourceMethod: ProdutosController.removeProdutosController.remove(Long)] are [14]
19:32:00,016 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'exceptionHandlerInterceptor'
19:32:00,017 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletRequestProvider'
19:32:00,018 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'exceptionHandlerInterceptor'
19:32:00,018 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor ExceptionHandlerInterceptor
19:32:00,018 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'instantiateInterceptor'
19:32:00,019 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'br.com.caelum.vraptor.ioc.spring.SpringBasedContainer'
19:32:00,019 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'instantiateInterceptor'
19:32:00,019 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor InstantiateInterceptor
19:32:00,020 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'produtosController'
19:32:00,020 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'hibernateProdutoDao'
19:32:00,021 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'com.caelumfj28.infra.CriadorDeSession'
19:32:00,021 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'criadorDeSession'
19:32:00,022 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'sessionFactory'
19:32:00,023 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'cglibProxifier'
19:32:00,023 DEBUG [CommonAnnotationBeanPostProcessor] Invoking init method on bean 'criadorDeSession': public void com.caelumfj28.infra.CriadorDeSession.open()
Enter open Session
19:32:00,024 DEBUG [CglibProxifier      ] a proxy for interface org.hibernate.Session is created as class org.hibernate.Session$$EnhancerByCGLIB$$bde86ec9
19:32:00,024 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'criadorDeSession'
19:32:00,024 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'hibernateProdutoDao'
19:32:00,025 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'produtosController'
19:32:00,025 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'flashInterceptor'
19:32:00,026 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpSessionProvider'
19:32:00,027 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletResponseProvider'
19:32:00,027 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'flashInterceptor'
19:32:00,027 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor FlashInterceptor
19:32:00,028 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'executeMethodInterceptor'
19:32:00,029 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'executeMethodInterceptor'
19:32:00,029 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor ExecuteMethodInterceptor
19:32:00,029 DEBUG [ExecuteMethodInterceptor] Invoking ProdutosController.remove(Long)
Hibernate: 
    select
        produto0_.id as id2_0_,
        produto0_.descricao as descricao2_0_,
        produto0_.nome as nome2_0_,
        produto0_.preco as preco2_0_ 
    from
        produto produto0_ 
    where
        produto0_.id=?
19:32:00,033 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultLogicResult'
19:32:00,035 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'cglibProxifier'
19:32:00,035 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'defaultRouter'
19:32:00,036 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletRequestProvider'
19:32:00,036 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletResponseProvider'
19:32:00,037 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'br.com.caelum.vraptor.ioc.spring.SpringBasedContainer'
19:32:00,037 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultPathResolver'
19:32:00,038 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultFormatResolver'
19:32:00,038 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletRequestProvider'
19:32:00,038 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'defaultAcceptHeaderToFormat'
19:32:00,038 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultFormatResolver'
19:32:00,039 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultPathResolver'
19:32:00,039 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'defaultTypeNameExtractor'
19:32:00,040 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultLogicResult'
19:32:00,040 DEBUG [DefaultLogicResult  ] redirecting to class ProdutosController
19:32:00,040 DEBUG [CglibProxifier      ] a proxy for class com.caelumfj28.controller.ProdutosController is created as class com.caelumfj28.controller.ProdutosController$$EnhancerByCGLIB$$fd7fe51
19:32:00,041 DEBUG [DefaultLogicResult  ] redirecting to /CursoCaelumF28/produtos/lista
19:32:00,041 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'forwardToDefaultViewInterceptor'
19:32:00,042 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'forwardToDefaultViewInterceptor'
19:32:00,042 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor ForwardToDefaultViewInterceptor
19:32:00,042 DEBUG [ForwardToDefaultViewInterceptor] Request already dispatched and commited somewhere else, not forwarding.
19:32:00,042 DEBUG [CommonAnnotationBeanPostProcessor] Invoking destroy method on bean 'criadorDeSession': public void com.caelumfj28.infra.CriadorDeSession.close()
Enter close Session
19:32:00,042 DEBUG [VRaptor             ] VRaptor ended the request
19:32:00,042 DEBUG [OpenSessionInViewFilter] Closing single Hibernate Session in OpenSessionInViewFilter
19:32:00,042 DEBUG [SessionFactoryUtils ] Closing Hibernate Session
19:32:00,043 DEBUG [SessionFactoryUtils ] Could not close Hibernate Session
org.hibernate.SessionException: Session was already closed
	at org.hibernate.impl.SessionImpl.close(SessionImpl.java:320)
	at org.springframework.orm.hibernate3.SessionFactoryUtils.closeSession(SessionFactoryUtils.java:791)
	at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.closeSession(OpenSessionInViewFilter.java:279)
	at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:208)
	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.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
19:32:00,044 DEBUG [OpenSessionInViewFilter] Using SessionFactory 'sessionFactory' for OpenSessionInViewFilter
19:32:00,044 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'sessionFactory'
19:32:00,044 DEBUG [OpenSessionInViewFilter] Opening single Hibernate Session in OpenSessionInViewFilter
19:32:00,044 DEBUG [SessionFactoryUtils ] Opening Hibernate Session
19:32:00,044 DEBUG [VRaptor             ] VRaptor received a new request
19:32:00,045 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'br.com.caelum.vraptor.http.EncodingHandlerFactory'
19:32:00,045 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'encodingHandlerFactory'
19:32:00,046 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'enhancedRequestExecution'
19:32:00,047 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultInterceptorStack'
19:32:00,047 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'defaultInterceptorHandlerFactory'
19:32:00,047 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultInterceptorStack'
19:32:00,048 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'topologicalSortedInterceptorRegistry'
19:32:00,048 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'enhancedRequestExecution'
19:32:00,048 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'commonsUploadMultipartInterceptor'
19:32:00,048 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletRequestProvider'
19:32:00,049 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletRequestProvider'
19:32:00,049 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'defaultMultipartConfig'
19:32:00,050 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultValidator'
19:32:00,050 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultResult'
19:32:00,051 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletRequestProvider'
19:32:00,051 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'br.com.caelum.vraptor.ioc.spring.SpringBasedContainer'
19:32:00,052 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultExceptionMapper'
19:32:00,052 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'cglibProxifier'
19:32:00,052 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultExceptionMapper'
19:32:00,053 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'defaultTypeNameExtractor'
19:32:00,053 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultResult'
19:32:00,053 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultValidationViewsFactory'
19:32:00,054 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'cglibProxifier'
19:32:00,054 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultValidationViewsFactory'
19:32:00,054 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'replicatorOutjector'
19:32:00,055 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultMethodInfo'
19:32:00,055 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultMethodInfo'
19:32:00,055 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'paranamerNameProvider'
19:32:00,055 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'replicatorOutjector'
19:32:00,056 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'cglibProxifier'
19:32:00,056 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'JSR303Validator'
19:32:00,057 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'jstlLocalization'
19:32:00,057 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'VRaptorRequestProvider'
19:32:00,057 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'jstlLocalization'
19:32:00,057 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'br.com.caelum.vraptor.validator.JSR303ValidatorFactory'
19:32:00,058 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'JSR303ValidatorFactory'
19:32:00,058 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'br.com.caelum.vraptor.validator.MessageInterpolatorFactory'
19:32:00,058 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'messageInterpolatorFactory'
19:32:00,058 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'JSR303Validator'
19:32:00,059 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultValidator'
19:32:00,059 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultServletFileUploadCreator'
19:32:00,059 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultServletFileUploadCreator'
19:32:00,060 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'commonsUploadMultipartInterceptor'
19:32:00,060 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'resourceLookupInterceptor'
19:32:00,060 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'defaultResourceTranslator'
19:32:00,061 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'defaultResourceNotFoundHandler'
19:32:00,061 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'defaultMethodNotAllowedHandler'
19:32:00,061 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'VRaptorRequestProvider'
19:32:00,062 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'resourceLookupInterceptor'
19:32:00,062 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor ResourceLookupInterceptor
19:32:00,062 DEBUG [DefaultResourceTranslator] trying to access /produtos/lista
19:32:00,062 DEBUG [DefaultResourceTranslator] found resource [DefaultResourceMethod: ProdutosController.listaProdutosController.lista()]
19:32:00,062 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'exceptionHandlerInterceptor'
19:32:00,064 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletRequestProvider'
19:32:00,064 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'exceptionHandlerInterceptor'
19:32:00,064 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor ExceptionHandlerInterceptor
19:32:00,064 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'instantiateInterceptor'
19:32:00,065 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'br.com.caelum.vraptor.ioc.spring.SpringBasedContainer'
19:32:00,065 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'instantiateInterceptor'
19:32:00,065 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor InstantiateInterceptor
19:32:00,065 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'produtosController'
19:32:00,065 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'hibernateProdutoDao'
19:32:00,066 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'com.caelumfj28.infra.CriadorDeSession'
19:32:00,066 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'criadorDeSession'
19:32:00,066 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'sessionFactory'
19:32:00,067 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'cglibProxifier'
19:32:00,067 DEBUG [CommonAnnotationBeanPostProcessor] Invoking init method on bean 'criadorDeSession': public void com.caelumfj28.infra.CriadorDeSession.open()
Enter open Session
19:32:00,067 DEBUG [CglibProxifier      ] a proxy for interface org.hibernate.Session is created as class org.hibernate.Session$$EnhancerByCGLIB$$bde86ec9
19:32:00,068 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'criadorDeSession'
19:32:00,068 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'hibernateProdutoDao'
19:32:00,068 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'produtosController'
19:32:00,068 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'flashInterceptor'
19:32:00,069 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpSessionProvider'
19:32:00,069 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletResponseProvider'
19:32:00,070 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'flashInterceptor'
19:32:00,070 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor FlashInterceptor
19:32:00,070 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'executeMethodInterceptor'
19:32:00,071 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'executeMethodInterceptor'
19:32:00,071 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor ExecuteMethodInterceptor
19:32:00,071 DEBUG [ExecuteMethodInterceptor] Invoking ProdutosController.lista()
Hibernate: 
    select
        this_.id as id2_0_,
        this_.descricao as descricao2_0_,
        this_.nome as nome2_0_,
        this_.preco as preco2_0_ 
    from
        produto this_
19:32:00,074 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'outjectResult'
19:32:00,075 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'defaultTypeNameExtractor'
19:32:00,075 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'outjectResult'
19:32:00,075 DEBUG [LazyInterceptorHandler] Invoking interceptor OutjectResult
19:32:00,075 DEBUG [OutjectResult       ] outjecting produtoList=[com.caelumfj28.model.Produto@30c66e16, com.caelumfj28.model.Produto@33657f5e, com.caelumfj28.model.Produto@4c8d0eae, com.caelumfj28.model.Produto@40bee8c5, com.caelumfj28.model.Produto@35a3feb8, com.caelumfj28.model.Produto@21a7fd8b, com.caelumfj28.model.Produto@1bf6c1f0, com.caelumfj28.model.Produto@653681e7, com.caelumfj28.model.Produto@5d8a989a, com.caelumfj28.model.Produto@3628d670]
19:32:00,076 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'forwardToDefaultViewInterceptor'
19:32:00,076 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'forwardToDefaultViewInterceptor'
19:32:00,076 DEBUG [ToInstantiateInterceptorHandler] Invoking interceptor ForwardToDefaultViewInterceptor
19:32:00,076 DEBUG [ForwardToDefaultViewInterceptor] forwarding to the dafault page for this logic
19:32:00,077 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultPageResult'
19:32:00,077 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletRequestProvider'
19:32:00,078 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletResponseProvider'
19:32:00,078 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultPathResolver'
19:32:00,079 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'defaultFormatResolver'
19:32:00,079 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'httpServletRequestProvider'
19:32:00,079 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'defaultAcceptHeaderToFormat'
19:32:00,079 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultFormatResolver'
19:32:00,080 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultPathResolver'
19:32:00,080 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'cglibProxifier'
19:32:00,080 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'defaultPageResult'
19:32:00,080 DEBUG [DefaultPageResult   ] forwarding to /WEB-INF/jsp/produtos/lista.jsp
19:32:00,081 DEBUG [DefaultStaticContentHandler] Deferring request to container: /CursoCaelumF28/WEB-INF/jsp/produtos/lista.jsp 
19:32:00,083 DEBUG [CommonAnnotationBeanPostProcessor] Invoking destroy method on bean 'criadorDeSession': public void com.caelumfj28.infra.CriadorDeSession.close()
Enter close Session
19:32:00,083 DEBUG [VRaptor             ] VRaptor ended the request
19:32:00,084 DEBUG [OpenSessionInViewFilter] Closing single Hibernate Session in OpenSessionInViewFilter
19:32:00,084 DEBUG [SessionFactoryUtils ] Closing Hibernate Session
19:32:00,084 DEBUG [SessionFactoryUtils ] Could not close Hibernate Session
org.hibernate.SessionException: Session was already closed
	at org.hibernate.impl.SessionImpl.close(SessionImpl.java:320)
	at org.springframework.orm.hibernate3.SessionFactoryUtils.closeSession(SessionFactoryUtils.java:791)
	at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.closeSession(OpenSessionInViewFilter.java:279)
	at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:208)
	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.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
L

Só olhar o erro com mais calma:

19:32:00,084 DEBUG [OpenSessionInViewFilter] Closing single Hibernate Session in OpenSessionInViewFilter  
19:32:00,084 DEBUG [SessionFactoryUtils ] Closing Hibernate Session  
19:32:00,084 DEBUG [SessionFactoryUtils ] Could not close Hibernate Session 
org.hibernate.SessionException: Session was already closed

o OpenSessionInViewFilter não tá conseguindo fechar a Session pq ela já tá fechada.

Como vc usa esse OpenSessionInViewFilter, vc não precisa se preocupar com o fechamento das sessions, então tire o método close do seu CriadorDeSession.

W

Bom dia Lucas, então tirei o close do meu criadorSession só que quando eu vou deletar ou editar ele ainda não faz nada…
Eu estou conseguindo inserir normalmente…

L

como assim ele não faz nada? não dá erro nem nada?

vc tá preenchendo o id do objeto normalmente? tem @Transaction em cima do método?

W

sim estou preenchendo ele recupera o ID, estou usando @Transactional nos metodos que manipula o banco… não aparece erro nenhum no console…

L

tenta lá na factory de Session usar:

Session sessionDoSpring = SessionFactoryUtils.getSession(factory, false);
Criado 13 de agosto de 2012
Ultima resposta 14 de ago. de 2012
Respostas 13
Participantes 4