-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate and Weblogic JNDI integration problems
PostPosted: Mon Sep 06, 2004 5:14 pm 
Newbie

Joined: Mon Sep 06, 2004 4:37 pm
Posts: 2
[b]Hibernate version: 2.1[/b]

[b]Weblogic version: 8.1[/b]

Hi, All:

Integrating Weblogic and Hibernate can be a little bit of a struggle. I am trying to place the SessionFactroy in the JNDI tree but having trouble. Is there a good example online on how to do this?

This is what I've done:

added this line to my hibernate.cfg.xml file

<property name="hibernate.session_factory_name">hibernate/HibernateFactory</property>

Then I used the code as mentioned in Hibernate In Action in a Hibernate Manager class that resides in the WebLogic App Server space:

try {
System.out.println("Initializing Hibernate in JNDI Tree");
new Configuration().configure().buildSessionFactory();
// SessionFactory is now in JNDI, see hibernate.cfg.xml
System.out.println("Successfully Initializing Hibernate in JNDI Tree");
} catch (HibernateException e) {
System.out.println("Could not place Hibernate Session Factory in JNDI Tree");
e.printStackTrace();
}

So far so good. This code ran fine.

Then I tried a lookup. Didn't work. Here's my lookup code.........

try {
Context ctx = new InitialContext();
String jndiName = "java:hibernate/HibernateFactory";
sessionFactory = (SessionFactory)ctx.lookup(jndiName);
} catch (NamingException ex) {
System.out.println("Could not obtain Session Factory from JNDI Tree");
ex.printStackTrace();
}

Here's my log exception:

javax.naming.NameNotFoundException: While trying to look up /hibernate/Hibernate
Factory in /app/ejb/SessionBeanProject.jar#PatientJNDISession.; remaining name '
/hibernate/HibernateFactory'
at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(Basic
NamingNode.java:858)
at weblogic.jndi.internal.ApplicationNamingNode.lookup(ApplicationNaming
Node.java:150)
at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.j
ava:237)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:336)
at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyCo
ntextWrapper.java:45)
at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.j
ava:130)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at gov.va.med.pharmacy.business.hibernate.HibernateJNDIManager.getSessio
nFactory(HibernateJNDIManager.java:86)

Any help would be great. I can get Hibernate to work within Weblogic as a Singleton class but can't get the SessionFactory obtained from the JNDI tree. Also, I would like to be able to eventually make use of Weblogic services, such as transactions, etc.

Can anyone help?

Thanks,
John Curley

_________________
John Curley
mayorcurley@hotmail.com


Top
 Profile  
 
 Post subject: Re: Hibernate and Weblogic JNDI integration problems
PostPosted: Tue Sep 07, 2004 8:50 am 
Beginner
Beginner

Joined: Tue Jul 20, 2004 1:53 am
Posts: 43
Location: India
JohnCurley wrote:
Any help would be great. I can get Hibernate to work within Weblogic as a Singleton class but can't get the SessionFactory obtained from the JNDI tree. Also, I would like to be able to eventually make use of Weblogic services, such as transactions, etc.


Use something like :
Code:
<hibernate-configuration>
    <session-factory name="hibernate.session-factory.Oracle">
        <property name="jndi.class">weblogic.jndi.WLInitialContextFactory</property>
        <property name="jndi.url">t3://localhost:7001</property>
         <!-- ... -->
    </session-factory>
</hibernate-configuration>


Also, raise the log level to INFO and see if something like the following is logged :
Code:
- INFO 07-Sep-04 18:18:24:018 net.sf.hibernate.cfg.Configuration: Configured SessionFactory: hibernate.session-factory.Oracle


There are a few posts elsewhere on the forums regarding this. Also please see this FAQ.

_________________
Thanks,
Binil Thomas


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.