Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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().

like image 571
rfders Avatar asked Sep 30 '10 00:09

rfders


2 Answers

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>  
like image 179
Yaro Avatar answered Nov 15 '22 20:11

Yaro


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

like image 28
Alexx Avatar answered Nov 15 '22 21:11

Alexx