-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problem configuring Hibernate transactions with Websphere6
PostPosted: Wed Apr 27, 2005 10:44 am 
Beginner
Beginner

Joined: Thu Apr 21, 2005 12:15 pm
Posts: 34
After alot of problems and misunderstandings I have almost got Hibernate to create a record when running in Websphere 6 but it is complaining it cannot find UserTransaction in JNDI. Is this something I have to do, I have created a JTA based Datasource in Websphere and Hibernate can use this Datasource to retrieve records but is unable to create them.

This is my hibernate config file
Code:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 2.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration.                   -->
<hibernate-configuration>

    <session-factory>
        <property name="connection.datasource">jdbc/PortfolioDataSource</property>
   <property name="dialect">net.sf.hibernate.dialect.OracleDialect</property>
   <property name="show_sql">true</property>
   <property name="transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
   <property name="transaction.manager_lookup_class">net.sf.hibernate.transaction.WebSphereTransactionManagerLookup</property>

        <!-- mapping files -->
        <mapping resource="com/abnamro/att/server/domain/PtfPortfolio.hbm.xml"/>
        <mapping resource="com/abnamro/att/server/domain/StlStockline.hbm.xml"/>
        <mapping resource="com/abnamro/att/server/domain/TrdTrade.hbm.xml"/>

    </session-factory>

</hibernate-configuration>


This is my Session Bean Code
Code:
public void createPortfolio(PortfolioVO portfolioVO) throws EJBException
    {
        System.out.println("Creating new Portfolio");
        try
        {
            Session s = HibernateSessionFactory.currentSession();     
           
            try
            {
                Transaction tx = s.beginTransaction();
                PtfPortfolio ptfPortfolio = new PtfPortfolio();
                ptfPortfolio.setPtfPk(new Long(100));
                ptfPortfolio.setName(portfolioVO.getName());
                ptfPortfolio.setDescription(portfolioVO.getDescription());
                ptfPortfolio.setVolume(portfolioVO.getVolume());

                s.save(ptfPortfolio);               
                tx.commit();
            }
            finally
            {
                HibernateSessionFactory.closeSession();
            }
           

        }
        catch (Exception e)
        {
            System.out.println("Failed to Create new Portfolio");
            throw new EJBException("Failed to create portfolio", e);
        }
        System.out.println("Created new Portfolio");
    }



This is the stacktrace starting from entering my Session Bean.
Code:
[27/04/05 15:37:32:250 BST] 00000076 JTATransactio E   Could not find UserTransaction in JNDI
[27/04/05 15:37:32:250 BST] 00000076 JTATransactio E   TRAS0014I: The following exception was logged javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".
   at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1091)
   at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:987)
   at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1263)
   at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:198)
   at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:139)
   at javax.naming.InitialContext.lookup(InitialContext.java:361)
   at net.sf.hibernate.transaction.JTATransaction.begin(JTATransaction.java:133)
   at net.sf.hibernate.transaction.JTATransactionFactory.beginTransaction(JTATransactionFactory.java:58)
   at net.sf.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:2252)
   at com.abnamro.att.server.ejb.PortfolioBean.CreatePortfolio(PortfolioBean.java:114)
   at com.abnamro.att.server.interfaces.EJSRemoteStatelessPortfolio_c29e384f.CreatePortfolio(Unknown Source)
   at com.abnamro.att.server.interfaces._Portfolio_Stub.CreatePortfolio(_Portfolio_Stub.java:259)
[/code]
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 28, 2005 9:15 am 
Beginner
Beginner

Joined: Thu Apr 21, 2005 12:15 pm
Posts: 34
Has anybody got Hibernate working with Websphere 6 ?
Ive taken alook at the WebSphereTransactionManagerLookup and it doesnt specifically check for Websphere 6, but does find the same transactionManagerFactory class as used by Websphere 5, so assumes Websphere 5 which might be ok.

There is also a WebSphereExtendedJTATransactionLookup class which doe s mention Websphere 6 but using this prevents me from even retrieving data from the database.

Have I got to configure some JNDi settings, in the documentation these are marked as optional but are they required for my setup?

