首页 > 代码库 > hibernate开发错误及解决办法
hibernate开发错误及解决办法
1、 Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at net.sf.hibernate.cfg.Configuration.(Configuration.java:95)
at cn.yuan.xmlparse.base._BaseRootDAO.initialize(_BaseRootDAO.java:49)
at cn.yuan.xmlparse.base._BaseRootDAO.initialize(_BaseRootDAO.java:38)
at cn.yuan.xmlparse.TestMODeliver.main(TestMODeliver.java:30)
解决方法:
添加commons-logging-1.0.4.jar即可
2、net.sf.hibernate.util.XMLHelper$ErrorLogger error
严重: Error parsing XML: XML InputStream(50) The content of element type "class" must match "(meta*,(cache|jcs-cache)?,(id|composite-id),discriminator?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-array)*,(subclass*|joined-subclass*))".
net.sf.hibernate.MappingException: Error reading resource: cn/yuan/xmlparse/MODeliver.hbm
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:340)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1027)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:983)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:911)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:897)
at cn.yuan.xmlparse.base._BaseRootDAO.initialize(_BaseRootDAO.java:51)
at cn.yuan.xmlparse.base._BaseRootDAO.initialize(_BaseRootDAO.java:38)
at cn.yuan.xmlparse.TestMODeliver.main(TestMODeliver.java:30)
Caused by: net.sf.hibernate.MappingException: invalid mapping
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:288)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:337)
... 7 more
Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,(cache|jcs-cache)?,(id|composite-id),discriminator?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-array)*,(subclass*|joined-subclass*))".
at weblogic.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:232)
at weblogic.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:173)
at weblogic.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:371)
at weblogic.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:305)
at weblogic.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:1918)
at weblogic.apache.xerces.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:851)
at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1008)
at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1469)
at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:329)
at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:525)
at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
at weblogic.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
at weblogic.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1175)
at weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:135)
at weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:138)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:287)
... 8 more
解决建议:
数据库结构设计有关,比如没有主键等,这个问题我真没有好的方法。
3、Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:142)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1172)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:803)
at cn.yuan.xmlparse.base._BaseRootDAO.initialize(_BaseRootDAO.java:54)
at cn.yuan.xmlparse.base._BaseRootDAO.initialize(_BaseRootDAO.java:38)
at cn.yuan.xmlparse.TestMODeliver.main(TestMODeliver.java:30)
解决方法:
添加ehcache-0.9.jar
4、
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xalan/processor/TransformerFactoryImpl
at weblogic.xml.jaxp.RegistryTransformerFactory.(RegistryTransformerFactory.java:62)
at weblogic.xml.jaxp.RegistrySAXTransformerFactory.(RegistrySAXTransformerFactory.java:12)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at javax.xml.transform.FactoryFinder.newInstance(Unknown Source)
at javax.xml.transform.FactoryFinder.findJarServiceProvider(Unknown Source)
at javax.xml.transform.FactoryFinder.find(Unknown Source)
at javax.xml.transform.TransformerFactory.newInstance(Unknown Source)
at net.sf.hibernate.xml.XMLDatabinder.getOutputStyleSheetTemplates(XMLDatabinder.java:254)
at net.sf.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:161)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:805)
at cn.yuan.xmlparse.base._BaseRootDAO.initialize(_BaseRootDAO.java:54)
at cn.yuan.xmlparse.base._BaseRootDAO.initialize(_BaseRootDAO.java:38)
at cn.yuan.xmlparse.TestMODeliver.main(TestMODeliver.java:30)
解决方法:
添加xalan-2.4.0.jar
5、net.sf.hibernate.MappingException: Bad identifier type: net.sf.hibernate.type.ComponentType
at net.sf.hibernate.persister.AbstractEntityPersister.(AbstractEntityPersister.java:669)
at net.sf.hibernate.persister.EntityPersister.(EntityPersister.java:690)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42)
at net.sf.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:137)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:805)
at MyTest.main(MyTest.java:61)
Exception in thread "main"
解决办法:升级至hibernate3.0
6、java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter
加入 cglib-nodep-2.1_3.jar包
hibernate开发错误及解决办法