-
1. Re: Can't get @TransactionTimeout to work
mihai.ratiu Jul 10, 2009 11:12 AM (in response to rlj)I'm facing the same problem. Did anyone managed to solve the problem?
Thx,
Mihai -
2. Re: Can't get @TransactionTimeout to work
jaikiran Jul 10, 2009 11:26 AM (in response to rlj)2 year old post and an old version of JBoss.
Please explain your issue in more detail. Which version of JBoss AS and Java do you use? What does your code look like? What exact issue do you see? -
3. Re: Can't get @TransactionTimeout to work
mihai.ratiu Jul 20, 2009 10:11 AM (in response to rlj)My objective is to set a different timeout (greater than default of 5 mins) for a method that need to process a group of objects in a long transaction. So I tried to use the @TransactionTimeout annotation. Below is a simplified pseudocode with what I want to do.
@PersistenceContext EntityManager em; @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) @TransactionTimeout(3600) public Long doLongTransaction(List<BaseEntity> entities) { for(BaseEntity entity : entities) { if (condition) persistEntity(entity); else updateEntity(entity); } } @TransactionAttribute(TransactionAttributeType.REQUIRED) public void persistEntity(BaseEntity entity) { em.persist(entity); } @TransactionAttribute(TransactionAttributeType.REQUIRED) public void updateEntity(BaseEntity entity) { em.merge(entity); }
If I try to set a minimum timeout to see if the transaction for this method will timeout let's say, after a minute it doesn't work, it will only timeout after the default 5 minutes value.
Am I missing something. Is there any other possibility to set a different transaction timeout for a method without affecting the global transaction default timeout?
Thanks,
Mihai -
4. Re: Can't get @TransactionTimeout to work
jaikiran Jul 20, 2009 10:49 AM (in response to rlj)Which version of JBoss AS? And please post the import statement that you have (especially for the Transaction* annotations)
-
5. Re: Can't get @TransactionTimeout to work
mihai.ratiu Jul 21, 2009 3:26 AM (in response to rlj)Jboss version used is 4.0.5 GA with ejb3 deployer, 'all' configuration. The import statement are like in the code below.
import org.jboss.annotation.ejb.TransactionTimeout; import javax.ejb.*; @PersistenceContext EntityManager em; @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) @TransactionTimeout(3600) public Long doLongTransaction(List<BaseEntity> entities) { for(BaseEntity entity : entities) { if (condition) persistEntity(entity); else updateEntity(entity); } } @TransactionAttribute(TransactionAttributeType.REQUIRED) public void persistEntity(BaseEntity entity) { em.persist(entity); } @TransactionAttribute(TransactionAttributeType.REQUIRED) public void updateEntity(BaseEntity entity) { em.merge(entity); }
Thanks,
Mihai -
6. Re: Can't get @TransactionTimeout to work
mihai.ratiu Jul 23, 2009 3:42 AM (in response to rlj)Can this problem occur from the fact that I'm using the @TransactionTimeout annotation from org.jboss.* package, and the others from javax.ejb.*? Did anyone faced this problem?
Thx,
Mihai -
7. Re: Can't get @TransactionTimeout to work
jaikiran Jul 23, 2009 9:51 AM (in response to rlj)Can you try upgrading to later versions of JBoss (like 4.2.3 GA or 5.1.0 GA) and try this. 4.0.5 GA by default did not have EJB3 support and required EJB3 patches to be applied.
-
8. Re: Can't get @TransactionTimeout to work
richardvanduijn Aug 5, 2009 11:40 AM (in response to rlj)I'm experiencing the same problem. I'm currently using JBoss 5.1.0 GA and still the transaction timeout is set to the default value.
I've read in other posts that you require a new transaction in order to allow the timeout Annotation to work. So I've done this, with little success.
Any ideas anyone?
Thanks in advance
Richard -
9. Re: Can't get @TransactionTimeout to work
jaikiran Aug 5, 2009 11:54 AM (in response to rlj)"richardvanduijn" wrote:
I'm experiencing the same problem. I'm currently using JBoss 5.1.0 GA and still the transaction timeout is set to the default value.
Without looking at your code, i guess you are importing the wrong packages for the transaction timeout annotation. You should be using:@org.jboss.ejb3.annotation.TransactionTimeout
-
10. Re: Can't get @TransactionTimeout to work
richardvanduijn Aug 5, 2009 12:01 PM (in response to rlj)You're correct that I'm not correclty importing the annotation.
I'm using org.jboss.annotation.ejb.TransactionTimeout
Which jar provides me with this class?
Thanks for your quick response.
Regards,
Richard -
11. Re: Can't get @TransactionTimeout to work
richardvanduijn Aug 5, 2009 12:11 PM (in response to rlj)Ah found the jar its called:\jboss-ejb3-ext-api.jar
My maven project did not update correctly somehow, not updating the ejb package name to ejb3.
Will see if it works now. Again, thank you for your reply. -
12. Re: Can't get @TransactionTimeout to work
richardvanduijn Aug 5, 2009 12:24 PM (in response to rlj)Ah nice, solution works.
-
13. Re: Can't get @TransactionTimeout to work
pablo.fraga1975 Aug 6, 2009 5:05 PM (in response to rlj)Hi,
I have the same problem. I'am using EJB3, JBoss 4.2.3 GA, SLSB with CMP transactions.
Code snap:
import org.jboss.annotation.ejb.TransactionTimeout;
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@TransactionTimeout(15)
public AbstractResult compra(AbstractCommand command){
The timeout doesn't work for me using this annotation with this full qualified name.
But the thing is that i can't find the other one in any jar provided by JBoss. Can't find org.jboss.ejb3.annotation.TransactionTimeout.
Any help?
Pablo. -
14. Re: Can't get @TransactionTimeout to work
pablo.fraga1975 Aug 6, 2009 5:40 PM (in response to rlj)I forgot to mention that if I change the transaction management type to BEAN it does work.
@TransactionManagement(TransactionManagementType.BEAN)
But I don't want to change the default transaction type, and what is more, I didn't find anywhere in the documentation of JBoss that this is needed to work it out, any suggestions?
Pablo.