I have managed to get logging working properly now and the full logging trace is
Code:
[28/04/05 13:59:19:934 BST] 0000006f Configuration I   Configuration resource: /hibernate.cfg.xml
[28/04/05 13:59:20:168 BST] 0000006f Configuration I   Mapping resource: com/abnamro/att/server/domain/PtfPortfolio.hbm.xml
[28/04/05 13:59:20:309 BST] 0000006f Binder        I   Mapping class: com.abnamro.att.server.domain.PtfPortfolio -> PTF_PORTFOLIO
[28/04/05 13:59:20:575 BST] 0000006f Configuration I   Mapping resource: com/abnamro/att/server/domain/StlStockline.hbm.xml
[28/04/05 13:59:20:590 BST] 0000006f Binder        I   Mapping class: com.abnamro.att.server.domain.StlStockline -> STL_STOCKLINE
[28/04/05 13:59:20:653 BST] 0000006f Configuration I   Mapping resource: com/abnamro/att/server/domain/TrdTrade.hbm.xml
[28/04/05 13:59:20:684 BST] 0000006f Binder        I   Mapping class: com.abnamro.att.server.domain.TrdTrade -> TRD_TRADE
[28/04/05 13:59:20:684 BST] 0000006f Configuration I   Configured SessionFactory: null
[28/04/05 13:59:20:684 BST] 0000006f Configuration I   processing one-to-many association mappings
[28/04/05 13:59:20:700 BST] 0000006f Configuration I   processing one-to-one association property references
[28/04/05 13:59:20:731 BST] 0000006f Configuration I   processing foreign key constraints
[28/04/05 13:59:20:793 BST] 0000006f Dialect       I   Using dialect: net.sf.hibernate.dialect.OracleDialect
[28/04/05 13:59:20:825 BST] 0000006f SettingsFacto I   Use outer join fetching: true
[28/04/05 13:59:20:840 BST] 0000006f NamingHelper  I   JNDI InitialContext properties:{}
[28/04/05 13:59:20:871 BST] 0000006f ConnectionFac W   J2CA0294W: Deprecated usage of direct JNDI lookup of resource jdbc/PortfolioDataSource.  The following default values are used: [Resource-ref settings]

   res-auth:                 1 (APPLICATION)
   res-isolation-level:      0 (TRANSACTION_NONE)
   res-sharing-scope:        true (SHAREABLE)
   loginConfigurationName:   null
   loginConfigProperties:    null
[Other attributes]

   res-resolution-control:   999 (undefined)
isCMP1_x:                 false (not CMP1.x)
isJMS:                 false (not JMS)

[28/04/05 13:59:20:918 BST] 0000006f DatasourceCon I   Using datasource: jdbc/PortfolioDataSource
[28/04/05 13:59:20:934 BST] 0000006f TransactionFa I   Transaction strategy: net.sf.hibernate.transaction.JTATransactionFactory
[28/04/05 13:59:20:934 BST] 0000006f NamingHelper  I   JNDI InitialContext properties:{}
[28/04/05 13:59:20:950 BST] 0000006f TransactionMa I   instantiating TransactionManagerLookup: net.sf.hibernate.transaction.WebSphereTransactionManagerLookup
[28/04/05 13:59:20:965 BST] 0000006f TransactionMa I   instantiated TransactionManagerLookup
[28/04/05 13:59:20:996 BST] 0000006f WebSphereTran I   WebSphere 5.1
[28/04/05 13:59:20:996 BST] 0000006f TransactionMa I   instantiating TransactionManagerLookup: net.sf.hibernate.transaction.WebSphereTransactionManagerLookup
[28/04/05 13:59:20:996 BST] 0000006f TransactionMa I   instantiated TransactionManagerLookup
[28/04/05 13:59:21:012 BST] 0000006f SettingsFacto I   Use scrollable result sets: true
[28/04/05 13:59:21:028 BST] 0000006f SettingsFacto I   Use JDBC3 getGeneratedKeys(): false
[28/04/05 13:59:21:059 BST] 0000006f SettingsFacto I   Optimize cache for minimal puts: false
[28/04/05 13:59:21:059 BST] 0000006f SettingsFacto I   echoing all SQL to stdout
[28/04/05 13:59:21:075 BST] 0000006f SettingsFacto I   Query language substitutions: {}
[28/04/05 13:59:21:075 BST] 0000006f SettingsFacto I   cache provider: net.sf.hibernate.cache.EhCacheProvider
[28/04/05 13:59:21:090 BST] 0000006f Configuration I   instantiating and configuring caches
[28/04/05 13:59:21:153 BST] 0000006f Configurator  W   No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: wsjar:file:/C:/apps/java/websphere/profiles/default/installedApps/kestrelNode01Cell/ATT-EnterpriseApplication.ear/ehcache-0.9.jar!/ehcache-failsafe.xml
[28/04/05 13:59:21:403 BST] 0000006f SessionFactor I   building session factory
[28/04/05 13:59:27:528 BST] 0000006e SystemOut     O Creating new Portfolio
[28/04/05 13:59:27:543 BST] 0000006e JTATransactio E   Could not find UserTransaction in JNDI
[28/04/05 13:59:27:543 BST] 0000006e JTATransactio E   TRAS0014I: The following exception was logged javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 20, 2005 6:25 pm 
Newbie

Joined: Fri May 20, 2005 6:17 pm
Posts: 1
I get the same error using WebSphere 5 with the same hibernate configuration settings. If anyone is using Hibernate w/WebSphere and JTA transactions successfully, would much appreciate a response. I'll update this post if I get this working.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 9:21 am 
Beginner
Beginner

Joined: Thu Oct 16, 2003 7:30 am
Posts: 21
Location: Brussels
What version of Hibernate are you using?

Take a look at the last but one post of http://forum.hibernate.org/viewtopic.php?t=929305&highlight=. Is the Hibernate code using that method?

Johan.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.