# org.hibernate.MappingException: entity class not found



## t.stein (22. Jul 2010)

Hey, ich bekomm bei einem Hibernate-Projekt folgenden Fehlermeldung:


```
org.hibernate.MappingException: entity class not found: HsagUser
	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:118)
	at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:425)
	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:1218)
	at de.info.hsag.edicat.persist.user.UsersService.initUsersService(UsersService.java:37)
	at de.info.hsag.edicat.persist.user.UsersService.createUsers(UsersService.java:79)
	at de.info.hsag.edicat.persist.Application.start(Application.java:36)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Caused by: java.lang.ClassNotFoundException: HsagUser
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
	at java.lang.ClassLoader.loadClass(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)
```

Meine hibernate.cfg.xml sieht so aus:


```
<?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.cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.password">hsag</property>
        <property name="hibernate.connection.pool_size">1</property>
        <property name="hibernate.connection.url">jdbc:mysql://Eddi:3306/EdicatDB</property>
        <property name="hibernate.connection.username">hsag</property>
        <property name="hibernate.current_session_context_class">thread</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.format_sql">true</property>
        <property name="hibernate.show_sql">true</property>
        <property name="hilbernamte.jdbc.batch_size">30</property> 
		<property name="hbm2ddl.auto">update</property>     
        

        <mapping class="de.info.hsag.edicat.persist.user.HsagUser"/>
        <mapping resource="de/info/hsag/edicat/persist/user/HsagUser.hbm.xml"/>
        
        <mapping class="de.info.hsag.edicat.persist.user.HsagSeeclient"/>
        <mapping resource="de/info/hsag/edicat/persist/user/HsagSeeclient.hbm.xml"/>
        
        
        <mapping class="de.info.hsag.edicat.persist.user.HsagClient"/>
        <mapping resource="de/info/hsag/edicat/persist/user/HsagClient.hbm.xml"/>
   	        
        
    </session-factory>
</hibernate-configuration>
```


----------



## SlaterB (22. Jul 2010)

wie sieht denn HsagUser.hbm.xml inhaltlich genau aus?
die Fehlermeldung klingt danach, als wenn dort die Klasse nur als HsagUser angegeben ist, ohne package


----------



## t.stein (22. Jul 2010)

Hey, genau das war es. 

Leider kommt jetzt eine andere Fehlermeldung:


```
org.hibernate.MappingException: Association references unmapped class: HsagSeeclient
	at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2370)
	at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2652)
	at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
	at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1054)
	at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1210)
	at de.info.hsag.edicat.persist.user.UsersService.initUsersService(UsersService.java:37)
	at de.info.hsag.edicat.persist.user.UsersService.createUsers(UsersService.java:79)
	at de.info.hsag.edicat.persist.Application.start(Application.java:36)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
```


----------



## SlaterB (22. Jul 2010)

auch in hmb.xml referenzierte andere Klassen müssen mit vollständigen Namen angegeben werden 
einmal um die Ecke denken?


----------



## t.stein (22. Jul 2010)

Ja, stimmt schon. Bei Hibernate ist man jedoch nach 2h so frustiert, weil man von einer Exception in die andere läuft,  dass man den Blick verliert, woran es jetzt liegen könnte...


----------

