当前位置: 代码迷 >> Java相关 >> exception is org.hibernate.MappingException: entity class not found:
  详细解决方案

exception is org.hibernate.MappingException: entity class not found:

热度:10786   发布时间:2013-02-25 21:50:54.0
SSH架构,出了个错误
log4j:WARN No appenders could be found for logger (org.springframework.core.CollectionFactory).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: entity class not found: com.zjm.login.vo.Tuser
org.hibernate.MappingException: entity class not found: com.zjm.login.vo.Tuser
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:89)
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:108)
at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:400)
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:211)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:825)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:751)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1091)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:396)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:87)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:72)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:63)
at test.main(test.java:16)
Caused by: java.lang.ClassNotFoundException: com.zjm.login.vo.Tuser
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:86)
... 20 more


------解决方案--------------------------------------------------------
类没有找到, 倒是SessionFactory初始化失败. 
com.zjm.login.vo.Tuser
将所有编译的类放到classpath下去.
------解决方案--------------------------------------------------------
applicationContext.xml里关连类时错误....
com.zjm.login.vo.Tuser 
第一你看是
com/zjm/login/vo/Tuser.hbm.xml
  相关解决方案