Programatically configure persistence under Tomcat
I'm working on an application which will have several instances deployed on the same server. I intend to do it as 'deploy friendly' as possible, and, since there is already a configuration file for other properties, I'd like to add properties there for the database connection, and add a context listener on Tomcat, so that, when the application starts, I can add a data source "on the fly" for that instance. This would avoid having to touch a system-wide file (openejb.xml). My problem is really splitted in 2 parts: 1. Dynamically adding a new data source with parameters I'll have from my configuration file 2. Making the "static" jta-data-source configuration tag under persistence.xml point to that new DataSource. Perhaps having a java:comp/env/ entry there, and adding the DataSource under this context would do the job. I don't mind using some OpenEJB-specific code to do this, but I'd need some guidance.
Exception while testing MDB
Hi, I'm currently writing simple test cases to test (and learn ;-)) power of MDBs. But I run into some problems. This is an modified "simple-mdb" example from openejb3 sources. I have simple test running by 4 threads in parallel sending requests to simple Stateless bean that add these request to some queue (to MDB). This is a stack trace of exception I getting: = http://www.nabble.com/file/p21453674/simple-mdb.zip simple-mdb.zip http://www.nabble.com/file/p21453674/simple-mdb.zip simple-mdb.zip WARN - Unable to enlist XAResource org.apache.geronimo.transaction.manager.wrappernamedxaresou...@17951f3, errorCode: -7 javax.transaction.xa.XAException: The connection is already closed at org.apache.activemq.TransactionContext.toXAException(TransactionContext.java:619) at org.apache.activemq.TransactionContext.setXid(TransactionContext.java:556) at org.apache.activemq.TransactionContext.start(TransactionContext.java:299) at org.apache.activemq.ra.LocalAndXATransaction.start(LocalAndXATransaction.java:136) at org.apache.geronimo.transaction.manager.WrapperNamedXAResource.start(WrapperNamedXAResource.java:86) at org.apache.geronimo.transaction.manager.TransactionImpl.enlistResource(TransactionImpl.java:208) at org.apache.geronimo.connector.outbound.TransactionEnlistingInterceptor.getConnection(TransactionEnlistingInterceptor.java:54) at org.apache.geronimo.connector.outbound.TransactionCachingInterceptor.getConnection(TransactionCachingInterceptor.java:86) at org.apache.geronimo.connector.outbound.ConnectionHandleInterceptor.getConnection(ConnectionHandleInterceptor.java:43) at org.apache.geronimo.connector.outbound.TCCLInterceptor.getConnection(TCCLInterceptor.java:39) at org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor.getConnection(ConnectionTrackingInterceptor.java:66) at org.apache.geronimo.connector.outbound.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:87) at org.apache.activemq.ra.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:92) at org.apache.activemq.ra.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:66) at example.ComputeServiceImpl.compute(ComputeServiceImpl.java:29) at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:158) at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:141) at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:67) at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:211) at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:169) at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:217) at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:77) at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:286) at $Proxy11.compute(Unknown Source) at MessageDrivenBeanTest.testMessageDrivenBean(MessageDrivenBeanTest.java:76) at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580) at org.testng.internal.Invoker.invokeMethod(Invoker.java:478) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:617) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:885) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110) at org.testng.internal.thread.ThreadUtil$CountDownLatchedRunnable.run(ThreadUtil.java:132) 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:619) Caused by: org.apache.activemq.ConnectionClosedException: The connection is already closed at org.apache.activemq.ActiveMQConnection.checkClosed(ActiveMQConnection.java:1245) at org.apache.activemq.ActiveMQConnection.checkClosedOrFailed(ActiveMQConnection.java:1232) at org.apache.activemq.TransactionContext.setXid(TransactionContext.java:553) ... 39