Announcement Announcement Module
Collapse
No announcement yet.
Occasional no value for key [LocalContainerEntityManagerFactoryBean] on tx commit Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Occasional no value for key [LocalContainerEntityManagerFactoryBean] on tx commit

    This problem pops up intermittently, seemingly randomly on a transaction commit, about 10% of the time.
    I'm using version 3.1.0.RELEASE of the Spring stack.
    Below are logs of a successful and unsuccessful record save followed by configuration and code details.
    Please let me know if I can provide anything else helpful.

    Successful Save
    Code:
    DEBUG: org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor - Opening JPA EntityManager in OpenEntityManagerInViewInterceptor
    DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Found thread-bound EntityManager [org.hibernate.ejb.EntityManagerImpl@128ef7d] for JPA transaction
    DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Creating new transaction with name [com.company.controllers.BusinessObjectController.save]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
    DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Exposing JPA transaction as JDBC transaction [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@1e956bd]
    DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Found thread-bound EntityManager [org.hibernate.ejb.EntityManagerImpl@128ef7d] for JPA transaction
    DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Participating in existing transaction
    DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Initiating transaction commit
    DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Committing JPA transaction on EntityManager [org.hibernate.ejb.EntityManagerImpl@128ef7d]
    DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Not closing pre-bound JPA EntityManager after transaction
    DEBUG: org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor - Closing JPA EntityManager in OpenEntityManagerInViewInterceptor
    DEBUG: org.springframework.orm.jpa.EntityManagerFactoryUtils - Closing JPA EntityManager
    Unsuccessful Save
    Code:
    DEBUG: org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor - Opening JPA EntityManager in OpenEntityManagerInViewInterceptor
    DEBUG: org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler - Starting resource local transaction on application-managed EntityManager [org.hibernate.ejb.EntityManagerImpl@16570ed]
    DEBUG: org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler - Joined local transaction
    DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Found thread-bound EntityManager [org.hibernate.ejb.EntityManagerImpl@16570ed] for JPA transaction
    ERROR: org.springframework.web.servlet.DispatcherServlet - HandlerInterceptor.afterCompletion threw exception
    java.lang.IllegalStateException: No value for key [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean@17a6a4b] bound to thread [tomcat-http--50]
    	at org.springframework.transaction.support.TransactionSynchronizationManager.unbindResource(TransactionSynchronizationManager.java:209)
    	at org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor.afterCompletion(OpenEntityManagerInViewInterceptor.java:107)
    	at org.springframework.web.servlet.handler.WebRequestHandlerInterceptorAdapter.afterCompletion(WebRequestHandlerInterceptorAdapter.java:68)
    	at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletion(DispatcherServlet.java:1218)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    	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.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
    	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
    	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    	at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
    	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    	at ... cutting off stacktrace due to 10,000 char limit.
    Persistence / TX Config:
    Code:
    	<!-- Create a testing embedded HSQL database -->
    	<jdbc:embedded-database id="testDataSource" type="H2">
    		<jdbc:script location="classpath:test-schema.sql"/>
    		<jdbc:script location="classpath:test-data.sql"/>
    	</jdbc:embedded-database>
    	
    	<!-- JPA Config -->
    	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    		<property name="persistenceUnitName" value="persistenceUnit"/>
    		<property name="dataSource" ref="testDataSource"/>
    		<property name="jpaVendorAdapter">
    	        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
    	            <property name="databasePlatform" value="org.hibernate.dialect.SQLServerDialect" />
    	            <property name="generateDdl" value="false"/>
    	            <property name="showSql" value="false" />
    	        </bean>
    	    </property>
    	</bean>
    	
    	<!-- JPA Support -->
    	<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
    	<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
    	
    	<!-- Annotation-Driven Transactions -->
    	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    		<property name="entityManagerFactory" ref="entityManagerFactory"/>
    	</bean>
    	<tx:annotation-driven/>
    Relevant service layer code:
    Code:
    @Controller("businessObjectController")
    @RequestMapping("/businessObject")
    public class BusinessObjectController extends BaseEntityController<BusinessObject> {
    	
    	@Autowired
    	protected BusinessObjectDao dao;
    	
    	@Transactional
    	@SuccessView({"redirect:/businessObject/{businessObject.id}"})
    	@RequestMapping(value={"/{id}/edit", "/new"}, method=RequestMethod.POST, params="save")
    	public void save(@Valid @ModelAttribute("businessObject") BusinessObject entity) {
    		dao.persist(entity);
    	}
    
    	... other methods
    
    }
    Relevant DAO layer code:
    Code:
    public class GenericDao<T extends BaseEntity<? extends Serializable>> {
    
    	@PersistenceContext
    	protected EntityManager entityManager;
    
    	... other methods
    
    	public void persist(T entity) {
    		entityManager.persist(entity);
    	}
    	
    	... other methods
    
    }

  • #2
    From the previous logs noticed that there was a referenced ExtendedEntityManagerCreator on the failure.
    While debugging noticed that a breakpoint in ExtendedEntityManagerCreator.enlistInCurrentTransa ction() is only hit before a failed persist.
    Why would this only be hit on some record save attempts?

    The stack looks like
    Code:
    Daemon Thread [tomcat-http--41] (Suspended (breakpoint at line 420 in ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler))	
    	ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.enlistInCurrentTransaction() line: 420	
    	ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.doJoinTransaction(boolean) line: 398	
    	ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(Object, Method, Object[]) line: 350	
    	$Proxy47.joinTransaction() line: not available	
    	EntityManagerFactoryUtils.doGetTransactionalEntityManager(EntityManagerFactory, Map) line: 179	
    	SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(Object, Method, Object[]) line: 211	
    	$Proxy47.find(Class, Object) line: not available	
    	BusinessObjectDao(GenericDao<T>).load(Serializable) line: 83	
    	GenericDao$$FastClassByCGLIB$$e5245179.invoke(int, Object, Object[]) line: not available	
    	MethodProxy.invoke(Object, Object[]) line: 204	
    	Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint() line: 689	
    	Cglib2AopProxy$CglibMethodInvocation(ReflectiveMethodInvocation).proceed() line: 150	
    	PersistenceExceptionTranslationInterceptor.invoke(MethodInvocation) line: 155	
    	Cglib2AopProxy$CglibMethodInvocation(ReflectiveMethodInvocation).proceed() line: 172	
    	Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Object, Method, Object[], MethodProxy) line: 622	
    	BusinessObjectDao$$EnhancerByCGLIB$$84f7e87f.load(Serializable) line: not available	
    	BusinessObjectController.load(Long) line: 42	
    	BusinessObjectController.load(Long) line: 1	
    	BusinessObjectController(BaseEntityController<T>).getBindingModel(Long, String) line: 39	
    	BaseEntityController$$FastClassByCGLIB$$b9f7d8e9.invoke(int, Object, Object[]) line: not available	
    	MethodProxy.invoke(Object, Object[]) line: 204	
    	Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Object, Method, Object[], MethodProxy) line: 618	
    	BusinessObjectController$$EnhancerByCGLIB$$a399d4d4.getBindingModel(Long, String) line: not available	
    	GeneratedMethodAccessor67.invoke(Object, Object[]) line: not available	
    	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
    	Method.invoke(Object, Object...) line: 597	
    	InvocableHandlerMethod.invoke(Object...) line: 212	
    	InvocableHandlerMethod.invokeForRequest(NativeWebRequest, ModelAndViewContainer, Object...) line: 126	
    	ModelFactory.invokeModelAttributeMethods(NativeWebRequest, ModelAndViewContainer) line: 123	
    	ModelFactory.initModel(NativeWebRequest, ModelAndViewContainer, HandlerMethod) line: 97	
    	RequestMappingHandlerAdapter.invokeHandlerMethod(HttpServletRequest, HttpServletResponse, HandlerMethod) line: 614	
    	RequestMappingHandlerAdapter.handleInternal(HttpServletRequest, HttpServletResponse, HandlerMethod) line: 578	
    	RequestMappingHandlerAdapter(AbstractHandlerMethodAdapter).handle(HttpServletRequest, HttpServletResponse, Object) line: 80	
    	DispatcherServlet.doDispatch(HttpServletRequest, HttpServletResponse) line: 900	
    	DispatcherServlet.doService(HttpServletRequest, HttpServletResponse) line: 827	
    	DispatcherServlet(FrameworkServlet).processRequest(HttpServletRequest, HttpServletResponse) line: 882	
    	DispatcherServlet(FrameworkServlet).doPost(HttpServletRequest, HttpServletResponse) line: 789	
    	DispatcherServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 641	
    	DispatcherServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 722	
    	ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 304	
    	ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 210	
    	FilterChainProxy$VirtualFilterChain.doFilter(ServletRequest, ServletResponse) line: 311	
    	FilterSecurityInterceptor.invoke(FilterInvocation) line: 116	
    	FilterSecurityInterceptor.doFilter(ServletRequest, ServletResponse, FilterChain) line: 83	
    	FilterChainProxy$VirtualFilterChain.doFilter(ServletRequest, ServletResponse) line: 323	
    	ExceptionTranslationFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 113	
    	FilterChainProxy$VirtualFilterChain.doFilter(ServletRequest, ServletResponse) line: 323	
    	SessionManagementFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 101	
    	FilterChainProxy$VirtualFilterChain.doFilter(ServletRequest, ServletResponse) line: 323	
    	AnonymousAuthenticationFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 113	
    	FilterChainProxy$VirtualFilterChain.doFilter(ServletRequest, ServletResponse) line: 323	
    	SecurityContextHolderAwareRequestFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 54	
    	FilterChainProxy$VirtualFilterChain.doFilter(ServletRequest, ServletResponse) line: 323	
    	RequestCacheAwareFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 45	
    	FilterChainProxy$VirtualFilterChain.doFilter(ServletRequest, ServletResponse) line: 323	
    	BasicAuthenticationFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 150	
    	FilterChainProxy$VirtualFilterChain.doFilter(ServletRequest, ServletResponse) line: 323	
    	UsernamePasswordAuthenticationFilter(AbstractAuthenticationProcessingFilter).doFilter(ServletRequest, ServletResponse, FilterChain) line: 182	
    	FilterChainProxy$VirtualFilterChain.doFilter(ServletRequest, ServletResponse) line: 323	
    	LogoutFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 105	
    	FilterChainProxy$VirtualFilterChain.doFilter(ServletRequest, ServletResponse) line: 323	
    	SecurityContextPersistenceFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 87	
    	FilterChainProxy$VirtualFilterChain.doFilter(ServletRequest, ServletResponse) line: 323	
    	FilterChainProxy.doFilter(ServletRequest, ServletResponse, FilterChain) line: 173	
    	DelegatingFilterProxy.invokeDelegate(Filter, ServletRequest, ServletResponse, FilterChain) line: 346	
    	DelegatingFilterProxy.doFilter(ServletRequest, ServletResponse, FilterChain) line: 259	
    	ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 243	
    	ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 210	
    	StandardWrapperValve.invoke(Request, Response) line: 224	
    	StandardContextValve.invoke(Request, Response) line: 175	
    	NonLoginAuthenticator(AuthenticatorBase).invoke(Request, Response) line: 472	
    	StandardHostValve.invoke(Request, Response) line: 164	
    	ErrorReportValve.invoke(Request, Response) line: 100	
    	AccessLogValve.invoke(Request, Response) line: 929	
    	StandardEngineValve.invoke(Request, Response) line: 118	
    	CoyoteAdapter.service(Request, Response) line: 405	
    	Http11Processor.process(SocketWrapper<Socket>) line: 279	
    Http11Protocol$Http11ConnectionHandler(AbstractProtocol$AbstractConnectionHandler<S,P>).process(SocketWrapper<S>, SocketStatus) line: 515	
    	JIoEndpoint$SocketProcessor.run() line: 302	
    	ThreadPoolExecutor$Worker.runTask(Runnable) line: 886	
    	ThreadPoolExecutor$Worker.run() line: 908	
    	TaskThread(Thread).run() line: 662

    Comment


    • #3
      Narrowed the replication procedure by removing redirect after save and jamming F5+enter until an exception occurred.
      In this case:
      Code:
      org.springframework.transaction.IllegalTransactionStateException: Pre-bound JDBC Connection found! JpaTransactionManager does not support running within DataSourceTransactionManager if told to manage the DataSource itself. It is recommended to use a single JpaTransactionManager for all transactions on a single DataSource, no matter whether JPA or JDBC access.
      	at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:356)
      	at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
      	at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:335)
      	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      	at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
      	at com.company.product.controllers.BusinessObjectController$$EnhancerByCGLIB$$51318fe2.save(<generated>)
      	at sun.reflect.GeneratedMethodAccessor81.invoke(Unknown Source)
      	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:212)
      	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
      	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
      	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
      	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
      	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
      	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
      	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
      	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
      	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
      	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.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
      	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
      	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      	at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
      	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
      	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
      	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
      	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
      	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:175)
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      	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: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.Http11Processor.process(Http11Processor.java:279)
      	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$Worker.runTask(ThreadPoolExecutor.java:886)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      	at java.lang.Thread.run(Thread.java:662)
      Last edited by Clarenfield; Mar 9th, 2012, 09:46 AM.

      Comment


      • #4
        It looks like OpenEntityManagerInViewInterceptor is occasionally creating a transaction that doesn't get committed or rolled back:
        Code:
        [09:37:39,896] DEBUG: org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor - Opening JPA EntityManager in OpenEntityManagerInViewInterceptor
        [09:37:39,896] DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Found thread-bound EntityManager [org.hibernate.ejb.EntityManagerImpl@5170a8] for JPA transaction
        [09:37:39,896] DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Creating new transaction with name [null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
        [09:37:39,897] DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Exposing JPA transaction as JDBC transaction [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@123ef32]
        [09:37:39,897] DEBUG: org.compass.spring.transaction.SpringSyncTransaction - Beginning new Spring transaction, and a new compass transaction on thread [tomcat-http--1]
        [09:37:39,911] DEBUG: org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor - Closing JPA EntityManager in OpenEntityManagerInViewInterceptor
        [09:37:39,911] DEBUG: org.springframework.orm.jpa.EntityManagerFactoryUtils - Closing JPA EntityManager
        [09:37:41,705] DEBUG: org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor - Opening JPA EntityManager in OpenEntityManagerInViewInterceptor
        [09:37:41,706] DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Found thread-bound EntityManager [org.hibernate.ejb.EntityManagerImpl@1acd952] for JPA transaction
        [09:37:41,707] DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Creating new transaction with name [com.company.product.controllers.BusinessObjectController.load]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly; ''
        [09:37:41,707] DEBUG: org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor - Closing JPA EntityManager in OpenEntityManagerInViewInterceptor
        [09:37:41,707] DEBUG: org.springframework.orm.jpa.EntityManagerFactoryUtils - Closing JPA EntityManager
        Mar 9, 2012 9:37:41 AM org.apache.catalina.core.StandardWrapperValve invoke
        SEVERE: Servlet.service() for servlet [appServlet] in context with path [/protosar] threw exception [Request processing failed; nested exception is org.springframework.transaction.IllegalTransactionStateException: Pre-bound JDBC Connection found! JpaTransactionManager does not support running within DataSourceTransactionManager if told to manage the DataSource itself. It is recommended to use a single JpaTransactionManager for all transactions on a single DataSource, no matter whether JPA or JDBC access.]

        Comment


        • #5
          I was using Compass, which registered a SpringSyncTransactionFactory. Whenever a compass search was performed compass was creating its own transaction in the absence of a spring transaction. But, it still expected the JpaTransactionManager to give it a lifecycle call back on the transaction being committed. Since there wasn't a spring transaction to commit, the compass-created transaction just floated out into the unknown. JPATransactionManager was eventually displeased to find the JDBC transaction that compass bound, and 'splosions followed.

          Corrected the issue by annotating my compass search method @Transactional(readOnly=true). Now the compass transaction hooks onto the Spring-managed transaction instead of going rogue.

          Comment

          Working...
          X