Issue 1:
Mike Youngstrom opened SPR-8800 and commented

Using Spring 3.1 rc1 I get a new error when using hibernate with JTA multiple times in the same thread. What appears to be happening is the HibernateJpaDialect is adding the Hibernate SessionFactory to the transactional resources for some reason. It assumes that when the transaction commits EntityManagerFactoryUtils.cleanupTransaction() will be called. However it doesn't in my situation.

I've included a maven test case. To duplicate simply run mvn test. If you change the version of spring to 3.0.6.RELEASE then the test passes.

Below is the exception I get:

java.lang.IllegalStateException: Already value [SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=[] updates=[] deletions=[] collectionCreations=[] collectionRemovals=[] collectionUpdates=[]])] for key [org.hibernate.internal.SessionFactoryImpl@1d7b222] bound to thread [main]

at org.springframework.transaction.support.TransactionSynchronizationManager.bindResource(TransactionSynchronizationManager.java:180)

at org.springframework.orm.jpa.vendor.HibernateJpaDialect.prepareTransaction(HibernateJpaDialect.java:98)

at org.springframework.orm.jpa.EntityManagerFactoryUtils.prepareTransaction(EntityManagerFactoryUtils.java:230)

at org.springframework.orm.jpa.EntityManagerFactoryUtils.doGetTransactionalEntityManager(EntityManagerFactoryUtils.java:207)

at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:211)

at $Proxy16.getDelegate(Unknown Source)

at test.JpaTest$2.doInTransaction(JpaTest.java:32)

at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)

at test.JpaTest.test(JpaTest.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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)

at org.testng.internal.MethodInvocationHelper$1.runTestMethod(MethodInvocationHelper.java:169)

at org.springframework.test.context.testng.AbstractTestNGSpringContextTests.run(AbstractTestNGSpringContextTests.java:158)

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.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:181)

at org.testng.internal.Invoker.invokeMethod(Invoker.java:684)

at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)

at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1208)

at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)

at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)

at org.testng.TestRunner.privateRun(TestRunner.java:753)

at org.testng.TestRunner.run(TestRunner.java:613)

at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)

at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)

at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)

at org.testng.SuiteRunner.run(SuiteRunner.java:240)

at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)

at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)

at org.testng.TestNG.runSuitesSequentially(TestNG.java:1137)

at org.testng.TestNG.runSuitesLocally(TestNG.java:1062)

at org.testng.TestNG.run(TestNG.java:974)

at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:109)

at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)

at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)

Attachments:

test-jpa-binding.zip (2.89 kB)

Issue Links:

#13414 Jpa transaction manager transaction suspension ignores dialect resources

1 votes, 2 watchers

Issue 2:
Paul Middelkoop opened SPR-8651 and commented

Tested on nightly build of August 29th 2011:

public interface MyRepository {

}

@Component

public class MyRepositoryImpl implements MyRepository {

@Scheduled(fixedDelay = 5)

public void initCache() {}

}

This works. But when I change from @Component to @Repository I get this exception:

java.lang.IllegalArgumentException: object is not an instance of declaring class

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.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:64)

at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:53)

at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)

at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

at java.util.concurrent.FutureTask.run(FutureTask.java:138)

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)

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)

Adding the @Scheduled method to the interface doesn't help also.

Affects: 3.1 M2

Issue Links:

#13514 @Scheduled does not work in classes annotated with @Cacheable ("is duplicated by")

Referenced from: commits d4123d0

2 votes, 3 watchers