Announcement Announcement Module
No announcement yet.
JTA propagation - XA datasources in glassfish 3 - not behaving Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JTA propagation - XA datasources in glassfish 3 - not behaving

    Hi all

    I've got a set up that is using JPA persistence.xml with JTA transactions from Glassfish 3. There are a number of XA datasources running with the Oracle ojdbc6 XA Datasource.

    The problem is that it seems to me after two days of exploration is that Transactions appear to be almost always set (or behaves as if set) to REQUIRES_NEW - even if across the same datasource (!).

    configuration is as follows;
    <tx:annotation-driven />
    <bean id="dao" class="myDaoImpl"/>
    <bean id="service" class="mySvc">
        <property name="dao" ref="dao" />
    "myDaoImpl" has an entity manager;

    @PersistenceContext(unitName = "twoPU")
    private EntityManager entityManager;
    and a method;

        public List<Item> getDataAndMarkAsDone(String arg1, String ar2, String arg3) {
        // query items
        // now mark them as "done".
        // return them
    "mySvc" has a method;

    @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly=false)
     public Result handle(RequestObject inMessage) {
      List<Item> = dao.getDataAndMarkAsDone(string1, string2, string3);
      // now do something else with the items, which doesn't involve a db
      // OH NO!!! throws RuntimeException("not at all good");
    I would have expected that the 'myDao' method is enrolled in the transaction from 'mySvc'. 'mySvc' in this case has no Entity Manager (not that this makes any difference if I add one).

    The problem seems to be that also "mySvc" throws a Runtime exception, the Transaction in "myDao" is not enrolled in it, and commits its changes.

    In fact if I change the "Transactional(propagation=Propagation.REQUIRE D)" on the "myDao" method to "Transactional(propagation=Propagation.MANDATO RY)" then I get exceptions complaining that there's no available transaction.

    However, if I call from one method in "myDao" to another method in "myDao" which is marked Propagation.MANDATORY the transaction propagates.

    Its like every call to a each new spring bean is like it is REQUIRES_NEW (i.e. REQUIRED results in a new transaction) or it doesn't work -- even when the two Spring beans are defined to use the same PersistentContext unitName (it's actually lucky the case is that I need the two different persistence units to actaully be in different transactions!). It seems to me that my JTA transaction manager, or my XA driver configuration is stuffed up. I found some mention of an Oracle XA driver property called "nativeXA" which Glassfish 2.x sets to "false" by default which I manually added to be "true" (in a couple of different variations because it seems to be unclear to me the exact name of this property) but it doesn't seem to make any difference.

    It's spent three days now driving me barmy. Anyone got any ideas or experience with this configuration?

    oh my Spring persistenceUnits config

    <bean class="">
        <property name="persistenceUnits">
            <entry key="onePU" value="persistence/onePU" />
            <entry key="twoPU" value="persistence/twoPU" />
    and my actual persistence.xml:

    <persistence xmlns="" xmlns:xsi=""
      xsi:schemaLocation="" version="2.0">
      <persistence-unit name="onePU" transaction-type="JTA">
     ... classes ...    
    <exclude-unlisted-classes />
          <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
          <property name="hibernate.default_schema " value="one" />
          <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.SunONETransactionManagerLookup" />
      <persistence-unit name="twoPU" transaction-type="JTA">
        ... classes ....
        <exclude-unlisted-classes />
          <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
          <property name="hibernate.default_schema " value="two" />
          <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.SunONETransactionManagerLookup" />

  • #2
    Hi Scot,
    Were you able to resolve your issue?
    I think I'm noticing much the same behavior.
    Thanks in advance for your feedback