JunitEJB wraps your test in a session bean that starts a user transaction. Your test runs in the context of that transaction.
The code in the JUnitEJB TestRunner is wrong. It catches the rollback from the commit() then tries to perform a rollback(). The transaction is already gone when the commit fails. Here is the source: http://cvs.sourceforge.net/viewcvs.py/junitejb/junitejb/src/net/sourceforge/junitejb/EJBTestRunnerBean.java?rev=1.3&content-type=text/vnd.viewcvs-markup Regards, Adrian On Wed, 2003-10-01 at 17:00, Mary He wrote: > Hi all, > > I am using junitejb to do unit testing. Since jboss doesn't provide clob, blob > mapping, I wrote a few bmp entity beans with commit option B (because trigger > populates the modified date, I can not use the default commit option A, because > commit option C will trigger Unable to passivate bug, for right now, in our > application every entity bean use commit option B). When I do entity bean unit > testing with junitejb, I often get the following No transaction errors. All entity > bean methods are specified as transaction "required" in ejb-jar.xml. I am using > jboss 3.2.1 and jdk 1.4.2 on windows 2000. Sometimes, if I add a few more lines in a > test method, the error will go away. Sometimes, no luck. I tried to use > UserTransaction to manage transaction in test method, but jboss complained the > transaction is active and I am not allowed to do it. > > Thank you in advance! > > Mary > > 17:14:55,809 ERROR [LogInterceptor] RuntimeException: > java.lang.IllegalStateException: No transaction. > at org.jboss.tm.TxManager.rollback(TxManager.java:273) > at org.jboss.ejb.EnterpriseContext$UserTransactionImpl.rollback(Enterpri > seContext.java:492) > at net.sourceforge.junitejb.EJBTestRunnerBean.runTestCase(EJBTestRunnerB > ean.java:111) > at net.sourceforge.junitejb.EJBTestRunnerBean.run(EJBTestRunnerBean.java > :44) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. > java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces > sorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(S > tatelessSessionContainer.java:629) > at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invo > ke(CachedConnectionInterceptor.java:186) > at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInte > rceptor.java:84) > at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxI > nterceptorBMT.java:144) > at org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:6 > 2) > at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(Stat > elessSessionInstanceInterceptor.java:72) > at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor. > java:117) > at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191) > at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFacto > ryFinderInterceptor.java:122) > at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessi > onContainer.java:322) > at org.jboss.ejb.Container.invoke(Container.java:674) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. > java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces > sorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBea > nDispatcher.java:284) > at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549) > at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java: > 359) > at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces > sorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261) > at sun.rmi.transport.Transport$1.run(Transport.java:148) > at java.security.AccessController.doPrivileged(Native Method) > at sun.rmi.transport.Transport.serviceCall(Transport.java:144) > at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4 > 60) > at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport > .java:701) > at java.lang.Thread.run(Thread.java:534) > 1 > > > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > JBoss-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/jboss-user -- xxxxxxxxxxxxxxxxxxxxxxxx Adrian Brock Director of Support Back Office JBoss Group, LLC xxxxxxxxxxxxxxxxxxxxxxxx ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
