-->
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: SessionFactory JNDI lookup fails
PostPosted: Thu Sep 15, 2005 9:07 am 
Newbie

Joined: Wed Feb 23, 2005 10:11 am
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0

Mapping documents:<property name="hibernate.connection.driver_class">com.ibm.db2.jcc.DB2Driver</property>
<property name="hibernate.jndi.url">iiop://localhost:2809/</property>
<property name="hibernate.jndi.class">com.ibm.websphere.naming.WsnInitialContextFactory</property>
<property name="hibernate.session_factory_name">HibernateSessionFactory</property>
<property name="hibernate.connection.datasource">jdbc/p1wpsdev</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.DB2Dialect</property>
<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WebSphereTransactionManagerLookup</property>
<property name="hibernate.transaction.auto_close_session">true</property>
<property name="jta.UserTransaction">thisNode/servers/WebSphere_Portal/jta/usertransaction</property>
<property name="org.hibernate.cache">true</property>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:db2 v8.1

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Hi everyone,

I'm using hibernate with WebSphere Portal v5.1 (based on WebSphere Application server v. 5.1.1),Hibernate SessionFactory initialized on portlet initalization and binded to jndi.
Jndi lookup from another WebSphere Server fails,my console shows:


Code:
org.hibernate.impl.SessionFactoryObjectFactory  Not found: 2c9585dd0659e94f010659e95a130000


I figure SessionFactory should be possible,so what is wrong?

Regards,
Guy Shkolnik


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 9:29 am 
Regular
Regular

Joined: Wed Feb 02, 2005 6:33 am
Posts: 70
Class Visibility

The org.hibernate.impl.SessionFactoryObjectFactory maintains a hashmap of uid to objects. If you bind a SessionFactory in one class loader and try to load it in another class loader, the SessionFactoryObjectFactory in that class loader cannot see the mapping of uid to session factory, so the call fails.

Don't know if this is a feature of hibernate or not, we had similar problem with having the session factory bound by one ear and looked up from another, resolved by putting the two ears together to create one big ear.

Someone with more knowledge may know how to get this to work with such a change.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 10:18 am 
Newbie

Joined: Wed Feb 23, 2005 10:11 am
Posts: 4
Thanks,

Well ,then i guess the best way for cross containers/servers use of Hibernate is using it with a stateless session bean which holds SessionFactory,session bean will exposes basic Hibernate functionalities
for local/remote calls.am i correct?

Regards,
Guy Shkolnik


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 11:39 am 
Regular
Regular

Joined: Wed Feb 02, 2005 6:33 am
Posts: 70
Whilst it is certainly possible to do, I would question any such design. You are essentially making the websphere server a hibernate proxy, and forcing detached use of the hibernate objects in your application for all situations.

A more ideal situation is to move the logic into the session layer, so that it can perform the majority of actions using connected instances under container managed transactions.

Otherwise, you might consider setting up a hibernate session factory in the portlet websphere server, connecting to the same database as the first instance.

Since I haven't seen this type of question before, I'd say it's an indication that such a design is either rare or not an intended use of the technology.

I'm sure more knowledgable developers on here can chip in with their thoughts.


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.