-->
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: JNDI problem
PostPosted: Thu Aug 19, 2004 12:34 pm 
Newbie

Joined: Tue Aug 17, 2004 4:34 am
Posts: 10
Hibernate version :2.1

Mapping documents:<?xml version="1.0" encoding="GB2312"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name="firsthibernate.PersonModel"
table="ZY_PERSON">

<id name="id" type="long">
<generator class="sequence">
<param name="sequence">ZY_PERSON_ID_SEQ</param>
</generator>
</id>

<property name="name"/>
<property name="address"/>

</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
package firsthibernate;

import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.cfg.Configuration;
import net.sf.hibernate.Query;

public class TestPersonModel3 {
//private static SessionFactory sessionFactory;
public static void main(String[] args) throws Exception{
//Configuration conf= new Configuration().addClass(PersonModel.class);
SessionFactory sf = new Configuration().configure().buildSessionFactory();
//sessionFactory = conf.buildSessionFactory();
Session s = sf.openSession();
PersonModel p = new PersonModel();
Query q = s.createQuery("from PersonModel as p where p.id=1");

p = (PersonModel) q.list().get(0);
System.out.println(p.getName());
s.close();
}
}


Full stack trace of any exception that occurs:

Name and version of the database you are using:
oracle 9i


Debug level Hibernate log excerpt:

I am a beginner.In my program,I do not use any jndi,and I do not config anything about jndi,but the exception occored.Although it doesn't cause the wrong results,but how can I reslove the problem?
By the way,in the hibernate.cfg.xml and *.hbm.xml,I do not set anything about jndi.

thanks for help!




00:22:18,593 INFO SessionFactoryObjectFactory:86 - Factory name: java:comp/env/hibernate/SessionFactory

00:22:18,593 INFO NamingHelper:26 - JNDI InitialContext properties:{}

00:22:18,609 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:640)

at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)

at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)

at javax.naming.InitialContext.getNameParser(InitialContext.java:429)

at net.sf.hibernate.util.NamingHelper.bind(NamingHelper.java:52)

at net.sf.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)

at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:172)

at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:750)

at firsthibernate.TestPersonModel3.main(TestPersonModel3.java:12)

00:22:18,656 INFO UpdateTimestampsCache:35 - starting update timestamps cache at region: net.sf.hibernate.cache.UpdateTimestampsCache

00:22:18,718 INFO QueryCache:39 - starting query cache at region: net.sf.hibernate.cache.QueryCache

robin//this is result.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 1:09 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
show hibernate.cfg.xml

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 4:13 am 
Newbie

Joined: Tue Aug 17, 2004 4:34 am
Posts: 10
OH,sorry.

My hibernate.cfg.xml


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

<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory
name="java:comp/env/hibernate/SessionFactory">

<!-- properties -->
<property name="query.substitutions">query.substitutions</property>

<!-- oracle -->
<property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.username">pam</property>
<property name="connection.password">pam</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:chenhan</property>

<!-- Hibernate Connection Pool -->
<property name="connection.pool_size">1</property>

<!-- Proxool Connection Pool -->
<property name="proxool.pool_alias pool1">pool1</property>
<!-- set the JDBC fetch size-->
<property name="jdbc.fetch_size">50</property>

<!--set the maximum JDBC 2 batch size (a nonzero value enables batching)-->
<property name="jdbc.batch_size">50</property>

<!--use streams when writing binary types to / from JDBC-->
<property name="jdbc.use_streams_for_binary">true</property>


<!--set the maximum depth of the outer join fetch tree-->
<property name="max_fetch_depth">1</property>

<!--enable the query cache-->
<property name="cache.use_query_cache">true</property>
<property name="cache.provider_class">net.sf.hibernate.cache.HashtableCacheProvider</property>

<!--outer_join_if-->
<property name="use_outer_join">True</property>

<!--JDBC Transaction-->
<property name="transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>



<!-- mapping files -->
<mapping resource="firsthibernate/PersonModel.hbm.xml"/>
<mapping resource="firsthibernate/Evaluation.hbm.xml"/>



</session-factory>

</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 4:17 am 
Regular
Regular

Joined: Wed Aug 18, 2004 5:16 am
Posts: 69
Location: Modena, Italy
Eliminate the name attribute in session-factory in your hibernate.cfg.xml.

The name of a session factory is a JNDI name, and when found Hibernate try to bind the session factory to this JNDI


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.