-->
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 3 without J2EE server problem
PostPosted: Sun Apr 24, 2005 10:32 pm 
Newbie

Joined: Sat Apr 16, 2005 9:10 am
Posts: 2
i am using database mysql4.1
IDE: eclispe

My Application Structure:
application -
-src
Publisher.java
Publisher.hbm.xml
-main
AddPublisher.java

hibernate.cfg.xml
log4j.properties

-lib
hibernate3.jar
all jars in hibernate/lib

When i run addpublisher, it comes error:
Code:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
org.hibernate.MappingException: entity class not found: org.hibernate.bookstore.Publisher
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:87)
at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:160)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:42)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:107)
at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:401)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:104)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:206)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1055)
at Main.AddPublisher.main(AddPublisher.java:14)
Caused by: java.lang.ClassNotFoundException: org.hibernate.bookstore.Publisher
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:84)
... 9 more
Exception in thread "main"



My addpublisher.java code :
Code:
public static void main(String[] args){
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
Publisher publisher = new Publisher();
Transaction tx = session.beginTransaction();
publisher.setName("Prentice Hall");
session.saveOrUpdate(publisher);
tx.commit();
session.close();
}
}


my hibernate.cfg.xml:

Code:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>


<session-factory>

<property name="show_sql">true</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLMyISAMDialect</property>
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/bookstore</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>

<mapping resource="POJO/publisher.hbm.xml"/>
</session-factory>
</hibernate-configuration>



My publisher schema in database:
Code:
id: int auto_increment
name: varchar(100)


the publisher.hbm.xml:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1

http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->

<class
name="org.hibernate.bookstore.Publisher"
table="publisher"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="publisher"
</meta>

<id
name="id"
type="java.lang.Integer"
column="id"
>
<meta attribute="field-description">
@hibernate.id
generator-class="assigned"
type="java.lang.Integer"
column="id"

</meta>
<generator class="assigned" />
</id>

<property
name="name"
type="java.lang.String"
column="name"
not-null="true"
length="255"
>
<meta attribute="field-description">
@hibernate.property
column="name"
length="255"
not-null="true"
</meta>
</property>

<!-- Associations -->


</class>
</hibernate-mapping>




Can anyone help me how to solve it ?

thanks !!![/code]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 25, 2005 3:37 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it cant find org.hibernate.bookstore.Publisher which is most likely not in your classpath.

_________________
Max
Don't forget to rate


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.