-->
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: Could not locate SessionFactory in JNDI
PostPosted: Thu Apr 06, 2006 12:13 am 
Newbie

Joined: Mon Apr 03, 2006 5:11 am
Posts: 1
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!

#############################################
init:
deps-module-jar:
deps-ear-jar:
deps-jar:
compile-single:
run-main:
09:34:57,921 INFO Environment:479 - Hibernate 3.1.2
09:34:57,937 INFO Environment:509 - hibernate.properties not found
09:34:57,937 INFO Environment:525 - using CGLIB reflection optimizer
09:34:57,953 INFO Environment:555 - using JDK 1.4 java.sql.Timestamp handling
09:34:58,031 INFO Configuration:1308 - configuring from resource: /hibernate.cfg.xml
09:34:58,031 INFO Configuration:1285 - Configuration resource: /hibernate.cfg.xml
09:34:58,437 INFO Configuration:469 - Reading mappings from resource: com/mirchmarket/model/beans/HContactUs.hbm.xml
09:34:58,859 INFO HbmBinder:309 - Mapping class: HContactUs -> h_contact_us
09:34:58,937 INFO Configuration:1419 - Configured SessionFactory: com.mirchmarket.model.HibernateSessionFactory
09:34:59,281 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
09:34:59,281 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
09:34:59,281 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
09:34:59,281 INFO DriverManagerConnectionProvider:80 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://192.168.1.5:3306/mirchmaster
09:34:59,281 INFO DriverManagerConnectionProvider:86 - connection properties: {user=admin}
09:35:04,578 INFO SettingsFactory:77 - RDBMS: MySQL, version: 4.1.11
09:35:04,593 INFO SettingsFactory:78 - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.12 ( $Date: 2005-11-17 15:53:48 +0100 (Thu, 17 Nov 2005) $, $Revision$ )
09:35:04,671 INFO Dialect:103 - Using dialect: org.hibernate.dialect.MySQLMyISAMDialect
09:35:04,703 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
09:35:04,718 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
09:35:04,718 INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
09:35:04,718 INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
09:35:04,718 INFO SettingsFactory:136 - JDBC batch size: 15
09:35:04,718 INFO SettingsFactory:139 - JDBC batch updates for versioned data: disabled
09:35:04,718 INFO SettingsFactory:144 - Scrollable result sets: enabled
09:35:04,718 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): enabled
09:35:04,718 INFO SettingsFactory:160 - Connection release mode: auto
09:35:04,718 INFO SettingsFactory:178 - Default schema: mirchmaster
09:35:04,718 INFO SettingsFactory:184 - Maximum outer join fetch depth: 2
09:35:04,718 INFO SettingsFactory:187 - Default batch fetch size: 1
09:35:04,718 INFO SettingsFactory:191 - Generate SQL with comments: disabled
09:35:04,718 INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
09:35:04,718 INFO SettingsFactory:338 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
09:35:04,765 INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory
09:35:04,765 INFO SettingsFactory:203 - Query language substitutions: {}
09:35:04,765 INFO SettingsFactory:209 - Second-level cache: enabled
09:35:04,765 INFO SettingsFactory:213 - Query cache: disabled
09:35:04,765 INFO SettingsFactory:325 - Cache provider: org.hibernate.cache.EhCacheProvider
09:35:04,781 INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
09:35:04,781 INFO SettingsFactory:237 - Structured second-level cache entries: disabled
09:35:04,828 INFO SettingsFactory:264 - Statistics: disabled
09:35:04,828 INFO SettingsFactory:268 - Deleted entity synthetic identifier rollback: disabled
09:35:04,828 INFO SettingsFactory:283 - Default entity-mode: pojo
09:35:05,000 INFO SessionFactoryImpl:153 - building session factory
09:35:05,031 WARN Configurator:126 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/hibernate/hibernate-3.1/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
initial creation failed
org.hibernate.MappingException: entity class not found: HContactUs
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.mirchmarket.model.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:22)
at com.mirchmarket.junit.actions.MirchJobsTestCase.main(MirchJobsTestCase.java:21)
Caused by: org.hibernate.MappingException: entity class not found: HContactUs
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:99)
at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:166)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:44)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:115)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:215)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at com.mirchmarket.model.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:18)
... 1 more
Caused by: java.lang.ClassNotFoundException: HContactUs
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:96)
... 10 more
Java Result: 1
BUILD SUCCESSFUL (total time: 10 seconds)
############################################
my *.cfg.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="com.mirchmarket.model.HibernateSessionFactory">
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://192.168.1.5:3306/mirchmaster</property>
<property name="hibernate.connection.username">admin</property>
<property name="hibernate.default_schema">mirchmaster</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLMyISAMDialect</property>
<mapping resource="com/mirchmarket/model/beans/HContactUs.hbm.xml"/>
</session-factory>
</hibernate-configuration>
############################################
my HContactUs.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Mar 18, 2006 6:32:18 PM by Hibernate Tools 3.1.0 beta3 -->
<hibernate-mapping>
<class name="HContactUs" table="h_contact_us" catalog="mirchmarket">
<id name="idContactUs" type="long">
<column name="ID_CONTACT_US" precision="10" scale="0" />
<generator class="assigned" />
</id>
<property name="idService" type="long">
<column name="ID_SERVICE" precision="10" scale="0" />
</property>
<property name="tsService" type="date">
<column name="TS_SERVICE" length="10" not-null="true" />
</property>
<property name="tsContact" type="date">
<column name="TS_CONTACT" length="10" />
</property>
<property name="txComments" type="string">
<column name="TX_COMMENTS" length="65535" />
</property>
<property name="inRegistered" type="character">
<column name="IN_REGISTERED" length="1" />
</property>
<property name="idVertical" type="long">
<column name="ID_VERTICAL" precision="10" scale="0" not-null="true" />
</property>
<property name="idUsr" type="long">
<column name="ID_USR" precision="10" scale="0" not-null="true" />
</property>
<property name="nmContact" type="string">
<column name="NM_CONTACT" length="40" />
</property>
<property name="idEmailContact" type="string">
<column name="ID_EMAIL_CONTACT" length="30" />
</property>
<property name="txPhoneContact" type="string">
<column name="TX_PHONE_CONTACT" length="30" />
</property>
</class>
</hibernate-mapping>
############################################
my MirchJobsTestCase.java

