-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Problem w/ WAS ConnectionPool
PostPosted: Fri Mar 10, 2006 8:05 pm 
Newbie

Joined: Fri Feb 03, 2006 10:06 pm
Posts: 4
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





Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 13, 2006 11:43 am 
Newbie

Joined: Fri Feb 03, 2006 10:06 pm
Posts: 4
Including the error we get when NOT using XA driver. Since this is the same thread asking for a connection to the same database there is no reason we should be using XA...in fact we are now seeing issues with Lock timeouts when we do use it and there are db constrainst between tables used in each individual XA connection.


Code:
[3/13/06 8:38:58:388 MST]  13a8313 TransactionIm E WTRN0062E: An illegal attempt to use multiple resources that have only one-phase capability has occurred within a global transaction.
[3/13/06 8:38:58:558 MST]  13a8313 LocalTransact E J2CA0030E: Method enlist caught com.ibm.ws.Transaction.IllegalResourceIn2PCTransactionException
   at com.ibm.ws.Transaction.JTA.TransactionImpl.enlistResource(TransactionImpl.java:1788)
   at com.ibm.ws.Transaction.JTA.TranManagerSet.enlistOnePhase(TranManagerSet.java:525)
   at com.ibm.ejs.j2c.LocalTransactionWrapper.enlist(LocalTransactionWrapper.java:517)
   at com.ibm.ejs.j2c.ConnectionEventListener.interactionPending(ConnectionEventListener.java:753)
   at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.processInteractionPendingEvent(WSRdbManagedConnectionImpl.java:1545)
   at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.beginTransactionIfNecessary(WSJdbcConnection.java:385)
   at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:1519)
   at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:1487)
   
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 13, 2006 1:00 pm 
Newbie

Joined: Fri Feb 03, 2006 10:06 pm
Posts: 4
Figured out the problem after a few hours of google-time:

http://www-1.ibm.com/support/docview.ws ... -8&lang=en

Quote:
For example, the application can potentially call two connections in the same transaction. The first connection is obtained from a data source that is looked up through a resource reference using indirect lookup (java:comp/env/jdbc/ds1). The second connection is acquired from a data source that is looked up directly (jdbc/ds1). The difference is that when a resource reference is used, some settings from the resource reference are picked up. In this case, it is the authentication type with is container. When there is no resource reference the default authentication types of application are used.



By changing hibernate.cfg.xml to use an indirect JNDI lookup, the problem went away.


Code:
<property name="hibernate.connection.datasource">java:comp/env/jdbc/EPDatabase</property>

instead of :
Code:
  <property name="hibernate.connection.datasource">jdbc/EPDatabase</property>


Also, the following message in our log should have been a dead giveaway as to there being a problem w/ the JNDI lookup

[
Code:
3/13/06 9:43:37:346 MST] 3c578bc4 ConnectionFac I J2CA0122I: Resource reference jdbc/EPDatabase could not be located, so default values of the following are used: [Resource-ref settings]

   res-auth:                 1 (APPLICATION)
   res-isolation-level:      0 (TRANSACTION_NONE)
   res-sharing-scope:        true (SHAREABLE)
   res-resolution-control:   999 (undefined)
[Other attributes]

isCMP1_x:                 false (not CMP1.x)
isJMS:                 false (not JMS)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.