Websphere Application Server 6.1 で Hibernate 3 を使用しています。JNDI を使用してデータソースに接続しています。管理コンソールで接続を確認したところ、接続に成功しました。しかし、プロジェクトをサーバーにデプロイし、JNDI を使用してデータソースに接続すると、以下のエラー メッセージが表示されます。
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)
cause:null と表示されます。
Oracle 10g データベースを使用しています。
ログにいくつかの例外が表示されます。これはこの問題に関連していますか?
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)
もう一つの例外は
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.
以下は私の休止状態の設定ファイルです:
<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>
ここでWebSphereExtendedJTATransactionLookupはorg.hibernate.transaction.TransactionManagerLookupを実装します
これは私がセッションを作成する方法です
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();