[EJB 3.0] - Transaction not rolling back in CONTAINER mode
by umberto_soprano
Hello,
I've a EHB3 Stateless bean who's using direct JDBC connections (no persistence manager) to store data in a database.
If I try to use TransactionManagement=CONTAINER Jboss seems to not execute roll backs in case of exceptions (both Application or Runtime exception). I inserted an as hoc thrown Exception to simulate the fault.
Managing TransactionManagement=BEAN works.
Any suggestion (code example below)?
CONTAINER mode (no rollback):
|
| @Stateless
| @javax.ejb.ApplicationException(rollback = true)
| @TransactionManagement(TransactionManagementType.CONTAINER)
| public class x implements y,z{
|
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public Message processMessage() throws Exception
| {
|
| try {
| <<insert to DB>>
| << launch Exception>>
| } catch (Exception e1)
| {
| <<log>>
| throw e1;
| }}
|
|
BEAN mode (rollback executed):
|
| @Stateless
| @javax.ejb.ApplicationException(rollback = true)
| @TransactionManagement(TransactionManagementType.CONTAINER)
| public class x implements y,z{
|
| @Resource
| private UserTransaction utx;
|
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public Message processMessage() throws Exception
| {
|
| try {
| utx.begin();
| <<insert to DB>>
| << launch Exception>>
| utx.commit();
| } catch (Exception e1)
| {
| utx.rollback();
| <<log>>
| throw e1;
| }}
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4091951#4091951
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4091951
18Â years, 8Â months
[JBossCache] - Re: Cache not accessible from different methods ?
by BruceSpringfield
Out of curiosity, which version of POJO Cache are you using?
"jacobeukes" wrote :
| Would it be possible to post the configuration file (in which you specify the MBean configuration) ?
Here is a minimal config you could use to deploy POJO Cache as an MBean. It is for POJO Cache version 1.4.1 which is the default POJO Cache that comes with JBoss 4.2.1
<?xml version="1.0" encoding="UTF-8"?>
| <server>
| <mbean code="org.jboss.cache.aop.PojoCache"
| name="jboss.cache:service=PojoCache">
| <depends>jboss:service=Naming</depends>
| <depends>jboss:service=TransactionManager</depends>
| <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute>
| <attribute name="NodeLockingScheme">OPTIMISTIC</attribute>
| <attribute name="CacheMode">LOCAL</attribute>
| <attribute name="LockAcquisitionTimeout">1000</attribute>
| <attribute name="BuddyReplicationConfig">
| <config>
| <buddyReplicationEnabled>false</buddyReplicationEnabled>
| </config>
| </attribute>
| </mbean>
| </server>
"jacobeukes" wrote :
| I have tried to configure and deploy it as an MBean and also tried running it as a standalone application (as part of a test), but I am just not having any luck.
|
The MBean deployment can be quite dependent on getting the right config attributes. If the attibutes or settings aren't quite right, you can get a lot of errors or unexpected behaviour.
"manik.surtani(a)jboss.com" wrote :
| Bruce's case probably worked since when you retrieve the cache from an MBean server rather than create a new one each tme, both cases use the same cache.
|
Manik is absolutely correct. With an MBean deployment, every access to the cache is accessing the same MBean.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4091949#4091949
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4091949
18Â years, 8Â months