1

当我针对 oracle 数据库运行我的代码时,我收到以下错误:

Error parsing XML (31) : http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd<Line 31, Column 2>: XML-20068: (Fatal Error) content model is not deterministic
[07 Aug 2012 14:41:36,643](UTC 20:41:36) WARN   ApplicationLifecycle      | Unable to install module at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.hibernate.InvalidMappingException: Unable to read XML
at org.hibernate.util.xml.MappingReader.readMappingDocument(MappingReader.java:101)
at org.hibernate.cfg.Configuration.add(Configuration.java:513)
at org.hibernate.cfg.Configuration.add(Configuration.java:509)
at org.hibernate.cfg.Configuration.add(Configuration.java:716)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:801)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2344)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2310)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2290)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2243)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2158)
Caused by: org.dom4j.DocumentException: Error on line 31 of document http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd : http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd<Line 31, Column 2>: XML-20068: (Fatal Error) content model is not deterministic Nested exception: http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd<Line 31, Column 2>: XML-20068: (Fatal Error) content model is not deterministic
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.util.xml.MappingReader.readMappingDocument(MappingReader.java:75)
... 20 more

主要错误是Error parsing XML (31) : http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd<Line 31, Column 2>: XML-20068: (Fatal Error) content model is not deterministic

然后当我删除 jar 时,xmlparserv2.jar我会收到以下错误。

Caused by: java.lang.NoClassDefFoundError: oracle/xml/parser/v2/XMLParseException
at oracle.jdbc.driver.OracleSQLXML.setString(OracleSQLXML.java:415)
at com.capitaliq.loader.persistence.messaging.QueueUtils$1FlushMessages.execute(QueueUtils.java:358)
at com.capitaliq.loader.persistence.messaging.QueueUtils.flushMessages(QueueUtils.java:378)
at com.capitaliq.loader.persistence.AbstractControlFacadeHelper$ControlFacadeRetrier.performOperation(AbstractControlFacadeHelper.java:303)
at com.capitaliq.loader.persistence.AbstractRetryLimitedDurationWithTimout.retryContinuously(AbstractRetryLimitedDurationWithTimout.java:66)
at com.capitaliq.loader.persistence.AbstractControlFacadeHelper.performRetries(AbstractControlFacadeHelper.java:138)
... 12 more
Caused by: java.lang.ClassNotFoundException: oracle.xml.parser.v2.XMLParseException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 18 more
at com.capitaliq.loader.control.ClientManager$HeartbeatCity.safeRun(ClientManager.java:429)
at com.capitaliq.common.thread.SafeRunnable.run(SafeRunnable.java:57)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NoClassDefFoundError: oracle/xml/parser/v2/XMLParseException
at oracle.jdbc.driver.OracleSQLXML.setString(OracleSQLXML.java:415)
... 12 more
Caused by: java.lang.ClassNotFoundException: oracle.xml.parser.v2.XMLParseException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 18 more  
   Caused by: oracle.xml.parser.v2.XMLParseException

从堆栈跟踪中,我可以推断我需要在我的类路径中有这个 jar 来读取 xml,但我不能拥有它,因为它与我的 hibernate 版本不兼容。在升级到 Hibernate 3.6 之前,我没有出现此错误。我的问题是,有人以前有过这种情况吗?还有另一个与 oracle 数据库一起使用的 xmlparser 吗?

如果我针对 SQL 数据库运行我的代码,如果 jar 在类路径上,我会得到同样的错误。但是,如果我删除一切正常。所以我知道这与 oracle 数据库有关。有人有什么建议吗?

4

1 回答 1

1

试试这个:使用以下命令解压缩文件:

"C:\Program Files\Java\jdk1.7.0_02\bin\jar" -xvf xmlparserv2.jar

更改 META-INF/services 中文件中的条目,如下所示:

  • javax.xml.parsers.DocumentBuilderFactory 替换 _oracle.xml.jaxp.JXDocumentBuilderFactory com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl

  • 对于javax.xml.parsers.SAXParserFactoryoracle.xml.jaxp.JXSAXParserFactory替换为com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl

  • 对于javax.xml.transform.TransformerFactoryoracle.xml.jaxp.JXSAXTransformerFactory替换为com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl

使用以下命令重新 jar 文件:

"C:\Program Files\Java\jdk1.7.0_02\bin\jar" -cvfm xmlparserv2.jar META-INF\MANIFEST.MF -c ./ .

将此新的 xmlparserv2.jar 文件复制到项目的 lib 目录中

于 2012-08-27T23:35:13.520 回答