I've validated this again - and double checked my set-up but can see nothing
wrong.
As I mentioned before JBoss container managed transactions are working fine
with raw JDBC access, but not with Castor.
It could be (and I hope it is :) ) just a set-up problem - but I'm really
stumped here.
Has anyone successfully used Castor with JBoss and has validated that it's
working correctly with CMT?? (Unless you test throwing an exception it will
probably *appear* to work fine).
I'd really appreciate any help here since as I'd really like to commit to
Castor on our project- it seems a great product - but this is kind of
scuppering us at the moment.
Thanks in advance.



-----Original Message-----
From: Tim Fox [mailto:[EMAIL PROTECTED]]
Sent: 07 August 2001 14:26
To: [EMAIL PROTECTED]
Subject: [castor-dev] Castor not rolling back transaction in ejb server


I'm using Castor 0.9.3 in JBoss to provide persistence for my classes, and
using container manager transactions.

The code appeared to be all working fine, until I decided to a transaction
test.
The test basically creates 2 business objects in an ejb method, and then
throws a javax.ejb.EJBException - this should result in the transaction
being rolled back.
I've also tried setting setRollbackOnly() on the context, but in either case
the transaction doesn't roll back, and the objects are committed to the
database.

Here's an example of my code from the ejb:

    //Test transaction using castor rollback correctly
    public void testTransactions()
    {
        try
        {
            Database db = null;
            try
            {
                db = CastorHelper.instance().getDB();
                Log.info("autostore is " + db.isAutoStore());

                //do something in db
                SystemProperty prop = new SystemProperty();
                prop.setName("wibble1");
                prop.setValue("value");
                db.create(prop);
                Log.info("Created wibble1");
            }
            finally
            {
                if (db != null && !db.isClosed()) db.close();
            }

            try
            {
                db = CastorHelper.instance().getDB();

                //do something in db
                SystemProperty prop = new SystemProperty();
                prop.setName("wibble2");
                prop.setValue("value");
                db.create(prop);
                Log.info("Created wibble2");

                //Now throw an exception - everything should rollback
                throw new RuntimeException("oooooh!! nurse");
            }
            finally
            {
                if (db != null && !db.isClosed()) db.close();
            }
        }
        catch(Exception e)
        {
            Log.error("Caught exception", e);
            throw new javax.ejb.EJBException("blah", e);
        }
    }


The CastorHelper class simply gets the DataObjects class from JNDI and
invokes the getDatabase() method on it.

The deployment descriptor for my ejb specifies container transactions.

I don't think this is a JBoss problem, since everything seems to work ok
with raw JDBC access.

Help!!!!

-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to