1 Reply Latest reply on May 30, 2006 7:56 AM by Dirk Haase

    Maintaining TX across EJBs and POJOs using JDBC, notifying o

    jrinderle Newbie


      I am working on an application which accepts "plugins". This is accomplished with an interface which the plugins implement. The plugins are invoked from a stateful session bean using container managed TXs. The TX demarcation for the calling method is "Required". Some of the client plugins will be EJB based while others will use JDBC.

      How do I ensure everything takes place in the same transaction?

      To further complicate matters, the plugins manipulate the file system. The application requires the file system to be kept in a consistent state. The plugins need to be notified of the outcome of the TX (commit or rollback) and clean-up accordingly. What's the best way to do this?

      Should the calling EJB implement SessionSynchronization and notify the plugins in after afterCompletion? Should my plug-in API extend Synchronization so I can register the plugins with the TX manger some how? What about the non-EJB, JDBC case? (I cannot use setAutoCommit(), commit(), etc.. because the TX context follows the thread).

      My current implementation has begin(), comit(), and rollback() methods on the plugins. I have the plugins using new user transactions which I notify. However, this creates locking problems if one of the plugins references an row locked by the outer TX.

      Your suggestions are greatly appreciated!

        • 1. Re: Maintaining TX across EJBs and POJOs using JDBC, notifyi
          Dirk Haase Newbie

          I don't fully understand what you are doing, but concerning the necessity to have it all in one transaction:
          if your datasources are configured in *-ds.xml files and obtained via jndi lookup, then this will all happen in one server transaction. If you are using different datasources, all but one need to be xa-enabled. If you get your datasource via jndi lookup and specify the same datasource as your EJB persistance datasource, then you will get the same database connection so you won't have to worry about xa.