-->
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: entity class not found problem
PostPosted: Mon Apr 09, 2007 2:09 pm 
Newbie

Joined: Mon Apr 09, 2007 1:55 pm
Posts: 2
Eclipse and hibernate versions: the latests.

When i try to execute my project, while creating a new session factory, my project trows a entity class not found exception. Let's see:

    entity class not found: Usuarios
    Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
    at utilidades.UtilidadHibernate.<clinit>(UtilidadHibernate.java:19)
    at accesoADatos.AccesoADatos.<init>(AccesoADatos.java:17)
    at negocio.Negocio.<init>(Negocio.java:12)
    at negocio.Negocio.<clinit>(Negocio.java:19)
    at presentacion.Login$1.actionPerformed(Login.java:75)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    Caused by: org.hibernate.MappingException: entity class not found: Usuarios
    at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:99)
    at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:168)
    at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:44)
    at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:123)
    at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
    at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
    at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
    at utilidades.UtilidadHibernate.<clinit>(UtilidadHibernate.java:16)
    ... 28 more
    Caused by: java.lang.ClassNotFoundException: Usuarios
    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:100)
    at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:96)
    ... 37 more


However, everything seems ok for me. The mapping file:

Code:
<?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 08-abr-2007 17:22:01 by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
    <class name="Usuarios" table="USUARIOS" schema="PUBLIC">
        <id name="nombreUsuario" type="string">
            <column name="NOMBRE_USUARIO" length="20" />
            <generator class="assigned" />
        </id>

        <property name="contrasenya" type="string">
            <column name="CONTRASENYA" length="10" not-null="true" />
        </property>
        <property name="tipoUsuario" type="string">
            <column name="TIPO_USUARIO" length="10" not-null="true" />
        </property>
    </class>
</hibernate-mapping>



is placed on the same package than the .java file

Code:
package negocio;

public class Usuarios {

   private String nombreUsuario;
....


and the hibernate config file is placed on the src root

Code:
<?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>
        <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
        <property name="hibernate.connection.url">jdbc:hsqldb:hsql://localhost/serviciomantenimiento</property>
        <property name="hibernate.connection.username">sa</property>
        <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
        <mapping resource="negocio/Usuarios.hbm.xml"/>
    </session-factory>
</hibernate-configuration>


I made some searchs about it and i guess the problem is related with classpath or alike, but i've been unable to solve it, so finally i am here asking for help.
Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 09, 2007 2:47 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
put the whole package name in the Usuarios.hbm.xml file

Code:
...
<hibernate-mapping>
    <class name="negocio.Usuarios" table="USUARIOS" schema="PUBLIC">
      ...

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 09, 2007 5:46 pm 
Newbie

Joined: Mon Apr 09, 2007 1:55 pm
Posts: 2
Ok, i already solved this problem after all the evening and a little break, there were some wrong things with my project, but anyway thanks for the help.


Top
 Profile  
 
 Post subject: please can you tell me how to solve this?
PostPosted: Sat Apr 04, 2009 2:19 am 
Newbie

Joined: Sat Apr 04, 2009 2:15 am
Posts: 1
hi, I am also encount this problem just like you, can you tell me how to solve this?
try{
// Create a configuration based on the properties file we've put
// in the standard place.
Properties prop=new Properties();
prop.load(new FileInputStream(propertyFileName));

Configuration config = new Configuration().addProperties(prop);
config.addClass(com.whu.iss.server.entity.MyGood.class);
config.addClass(com.whu.iss.server.entity.MyGoodclass.class);
config.addClass(com.whu.iss.server.entity.MyIndent.class);
config.addClass(com.whu.iss.server.entity.MyIndentlist.class);
config.addClass(com.whu.iss.server.entity.MyUser.class);
config.addClass(com.whu.iss.server.entity.MyGoodadminuser.class);
// Get the session factory we can use for persistence
sessionFactory = config.buildSessionFactory();
}catch(Exception e){
throw e;
}

}
this is my code, when execute to this line:
sessionFactory = config.buildSessionFactory();
it throw the
entity class not found: com.whu.iss.server.entity.MyGoodadminuser
exception


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.