-->
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: Is JNDI really needed?
PostPosted: Fri Mar 09, 2007 10:36 am 
Newbie

Joined: Fri Mar 09, 2007 10:12 am
Posts: 6
Hi all,

I'm new to Hibernate. Everything is working quite fine. However, I always get a warning I would like to fix.

When calling buildSessionFactory(), I always get this warning:

Code:
15:19:43,451  WARN SessionFactoryObjectFactory:98 - Could not bind factory to JNDI
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
   at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
   at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
   at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
   at javax.naming.InitialContext.getNameParser(InitialContext.java:439)
   at org.hibernate.util.NamingHelper.bind(NamingHelper.java:52)
   at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:306)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
   at com.ruag.panther.missionservice.provider.persistence.internal.HibernateManager$1.run(HibernateManager.java:74)

We do not use any application server. It is an application based on OSGi (Equinox). I guess we have no JNDI context registered. Actually, we do not need one. And using hibernate.connection.url works well (I have not set hibernate.connection.datasource).

Is JNDI really needed? Is it possible to tell Hibernate to skip all these JNDI things? Should I set a "dummy" context somewhere?

Thank you


Top
 Profile  
 
 Post subject: JNDI
PostPosted: Fri Mar 09, 2007 1:53 pm 
Newbie

Joined: Wed Feb 23, 2005 9:01 am
Posts: 9
Location: London
Hello

Are you using hibernate.cfg.xml?

You can use the Hibernate build-in connection pool.

See page 13 of the Hibernate reference manual:

http://www.hibernate.org/hib_docs/v3/re ... erence.pdf

Note that this isn't production-quality and you'll need to use a thrid-party pool such as c3p0 (comes with Hibernate) or Apache DBCP.

Regards

Mark


Top
 Profile  
 
 Post subject: Re: JNDI
PostPosted: Fri Mar 16, 2007 6:06 am 
Newbie

Joined: Fri Mar 09, 2007 10:12 am
Posts: 6
markandirene wrote:
Are you using hibernate.cfg.xml?

Yes I am.

markandirene wrote:
You can use the Hibernate build-in connection pool.

See page 13 of the Hibernate reference manual:

http://www.hibernate.org/hib_docs/v3/re ... erence.pdf

Note that this isn't production-quality and you'll need to use a thrid-party pool such as c3p0 (comes with Hibernate) or Apache DBCP.

I'm already using C3P0. Here are the relevant parts of my hibernate.cfg.xml:

Code:
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.connection.password">****</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/database</property>
<property name="hibernate.connection.username">****</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
       
<property name="current_session_context_class">thread</property>
       
<property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.use_query_cache">true</property>
       
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">1800</property>
<property name="hibernate.c3p0.max_statements">50</property>

Any suggestions?

Thank you


Top
 Profile  
 
 Post subject: Don't Name You Session Factory
PostPosted: Mon Mar 26, 2007 7:50 pm 
Newbie

Joined: Thu Dec 11, 2003 10:06 pm
Posts: 8
You're getting this warning because you named your session factory and Hibernate is trying to use this name to bind it in JNDI. The easiest thing to do is simply don't name you session factory. Or just ignore the warning, since it will only happen at startup and is harmless. Or change your logging level so you don't see warnings...


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.