[jboss-user] [EJB 3.0] New message: "Re: Entity Manager with BMT and Transaction Timeout"

Alexander Hartner do-not-reply at jboss.com
Thu Feb 25 11:49:35 EST 2010


User development,

A new message was posted in the thread "Entity Manager with BMT and Transaction Timeout":

http://community.jboss.org/message/528562#528562

Author  : Alexander Hartner
Profile : http://community.jboss.org/people/ejb3workshop

Message:
--------------------------------------------------------------
Thanks for responsing. Here is my bean code.
 
First the MDB which shows the injection of an entityManager, usertransaction and a datasource:
> ...
> @MessageDriven(name = "WorkListener", activationConfig = {
>         @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
>         @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
>         @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/abc/WorkMessages")
> })
> @TransactionManagement(TransactionManagementType.BEAN)
> public class WorkListener  implements MessageListener {
>  
>     @PersistenceContext(unitName = "entityManager")
>     protected EntityManager entityManager;
>  
>     @Resource(name = "jdbc/abcDSNoTX")
>     DataSource datasource;
>  
>     @Resource
>     private UserTransaction userTransaction;
>  
>     public void onMessage(Message message) {
>         try {           
>             Processor processor = new Processor(entityManager, userTransaction, datasource);
>             processor.process(message);
> ....
 
Then further down the stack we begin a new userTransaction and load some entity via the entity manager
 
> ...
> m_userTransaction.begin();
> Account account = m_entityManager.find(Account.class, accountId);
> ...
>  
> account.getRelatedAccounts();
 
However further down the stack we access a collection on the account which loads further linked entities and failes with the LazyInitializationException. 
 
This problem only occurs under load and is most likely caused by a slow down while accessing the database. However I am not too concerned about performance at this stage, just want to know how I can debug this issue and see what happened to my entity manager session. My suspicion is that since I am using a User Transaction that the global timeout which I set to 3600 (=1 hour) is not applied. If this is the case where do you set the default transaction timeout for a user transaction or the hibernate session. Usually the first time the exception is thrown is between 20 and 30 minutes after submitting a large volume of work. 

--------------------------------------------------------------

To reply to this message visit the message page: http://community.jboss.org/message/528562#528562




More information about the jboss-user mailing list