/*
* Created on Mar 12, 2006
*
* To change the template for this generated file go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
package com.mirchmarket.junit.actions;

import org.hibernate.Session;

import com.mirchmarket.model.HibernateSessionFactory;
import com.mirchmarket.model.beans.HContactUs;
import com.mirchmarket.model.beans.HContactUsHome;

import junit.framework.TestCase;

public class MirchJobsTestCase extends TestCase {

public static void main(String[] args) {

Session session = HibernateSessionFactory.getHibernateSession();
HContactUsHome home = new HContactUsHome();
HContactUs contactus = new HContactUs();
contactus.setIdUsr(3232);
contactus.setTxComments("helloooo");
home.persist(contactus);

}

public MirchJobsTestCase(String arg0) {
super(arg0);
}

protected void setUp() throws Exception {
super.setUp();
}

protected void tearDown() throws Exception {
super.tearDown();
}

}
#############################################
my HibernateSessionFactory.java
package com.mirchmarket.model;

import org.hibernate.*;
import org.hibernate.cfg.*;
import org.hibernate.HibernateException;

/*
* Created on Feb 25, 2006
*
* To change the template for this generated file go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/

public class HibernateSessionFactory {
public static final SessionFactory sessionFactory;
static {
try {
sessionFactory = new Configuration().configure().buildSessionFactory();
}
catch(Throwable ex) {
System.err.println("initial creation failed \n"+ex);
throw new ExceptionInInitializerError(ex);
}
}
public static Session getHibernateSession() throws HibernateException
{
return sessionFactory.openSession();
}

}

############################################


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 06, 2006 6:39 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
mapping should specify full class name or specify package
<hibernate-mapping >
<class name="com.mirchmarket.model.beans.HContactUs"

or
<hibernate-mapping
package="com.mirchmarket.model.beans">
<class name="HContactUs"

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


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.