-->
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/ SessionFactory in WebLogic cluster
PostPosted: Fri Jan 14, 2005 3:05 pm 
Newbie

Joined: Fri Jan 14, 2005 2:35 pm
Posts: 2
Location: New York, NY
Hibernate version:[/b2.1.1...]

[b]Mapping documents:


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

Full stack trace of any exception that occurs:

Name and version of the database you are using:[/bOracle 9i]

[b]The generated SQL (show_sql=true):


Debug level Hibernate log excerpt:

I use Hibernate w/ NO cache as a local library in my Session EJB deployed in WebLogic 8.1 cluster. WebLogic DB Connection Pool is configured w/ minimum 5 connections for Oracle 9i. My Hibernate bootstrap code initializes SessionFactory and bind it to the JNDI.

private static
SessionFactory getSessionFactory ()
throws HibernateException, NamingException
{
if (IN_CONTAINER) {
return getSessionFactory_jndi ();
} else {
return getSessionFactory_local ();
}
// NOT REACHED
}

private static
SessionFactory getSessionFactory_jndi ()
throws NamingException, HibernateException
{
final InitialContext ctx = JNDIUtil.getInitialContext (COMPONENT_NAME);

// See if the SessionFactory is already bound in JNDI

try {
final Object obj = ctx.lookup (SESSION_FACTORY_JNDI);
return (SessionFactory) obj;
}
catch (final NamingException n_e) {
// IGNORED
}

// Create a new SessionFactory and bind it into JNDI

try {
final URL url = Thread.currentThread ().getContextClassLoader ().getResource (CONFIG_RESOURCE);
final Configuration config = new Configuration ().configure (url);
final SessionFactory factory = config.buildSessionFactory ();
ctx.bind (SESSION_FACTORY_JNDI, factory);
return factory;
}
catch (final NamingException n_e) {
logger.log (Level.SEVERE, n_e.getMessage (), n_e);
throw n_e;
}

// NOT REACHED
}

}

I send requests to the cluster ( IN_CONTAINER = true ) and Hibernate works fine on one server only; on another server I always get SessionFactory obj=null and I cannot open the Session ( wile I do have my DB Connection available ): line
final Object obj = ctx.lookup (SESSION_FACTORY_JNDI);

What is wrong ? My guess is this: when the first request reaches SessionFactory initialization, it goes fine and the object gets bound to the JNDI; in the cluster, JNDI is replicated to another server; the second request in the second server finds SessionFactory' s JNDI name and tries to get bound object; the object exists in the JVM of another server and, obviously, NULL is returned. Am I right ?

Should I avoid binding SessionFactory to the JNDI in the cluster and always treat SessionFactory as only local instance ?

Please, help me with it.

Thank you,
- Michael

_________________
"Before jumping into something, think how you would get out later" -since the time of Alice in Wonderland


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 14, 2005 3:42 pm 
Newbie

Joined: Wed Jan 05, 2005 12:30 pm
Posts: 17
Location: Philadelphia, PA
Have you looked at http://www.hibernate.org/120.html ?


Top
 Profile  
 
 Post subject: Problem w/ SessionFactory in WebLogic cluster
PostPosted: Fri Jan 14, 2005 7:44 pm 
Newbie

Joined: Fri Jan 14, 2005 2:35 pm
Posts: 2
Location: New York, NY
evan wrote:


yes, I have. If you look into my code in the message, it uses exactly same approach. Plus, I never had a problem with single WebLogic server ( using JNDI ).
Thanks,
- Michael

_________________
"Before jumping into something, think how you would get out later" -since the time of Alice in Wonderland


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.