We are trying to use hibernate in an an application that will also call existing EJB Stateless session bean services. We are using WAS 5.1, Stateless Session beans w/ CMT. Our "hibernate DAO"-only services work fine as do the existing legacy services. however a problem arises when we mix the two together. If we try to call a legacy Service from within one of our Hibernate Services we get an error that an XA-compliant jdbc driver. Note that both services hit the same database so there should not be a need for an XA driver. All of the methods are set to "Transaction Required" We want to call the legacy EJB from within our hibernate EJB in order to have
all of the work under the same transaction.
I am including some WAS PoolManager tracing below that indicates that the Principal and Private Credential are input parms when the legacy DAO gets a connection from the pool, but are absent when a hibernate DAO gets a connection from the pool. I think this may be what causes the PoolManager to issue a separate connection. Any advice on how to pass the credentials would be appreciated.
Hibernate version: Hibernate 3.1.2 on WAS 5.1
Mapping documents:
Code:
<hibernate-configuration>
<session-factory name="sf">
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="hibernate.connection.datasource">jdbc/EPDatabase</property>
<property name="hibernate.default_schema">DEVUSER</property>
<property name="hibernate.dialect">org.hibernate.dialect.DB2Dialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.use_sql_comments">false</property>
<!-- <property name="hibernate.transaction.auto_close_session">true</property>
-->
<!-- Enable Hibernate's automatic session context management -->
<property name="hibernate.session_factory_name">HibernateSessionFactory</property>
<!-- Transaction API -->
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WebSphereTransactionManagerLookup</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
<!-- <property name="hibernate.current_session_context_class">thread</property> -->
<!-- Mapping Files for Value Objects -->
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Hibernate Connection Request
[2/10/06 17:22:26:868 MST] 68c91135 ConnectionMan > allocateConnection
[2/10/06 17:22:26:878 MST] 68c91135 ConnectionMan d This CM is [ConnectionManager]@2df95120JNDI Name <jdbc/EPDatabase>shareable <true>
[2/10/06 17:22:26:878 MST] 68c91135 ConnectionMan d Input MCF is com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl@7b83912a
[2/10/06 17:22:26:878 MST] 68c91135 ConnectionMan d This CM's MCF is com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl@7b83912a
[2/10/06 17:22:26:878 MST] 68c91135 DefaultSecuri > finalizeSubject
[2/10/06 17:22:26:878 MST] 68c91135 DefaultSecuri < finalizeSubject
[2/10/06 17:22:26:878 MST] 68c91135 DefaultSecuri > beforeGettingConnection
[2/10/06 17:22:26:878 MST] 68c91135 DefaultSecuri < beforeGettingConnection
[2/10/06 17:22:26:878 MST] 68c91135 ConnectionMan > allocateMCWrapper
[2/10/06 17:22:26:878 MST] 68c91135 PoolManager > reserve
[2/10/06 17:22:26:878 MST] 68c91135 PoolManager d input parms... subject = null affinity = com.ibm.ws.Transaction.JTA.TransactionImpl@19ded133#tid=691 Shared connection = true Force new MC = false Connection Request Information = com.ibm.ws.rsadapter.spi.WSConnectionRequestInfoImpl@4
UserName = null
Password = null
Catalog = null
IsReadOnly = null
TypeMap = null
Isolation = REPEATABLE READ
Support isolation switching = false
Handle type = java.sql.Connection
[2/10/06 17:22:26:878 MST] 68c91135 PoolManager d reserve(), Pool contents ==> PoolManager name:jdbc/EPDatabasePoolManager object:1935561003Total number of connections: 5 (max/min 10/1)Pool Bucket configuration Shared Buckets: 200 UnShared Buckets: 10Shared Connection information
========================================================================================================================================================================
Legacy Connection Request
2/10/06 17:22:26:898 MST] 68c91135 ConnectionMan > allocateConnection
[2/10/06 17:22:26:898 MST] 68c91135 ConnectionMan d This CM is [ConnectionManager]@7b045128JNDI Name <jdbc/EPDatabase>shareable <true>
[2/10/06 17:22:26:898 MST] 68c91135 ConnectionMan d Input MCF is com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl@7b83912a
[2/10/06 17:22:26:898 MST] 68c91135 ConnectionMan d This CM's MCF is com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl@7b83912a
[2/10/06 17:22:26:898 MST] 68c91135 ConnectionMan > getSubject
[2/10/06 17:22:26:898 MST] 68c91135 PrivExAction d calling WSDPM.getSubject(com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl@7b83912a, DefaultPrincipalMapping, EP DB ID)
[2/10/06 17:22:26:898 MST] 68c91135 ConnectionMan < getSubject returning non-null Subject
[2/10/06 17:22:26:898 MST] 68c91135 DefaultSecuri > finalizeSubject
[2/10/06 17:22:26:898 MST] 68c91135 DefaultSecuri < finalizeSubject
[2/10/06 17:22:26:898 MST] 68c91135 DefaultSecuri > beforeGettingConnection
[2/10/06 17:22:26:898 MST] 68c91135 DefaultSecuri < beforeGettingConnection
[2/10/06 17:22:26:898 MST] 68c91135 ConnectionMan > allocateMCWrapper
[2/10/06 17:22:26:898 MST] 68c91135 PoolManager > reserve
[2/10/06 17:22:26:898 MST] 68c91135 PoolManager d input parms...
subject = Subject:
Principal: BBauto10@BBauto10
Private Credential: javax.resource.spi.security.PasswordCredential@c7fe3400
affinity = com.ibm.ws.Transaction.JTA.TransactionImpl@19ded133#tid=691 Shared connection = true Force new MC = false Connection Request Information = com.ibm.ws.rsadapter.spi.WSConnectionRequestInfoImpl@4
UserName = null
Password = null
Catalog = null
IsReadOnly = null
TypeMap = null
Isolation = REPEATABLE READ
Support isolation switching = false
Handle type = java.sql.Connection
[2/10/06 17:22:26:898 MST] 68c91135 PoolManager d reserve(), Pool contents ==> PoolManager name:jdbc/EPDatabasePoolManager object:1935561003Total number of connections: 5 (max/min 10/1)
Name and version of the database you are using:
DB2 8.1