[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3676) Unable to Load JTA Transaction

pioneer (JIRA) noreply at atlassian.com
Wed Dec 24 07:11:38 EST 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32018#action_32018 ] 

pioneer commented on HHH-3676:
------------------------------

We can rewrite the method as like this....


 public Session currentSession()
        throws HibernateException
    {
        TransactionManager transactionManager = factory.getTransactionManager();
        if(transactionManager == null)
            throw new HibernateException("No TransactionManagerLookup specified");
        Transaction txn;
        try
        {
            txn = transactionManager.getTransaction();
            if(txn == null)
                throw new HibernateException("Unable to locate current JTA transaction");
            if(!JTAHelper.isInProgress(txn.getStatus()))
                throw new HibernateException("Current transaction is not in progress");
        }
        catch(HibernateException e)
        {
            throw e;
        }
        catch(Throwable t)
        {
            throw new HibernateException("Problem locating/validating JTA transaction", t);
        }

	Session currentSession = null;
  	if ( txn != null && !JTAHelper.isInProgress( txn.getStatus() ) ) {
	               throw new HibernateException( "Current transaction is not in progress" );
	    } else if (txn != null) {
	              currentSession = ( Session ) currentSessionMap.get( txn );
	    }

        if(currentSession == null)
        {
            currentSession = buildOrObtainSession();
            try
            {
                txn.registerSynchronization(buildCleanupSynch(txnIdentifier));
            }
            catch(Throwable t)
            {
                try
                {
                    currentSession.close();
                }
                catch(Throwable ignore)
                {
                    log.debug("Unable to release generated current-session on failed synch registration", ignore);
                }
                throw new HibernateException("Unable to register cleanup Synchronization with TransactionManager");
            }
            currentSessionMap.put(txnIdentifier, currentSession);
        }
        return currentSession;
    }


> Unable to Load JTA Transaction
> ------------------------------
>
>                 Key: HHH-3676
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3676
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>         Environment: Hibernate3, Weblogic 9.0
>            Reporter: pioneer
>
> This is my hibernat.cfg.xml file which i have been using for my app. me trying out an J2ee Application within an weblogic 9.0 . As my config denotes its exactly true.When WeblogicTransactionManagerLookup tries to look out for tranaction within JTASessionContext within currentSession() method , it returns due to the following line.
> if(txn == null)
> {
>   throw new HibernateException("Unable to load JTA Transaction);
> }
> this line didn't allow to proceed within the method to create an new session. Its an bug with JTASessionContext. Correct me if iam wrong.
> <property name="connection.datasource">jdbc/connectionPool</property>
> <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
> <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</property>
> <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property> 
> <property name="hibernate.current_session_context_class">jta</property> 
> <property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property> 
> <property name="hibernate.cache.use_query_cache">true</property>
> <property name="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</property>  
> <property name="show_sql">true</property>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list