[jboss-user] [EJB 3.0] - EJB3 Entity doing Batch Insert fails with transaction requir

ejb3workshop do-not-reply at jboss.com
Mon Sep 24 12:10:07 EDT 2007


I am reading a rather large XML file, split it into a large number of segments and would like to insert each segment into a database. The segments fit nicely   into entities, so please don't tell me about prepared statement etc. Currently I have MDB which received the file descriptor and begins reading the file and processing it. 

When using smaller files (<30Mb) everything seems to work really well. The files are loaded quickly and without errors. However as soon as the I try to load the large file the process failes with :

anonymous wrote : 
  | javax.persistence.TransactionRequiredException: EntityManager must be access within a transaction
  |        at org.jboss.ejb3.entity.ManagedEntityManagerFactory.verifyInTx(ManagedEntityManagerFactory.java:150)
  |        at org.jboss.ejb3.entity.TransactionScopedEntityManager.persist(TransactionScopedEntityManager.java:181)
  |        at com.thunderhead.backend.BatchJobDevider.segmentCompleted(BatchJobDevider.java:56)
  |        at com.thunderhead.backend.utilities.XMLSegmenter.notifyListeners(XMLSegmenter.java:61)
  |        at com.thunderhead.backend.utilities.XMLSegmenter.segment(XMLSegmenter.java:51)
  |        at com.thunderhead.backend.BatchJobProcessor.onMessage(BatchJobProcessor.java:85)
  |        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.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
  |        at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
  |        at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
  |        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |        at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
  |        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |        at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
  |        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |        at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
  |        at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
  |        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |        at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
  |        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |        at org.jboss.ejb3.mdb.MessagingContainer.localInvoke(MessagingContainer.java:245)
  |        at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.delivery(MessageInflowLocalProxy.java:268)
  |        at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.invoke(MessageInflowLocalProxy.java:138)
  |        at $Proxy99.onMessage(Unknown Source)
  |        at org.jboss.resource.adapter.jms.inflow.JmsServerSession.onMessage(JmsServerSession.java:178)
  |        at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:891)
  |        at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:170)
  |        at org.jboss.mq.SpySession.run(SpySession.java:323)
  |        at org.jboss.resource.adapter.jms.inflow.JmsServerSession.run(JmsServerSession.java:237)
  |        at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204)
  |        at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275)
  |        at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
  |        at java.lang.Thread.run(Thread.java:619)
  | 

Currently I don't have any transaction attributes defined on my onMessage method. At first I thought it might be the database connection pool timing out, so I increased the timeout. However I now get this failure before the timeout period elapsed. It seems that the transaction constructed by the server is exceeding some limit and then enters into a no transaction available state.

Any suggestions on how to resolve this without using a prepared statement and inserting it directly into the database. 

Thanks 
Alex

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4088029#4088029

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4088029



More information about the jboss-user mailing list