tags:

views:

213

answers:

0

I am running a J2EE application on Oracle Application Server 10.1.3.1 that will save to 2 Oracle databases (9i and 10g) within the same method in some cases. In order for this to take place, we are using XA drivers for both data sources and Hibernate to abstract the integration layer. Hibernate sessions are singletons and are owned by whichever class gets them first, which are the only classes that can close them. In this example, all EJB methods get a hibernate session, but only the MDB can close it since it created the session.

The part of the application I am currently having problems with starts in an MDB, calls methods in multiple EJBs one of which calls a regular Java class. The basic flow of my classes are pseudo-coded below.

//main class that drives the whole process
public class exampleMDB implements MessageDrivenBean, MessageListener{

    public void onMessage(Message msg) {
        get database 1 Hibernate session

        call loggerEJB.savetodb1(somexml)

        call processorEJB.process(somexml)

        call loggerEJB.savetodb1(somexml)

        close database 1 Hibernate session
    }

}

//handles all saves to database 1
public class loggerEJB {

    public void savetodb1(Document somexml) {

        save somexml to database 1

    }

}

//gets database 2 session and calls regular java class
public class processorEJB {

    public Document process(Document somexml) {
        get database 2 Hibernate session

        call processorJavaClass.process(somexml)

        close database 2 Hibernate session

        return somexml
    }

}

//saves to both database 1 (through loggerEJB) and database 2
public class processorJavaClass {

    public Document process(Document somexml) {

        call loggerEJB.savetodb1(somexml)

        save something directly to database 2 using Hibernate DAO

        return somexml

    }

}

So, loggerEJB handles all saves to database 1 while database 2 is only saved to with direct Hibernate DAO calls by processorJavaClass. The problem occurs when I return from the processorEJB and go to call the loggerEJB for the second time from the MDB. The transaction is created in database 1, but the document somexml, which is a CLOB datatype, is not saved even though it can be followed all the way to the save call in the Hibernate DAO. So, the transaction is only partially saved. However, if I remove the loggerEJB.savetodb1 call from the processorJavaClass the second log in the MDB works as expected (somexml is saved).

Has anyone ever seen information not posted like this while working with Hibernate, XA and OAS? Do CLOB datatypes not play nice with XA datasources? Or is Hibernate or OAS the more likely problem?

Thanks for your help.