if you don't call close explicitely maybe you start too much openejb and datasource pool for your database if you have several tests
- Romain 2012/7/17 <klaus.schroe...@ethalon.de> > In the meantime we found another workaround for the issue: If we set the > MaxActive property on the datasource to -1, we do not run into the hanging > problem. But nevertheless, I would like to understand, what could be the > reason for the problem, so here are more details: > > We use "new IntialContext()" to "startup" openejb. In detail, we have a > factory class implementing Springs FactoryBean interface and instatiate an > instance via Spring. I ensured that the new InitialContext() is only > called once per test class. As openejb is managed by Spring we do not > explicitly call "close" somewhere. In our EJBs the JPA-EntityManager is > injected via the @PersistenceContext annotation, so I assume that the > whole database management should be handled properly by openejb. > In our tests each test method initializes a in-memory database (derby) > using dbunit and then executes the test on an EJB. The test methods run > successfully if executed standalone, but if all methods of the test class > are executed, the execution hangs after a number of successful methods. > > I did not provide test class yet, as there are some more classes involved > and would not make this reply too complicated. But if needed, I will > collect the needed classes and send them. > > > Thanks > Klaus > > > > Von: > Romain Manni-Bucau <rmannibu...@gmail.com> > An: > users@openejb.apache.org > Datum: > 17.07.2012 09:11 > Betreff: > Re: Antwort: Re: Unit tests hanging with openejb+dbunit+spring > > > > How is managed openejb? New initialcontext? Ejbcontainer? Openejb runner? > Snapshot arquiilian adapter? Applicationcompozer? > > If on of the two first i mentionned do you call close? > > The best is probably to share a test class removing your business part, is > it possible? > > - Romain > Le 17 juil. 2012 08:54, <klaus.schroe...@ethalon.de> a écrit : > > > Hi Romain > > yes, see stack trace of the hanging thread below. After some more > > investigation it looks like it's hanging while trying to get database > > connections from the connection pool. Seems that connectins are not > > properly freed and returned to the pool? > > > > Any help is appreciated. > > Klaus > > > > Thread [main] (Suspended) > > waiting for: GenericObjectPool$Latch (id=146) > > Object.wait(long) line: not available [native method] > > GenericObjectPool$Latch(Object).wait() line: 485 [local > variables > > unavailable] > > GenericObjectPool.borrowObject() line: 1115 > > ManagedConnection.updateTransactionStatus() line: 117 > > ManagedConnection.<init>(ObjectPool, TransactionRegistry, > boolean) > > line: 55 > > ManagedDataSource.getConnection() line: 77 > > BasicManagedDataSource(BasicDataSource).getConnection() line: > 1044 > > > > DecoratingDataSource(DelegatingDataSource).getConnection() line: > > 110 > > DecoratingDataSource.getConnection() line: 87 > > JDBCStoreManager.connectInternal() line: 960 > > JDBCStoreManager.connect(boolean) line: 945 > > JDBCStoreManager.getConnection() line: 240 > > FinderQueryImpl.execute(OpenJPAStateManager, StoreManager, > > FetchConfiguration) line: 139 > > JDBCStoreManager.getInitializeStateResult(OpenJPAStateManager, > > ClassMapping, JDBCFetchConfiguration, int) line: 537 > > JDBCStoreManager.initializeState(OpenJPAStateManager, PCState, > > JDBCFetchConfiguration, ConnectionInfo) line: 349 > > JDBCStoreManager.initialize(OpenJPAStateManager, PCState, > > FetchConfiguration, Object) line: 304 > > ROPStoreManager(DelegatingStoreManager).initialize(OpenJPAStateManager, > > PCState, FetchConfiguration, Object) line: 112 > > ROPStoreManager.initialize(OpenJPAStateManager, PCState, > > FetchConfiguration, Object) line: 57 > > BrokerImpl.initialize(StateManagerImpl, boolean, > > FetchConfiguration, Object) line: 1036 > > BrokerImpl.find(Object, FetchConfiguration, BitSet, Object, int, > > FindCallbacks) line: 994 > > BrokerImpl.find(Object, boolean, FindCallbacks) line: 911 > > DelegatingBroker.find(Object, boolean, FindCallbacks) line: 231 > > EntityManagerImpl.find(Class<T>, Object) line: 487 > > JtaEntityManager.find(Class<T>, Object) line: 157 > > MmData(BasicDataService).findById(Class<T>, U) line: 96 > > GeneratedMethodAccessor208.invoke(Object, Object[]) line: not > > available > > DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 > > Method.invoke(Object, Object...) line: 597 > > > > > > > > ReflectionInvocationContext$BeanInvocation(ReflectionInvocationContext$Invocation).invoke() > > line: 181 > > ReflectionInvocationContext.proceed() line: 163 > > StatsInterceptor.record(InvocationContext, Method) line: 176 > > StatsInterceptor.invoke(InvocationContext) line: 95 > > GeneratedMethodAccessor86.invoke(Object, Object[]) line: not > > available > > DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 > > Method.invoke(Object, Object...) line: 597 > > > > > > > > ReflectionInvocationContext$InterceptorInvocation(ReflectionInvocationContext$Invocation).invoke() > > line: 181 > > ReflectionInvocationContext.proceed() line: 163 > > CdiInterceptor.invoke(InvocationContext) line: 129 > > CdiInterceptor.access$000(CdiInterceptor, InvocationContext) > line: > > 45 > > CdiInterceptor$1.call() line: 66 > > CdiInterceptor.aroundInvoke(InvocationContext) line: 72 > > GeneratedMethodAccessor85.invoke(Object, Object[]) line: not > > available > > DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 > > Method.invoke(Object, Object...) line: 597 > > > > > > > > ReflectionInvocationContext$InterceptorInvocation(ReflectionInvocationContext$Invocation).invoke() > > line: 181 > > ReflectionInvocationContext.proceed() line: 163 > > InterceptorStack.invoke(Object...) line: 138 > > StatelessContainer._invoke(Method, Method, Object[], Instance, > > ThreadContext, InterfaceType) line: 226 > > StatelessContainer.invoke(Object, InterfaceType, Class, Method, > > Object[], Object) line: 178 > > > > > > > > StatelessEjbObjectHandler(EjbObjectProxyHandler).synchronizedBusinessMethod(Class<?>, > > Method, Object[], Object) line: 260 > > > StatelessEjbObjectHandler(EjbObjectProxyHandler).businessMethod(Class<?>, > > Method, Object[], Object) line: 240 > > StatelessEjbObjectHandler(EjbObjectProxyHandler)._invoke(Object, > > Class, Method, Object[]) line: 91 > > StatelessEjbObjectHandler(BaseEjbProxyHandler).invoke(Object, > > Method, Object[]) line: 284 > > $Proxy98.findById(Class, Object) line: not available > > InvoiceServiceLoadHelper.loadInvoiceHeaderEntity(Long, > > InventoryManagementContainer) line: 217 > > InvoiceServiceImpl.saveInvoiceItem(UserContainer, InvoiceItem, > > Long, Short, InvoiceItemResponse) line: 381 > > > > > > > > InventoryManagementLogicEJB.saveInvoiceItem_aroundBody46(InventoryManagementLogicEJB, > > UserContainer, InvoiceItem, Long, Short, JoinPoint) line: 234 > > > > > > > > InventoryManagementLogicEJB.saveInvoiceItem_aroundBody47$advice(InventoryManagementLogicEJB, > > UserContainer, InvoiceItem, Long, Short, JoinPoint, LogicServiceAspect, > > AroundClosure, JoinPoint$StaticPart, JoinPoint) line: 117 > > > > > > > > InventoryManagementLogicEJB.saveInvoiceItem_aroundBody48(InventoryManagementLogicEJB, > > UserContainer, InvoiceItem, Long, Short, JoinPoint) line: 1 > > > > > > > > InventoryManagementLogicEJB.saveInvoiceItem_aroundBody49$advice(InventoryManagementLogicEJB, > > UserContainer, InvoiceItem, Long, Short, JoinPoint, GuardAspect, > > AroundClosure, JoinPoint) line: 135 > > InventoryManagementLogicEJB.saveInvoiceItem(UserContainer, > > InvoiceItem, Long, Short) line: 1 > > NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: > > not available [native method] > > NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 > > DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 > > Method.invoke(Object, Object...) line: 597 > > > > > > > > ReflectionInvocationContext$BeanInvocation(ReflectionInvocationContext$Invocation).invoke() > > line: 181 > > ReflectionInvocationContext.proceed() line: 163 > > StatsInterceptor.record(InvocationContext, Method) line: 176 > > StatsInterceptor.invoke(InvocationContext) line: 95 > > GeneratedMethodAccessor86.invoke(Object, Object[]) line: not > > available > > DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 > > Method.invoke(Object, Object...) line: 597 > > > > > > > > ReflectionInvocationContext$InterceptorInvocation(ReflectionInvocationContext$Invocation).invoke() > > line: 181 > > ReflectionInvocationContext.proceed() line: 163 > > CdiInterceptor.invoke(InvocationContext) line: 129 > > CdiInterceptor.access$000(CdiInterceptor, InvocationContext) > line: > > 45 > > CdiInterceptor$1.call() line: 66 > > CdiInterceptor.aroundInvoke(InvocationContext) line: 72 > > GeneratedMethodAccessor85.invoke(Object, Object[]) line: not > > available > > DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 > > Method.invoke(Object, Object...) line: 597 > > > > > > > > ReflectionInvocationContext$InterceptorInvocation(ReflectionInvocationContext$Invocation).invoke() > > line: 181 > > ReflectionInvocationContext.proceed() line: 163 > > InterceptorStack.invoke(Object...) line: 138 > > StatelessContainer._invoke(Method, Method, Object[], Instance, > > ThreadContext, InterfaceType) line: 226 > > StatelessContainer.invoke(Object, InterfaceType, Class, Method, > > Object[], Object) line: 178 > > > > > > > > StatelessEjbObjectHandler(EjbObjectProxyHandler).synchronizedBusinessMethod(Class<?>, > > Method, Object[], Object) line: 260 > > > StatelessEjbObjectHandler(EjbObjectProxyHandler).businessMethod(Class<?>, > > Method, Object[], Object) line: 240 > > StatelessEjbObjectHandler(EjbObjectProxyHandler)._invoke(Object, > > Class, Method, Object[]) line: 91 > > StatelessEjbObjectHandler(BaseEjbProxyHandler).invoke(Object, > > Method, Object[]) line: 284 > > $Proxy97.saveInvoiceItem(UserContainer, InvoiceItem, Long, > Short) > > line: not available > > InvoiceServiceImplTest.testSaveInvoiceItemNoAmount() line: 882 > > NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: > > not available [native method] > > NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 > > DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 > > Method.invoke(Object, Object...) line: 597 > > FrameworkMethod$1.runReflectiveCall() line: 44 > > FrameworkMethod$1(ReflectiveCallable).run() line: 15 > > FrameworkMethod.invokeExplosively(Object, Object...) line: 41 > > InvokeMethod.evaluate() line: 20 > > RunBefores.evaluate() line: 28 > > RunBeforeTestMethodCallbacks.evaluate() line: 74 > > RunAfters.evaluate() line: 31 > > RunAfterTestMethodCallbacks.evaluate() line: 82 > > SpringRepeat.evaluate() line: 72 > > SpringJUnit4ClassRunner.runChild(FrameworkMethod, RunNotifier) > > line: 231 > > SpringJUnit4ClassRunner(BlockJUnit4ClassRunner).runChild(Object, > > RunNotifier) line: 49 > > ParentRunner$3.run() line: 193 > > ParentRunner$1.schedule(Runnable) line: 52 > > SpringJUnit4ClassRunner(ParentRunner<T>).runChildren(RunNotifier) > > line: 191 > > ParentRunner<T>.access$000(ParentRunner, RunNotifier) line: 42 > > ParentRunner$2.evaluate() line: 184 > > RunBeforeTestClassCallbacks.evaluate() line: 61 > > RunAfterTestClassCallbacks.evaluate() line: 70 > > SpringJUnit4ClassRunner(ParentRunner<T>).run(RunNotifier) line: > > 236 > > SpringJUnit4ClassRunner.run(RunNotifier) line: 174 > > JUnit4TestClassReference(JUnit4TestReference).run(TestExecution) > > line: 50 > > TestExecution.run(ITestReference[]) line: 38 > > RemoteTestRunner.runTests(String[], String, TestExecution) line: > > 467 > > RemoteTestRunner.runTests(TestExecution) line: 683 > > RemoteTestRunner.run() line: 390 > > RemoteTestRunner.main(String[]) line: 197 > > > > > > > > > > Von: > > Romain Manni-Bucau <rmannibu...@gmail.com> > > An: > > users@openejb.apache.org > > Datum: > > 16.07.2012 17:03 > > Betreff: > > Re: Unit tests hanging with openejb+dbunit+spring > > > > > > > > Hi, > > > > Any luck to get a thread stack when it hangs? > > > > - Romain > > Le 16 juil. 2012 16:23, <klaus.schroe...@ethalon.de> a écrit : > > > > > Hi OpenEJB experts > > > We use openejb4 + DbUnit + Spring for unittesting our EJBs. Works > pretty > > > well in most cases so far. But with some tests we run into a strange > > > problem: > > > If the test class has more than a certain number of test methods (e.g. > > 20 > > > methods), the test simply hangs forever. It does not fail, it just > hangs > > > and this is really bad for our build server. If we comment out one > > method, > > > the test runs fine. Our current workaround is to split up the test > class > > > in multiple classes and then all test methods work fine, but this is > > kind > > > of a stupid fix. > > > > > > Does anybody ever encountered this behavior? Any ideas to fix this? > > > > > > Thanks > > > Klaus > > > > > > > > > > > > > > > > > > > > > > > > > > >