This is a little old question, but he thought about answering correctly.
Changing the property name hibernate.current_session_context_class to current_session_context_class , force the default JTASessionContext .
Below is a snippet from hibernate SessionFactoryImpl . BTW, Environment.CURRENT_SESSION_CONTEXT_CLASS - "hibernate.current_session_context_class" . ThreadLocalSessionContext causes this problem.
private CurrentSessionContext buildCurrentSessionContext() { String impl = (String) properties.get( Environment.CURRENT_SESSION_CONTEXT_CLASS ); // for backward-compatibility if ( impl == null ) { if ( canAccessTransactionManager() ) { impl = "jta"; } else { return null; } } if ( "jta".equals( impl ) ) { // if ( ! transactionFactory().compatibleWithJtaSynchronization() ) { // LOG.autoFlushWillNotWork(); // } return new JTASessionContext( this ); } else if ( "thread".equals( impl ) ) { return new ThreadLocalSessionContext( this ); } else if ( "managed".equals( impl ) ) { return new ManagedSessionContext( this ); } else { try { Class implClass = serviceRegistry.getService( ClassLoaderService.class ).classForName( impl ); return (CurrentSessionContext) implClass.getConstructor( new Class[] { SessionFactoryImplementor.class } ) .newInstance( this ); } catch( Throwable t ) { LOG.unableToConstructCurrentSessionContext( impl, t ); return null; } } }
Please check ThreadLocalSessionContext.TransactionProtectionWrapper.invoke
source share