日期:2014-05-20  浏览次数:20866 次

初学hibernate遇到问题
大家好!
我调试一个例子启动tomcat的时候出现以下问题:
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:   Joblog
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:216)
at   org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at   org.hw.hibernate.WriteLog. <clinit> (WriteLog.java:17)
at   org.hw.hibernate.WritelogServlet.doPost(WritelogServlet.java:59)
at   javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
at   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212)
at   org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:818)
at   org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:624)
at   org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
at   java.lang.Thread.run(Thread.java:595)
Caused   by:   java.lang.ClassNotFoundException:   Joblog
at   org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1355)
at   org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1201)
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)
...   24   more

------解决方案--------------------
hbm配置文件中的包名称package org.hw.hibernate没有写