0

I am using Hibernate 3 in Websphere Application Server 6.1. I am using JNDI to connect to my datasource. I checked the connection in Admin console and the connection was successful. But when I deploy my project in the server and connect to the datasource using JNDI I am getting below error message.

Caused by: java.lang.NullPointerException
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:159)
    at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2163)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2159)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1383)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)

It shows cause:null.

I use Oracle 10g database.

I see some more exceptions in the log. Is this related to this problem?

00000027 RegisteredRes E   WTRN0078E: An attempt by the transaction manager to call start on a transactional resource has resulted in an error. The error code was XAER_RMERR. The exception stack trace follows: oracle.jdbc.xa.OracleXAException
    at oracle.jdbc.xa.OracleXAResource.checkError(OracleXAResource.java:1157)
    at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:295)
    at com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl.start(WSRdbXaResourceImpl.java:1324)
    at com.ibm.ejs.j2c.XATransactionWrapper.start(XATransactionWrapper.java:1467)
    at com.ibm.ws.Transaction.JTA.JTAResourceBase.start(JTAResourceBase.java:141)
    at com.ibm.ws.Transaction.JTA.RegisteredResources.startRes(RegisteredResources.java:1103)
    at com.ibm.ws.Transaction.JTA.RegisteredResources.enlistResource(RegisteredResources.java:525)
    at com.ibm.ws.Transaction.JTA.TransactionImpl.enlistResource(TransactionImpl.java:3219)
    at com.ibm.ws.Transaction.JTA.TranManagerSet.enlist(TranManagerSet.java:396)
    at com.ibm.ejs.j2c.XATransactionWrapper.enlist(XATransactionWrapper.java:693)
    at com.ibm.ejs.j2c.ConnectionManager.lazyEnlist(ConnectionManager.java:1723)
    at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.lazyEnlist(WSRdbManagedConnectionImpl.java:2109)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.beginTransactionIfNecessary(WSJdbcConnection.java:600)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.getMetaData(WSJdbcConnection.java:1533)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:116)
    at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2163)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2159)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1383)
    at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)

Another exception is

    00000027 XATransaction E   J2CA0030E: Method enlist caught javax.transaction.SystemException: XAResource start association error:XAER_RMERR
    at com.ibm.ws.Transaction.JTA.RegisteredResources.startRes(RegisteredResources.java:1154)
    at com.ibm.ws.Transaction.JTA.RegisteredResources.enlistResource(RegisteredResources.java:525)
    at com.ibm.ws.Transaction.JTA.TransactionImpl.enlistResource(TransactionImpl.java:3219)
    at com.ibm.ws.Transaction.JTA.TranManagerSet.enlist(TranManagerSet.java:396)
    at com.ibm.ejs.j2c.XATransactionWrapper.enlist(XATransactionWrapper.java:693)
    at com.ibm.ejs.j2c.ConnectionManager.lazyEnlist(ConnectionManager.java:1723)
    at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.lazyEnlist(WSRdbManagedConnectionImpl.java:2109)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.beginTransactionIfNecessary(WSJdbcConnection.java:600)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.getMetaData(WSJdbcConnection.java:1533)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:116)
    at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2163)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2159)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1383)
    at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
Caused by: oracle.jdbc.xa.OracleXAException
    at oracle.jdbc.xa.OracleXAResource.checkError(OracleXAResource.java:1157)
    at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:295)
    at com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl.start(WSRdbXaResourceImpl.java:1324)
    at com.ibm.ejs.j2c.XATransactionWrapper.start(XATransactionWrapper.java:1467)
    at com.ibm.ws.Transaction.JTA.JTAResourceBase.start(JTAResourceBase.java:141)
    at com.ibm.ws.Transaction.JTA.RegisteredResources.startRes(RegisteredResources.java:1103)
while trying to enlist resources from datasource jdbc/OracleData with the Transaction Manager for the current transaction, and threw a ResourceException.

Below is my hibernate configuration file:

<hibernate-configuration>
    <session-factory>
        <property name="dialect">
            org.hibernate.dialect.Oracle10gDialect
        </property>
        <property name="hibernate.transaction.factory_class">
            org.hibernate.transaction.JTATransactionFactory
        </property>
        <property name="hibernate.transaction.manager_lookup_class">
            xxx.xxx.xxx.WebSphereExtendedJTATransactionLookup
        </property>
        <property name="jta.UserTransaction">
            java:comp/UserTransaction
        </property>
    </session-factory>
</hibernate-configuration>

Here WebSphereExtendedJTATransactionLookup implements org.hibernate.transaction.TransactionManagerLookup

This is how I create session

final Configuration configuration = new AnnotationConfiguration();
configuration.setProperty("hibernate.connection.datasource", dataSource);
configuration.setProperty(org.hibernate.cfg.Environment.SHOW_SQL, System.getProperty(SHOW_SQL,"false"));
configuration.configure();
return configuration.buildSessionFactory();

1 Answers1

0

unfortunately I can't say much without looking at your configuration files but I will give it a try. This error seems to be a problem with the connection configuration between your App and JNDI pool.

  • Make sure your Deployment Descriptor(web.xml) contains the configuration for the JNDI connection, ex:
    
        <resource-ref>
            <description>Your New DataSource</description>
            <res-ref-name>jdbc/mysqlblogpostdataref</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
        </resource-ref>
    
  • And lookup on your hibernate.cfg(Assuming you are not using Spring) for configuration issues, here goes another ex:


<property name="current_session_context_class">thread</property>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.connection.datasource">java:comp/env/jdbc/mysqlblogpostdataref</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
Also, make sure to verify the config at you context.xml file as quoted here Configure hibernate to connect to database via JNDI Datasource.

Source for the other examples: http://jefferyhaynes.net/2009/11/29/websphere-hibernate-datasource-configuration-for-mysql/

EDIT Based on your update I was able to do some research, look what I've found:

(from: IBM)

The error is that the transaction manager was unable to convert the transaction to an XA transaction. Specifically, Oracle returned an error XAER_RMERR, error code number 65535. ORA-65535 is not a valid error code and XAER_RMERR essentially means that something went wrong with XA. What this indicates is that your Oracle database is not configured to support XA transactions. Therefore, when the WebSphere Application Server transaction manager instructs the Oracle transaction manager to participate in this XA transaction, Oracle cannot comply and throws this exception.

Also, just be sure, have a look at your context.xml and web.xml file, when working with WS I used to forget configuring those.

Community
  • 1
  • 1
Ederson
  • 133
  • 4
  • Hi, I have given the data source jndi name correctly. The same project works when I give all the configuration in the hibernate.cfg file itself (like database server url, username, password). But it fails when I do the same with jndi. I want to use websphere global transaction(XA) between MQ and my oracle database. I see some more exceptions in the log. I have updated them in the question. Please have a look. – Prabu Dhanapal Jun 06 '13 at 04:27