-->
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: How do you get Hibernate to NOT bind to JNDI??
PostPosted: Fri Jul 08, 2005 5:22 pm 
Beginner
Beginner

Joined: Mon Nov 22, 2004 8:53 pm
Posts: 23
I have a standalone java app that I am running from inside of Intellij Idea.

I do NOT want Hibernate to bind itself to any JNDI tree. According to the docs:

"If you wish to have the SessionFactory bound to a JNDI namespace, specify a name (eg. java:comp/env/hibernate/SessionFactory) using the property hibernate.session_factory_name. If this property is omitted, the SessionFactory will not be bound to JNDI."

I have not included the above config property. Here is my hibernate.cfg.xml (with sensitive info removed):

<?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">

<hibernate-configuration>

<session-factory name="comp:env:hibernate:SessionFactory">

<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.username"></property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@....</property>

<property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.use_outer_join">true</property>
<property name="hibernate.max_fetch_depth">3</property>
<property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.cglib.use_reflection_optimizer">false</property>
<property name="hibernate.jdbc.batch_size">0</property>

</session-factory>

</hibernate-configuration>

But whenever I run my app and execute this code:

new Configuration().configure().buildSessionFactory();

I get the following exception:

16:13:50,517 WARN [SessionFactoryObjectFactory] Could not bind factory to JNDI
javax.naming.CommunicationException: Can't find SerialContextProvider
at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:63)
at com.sun.enterprise.naming.SerialContext.rebind(SerialContext.java:188)
at com.sun.enterprise.naming.SerialContext.rebind(SerialContext.java:202)
at javax.naming.InitialContext.rebind(InitialContext.java:367)
at net.sf.hibernate.util.NamingHelper.bind(NamingHelper.java:74)
at net.sf.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:171)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:791)
.........


The thing is, after I get this error, my hibernate code works fine. I need to get rid of the error and I think the way to do that is to figure out how to get hibernate NOT to try to bind itself to JNDI. Can anyone shed any light on this?

Thanks.
-peter

Hibernate version: 2.1.6


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2005 5:32 pm 
Beginner
Beginner

Joined: Fri Jul 08, 2005 12:38 pm
Posts: 41
Location: Massachusetts, USA
I think you need to remove the name attribute from:

Code:
<session-factory name="comp:env:hibernate:SessionFactory">


It should just be:

Code:
<session-factory>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2005 8:02 pm 
Beginner
Beginner

Joined: Mon Nov 22, 2004 8:53 pm
Posts: 23
That solved my problem.

Many thanks!
-peter


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.