Error getting JDBC Connection: Could not enlist in transaction on entering meta-aware object

14,853

Solution 1

I changed my transaction manager to be bean-managed and it works perfectly.

Solution 2

Can try, for old Jboss-es: /server/all/conf/jbossjta-properties.xml

<properties depends="arjuna" name="jta">
   <property name="com.arjuna.ats.jta.allowMultipleLastResources" value="true"/>
</properties>

for new: standalone\configuration\standalone.xml (or other what you use)

<system-properties>
    <property name="com.arjuna.ats.arjuna.allowMultipleLastResources"   value="true"/>
</system-properties>  

Solution 3

I have noticed this in cases where the tx times out. FWIW.

Share:
14,853
rfders
Author by

rfders

Updated on June 09, 2022

Comments

  • rfders
    rfders almost 2 years

    I am having a problem getting a JDBC connection in an EJB SessionBean. The error is:

    org.jboss.util.NestedSQLException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings.

    I thought this happens, because I already have an open connection from a different datasource, so I configured an XA datasource to avoid transaction problems, but it doesn't work at all, so I don't know if I am doing something wrong in my code. Here it is:

      try 
        {
            Properties p = new Properties();
            p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
            p.put(Context.PROVIDER_URL,"jnp://localhost:11099");
            p.put("java.naming.factory.url.pkgs", "org.jboss.naming");
    
            InitialContext ic = new InitialContext(p);
    
            DataSource dataSource = (DataSource)ic.lookup("java:/jdbc/etlreportservices");
    
            return dataSource.getConnection();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    

    The exception is thrown while calling dataSource.getConnection().

  • Sam Orozco
    Sam Orozco almost 8 years
    Yeah, but how? This didn't help me very much. Probably the right answer but not thorough enough.
  • k32y
    k32y almost 5 years
    It would've been helpful if you added some code or description on how to change your transaction manager to be bean managed.
  • Victor
    Victor almost 4 years
    Had the same issue and it was because the bean was missing the @TransactionManagement(TransactionManagementType.BEAN) annotation.