我想知道是否有人在安装时遇到了同样的问题:
WebLogic 12c
Docx4J 2.8.1
Java EE 6
我试图通过Docx4J获取某个Microsoft Word 2007文档的内容,但是出现了如下错误:
当我尝试做时:
WordprocessingMLPackage package = WordprocessingMLPackage.load(new File((path));
它将引发异常,如:
2013-06-05 15:29:12.0283 ERROR Thread-18 org.docx4j.jaxb.NamespacePrefixMapperUtils – name: com.sun.xml.internal.bind.namespacePrefixMapper value: org.docx4j.jaxb.NamespacePrefixMapperSunInternal@2b0bf3 .. trying RI.
javax.xml.bind.PropertyException: name: com.sun.xml.bind.namespacePrefixMapper value: org.docx4j.jaxb.NamespacePrefixMapper@2a3c7c
at org.eclipse.persistence.jaxb.JAXBMarshaller.setProperty(JAXBMarshaller.java:590)
at org.docx4j.jaxb.NamespacePrefixMapperUtils.tryUsingRI(NamespacePrefixMapperUtils.java:73)
at org.docx4j.jaxb.NamespacePrefixMapperUtils.getPrefixMapper(NamespacePrefixMapperUtils.java:64)
at org.docx4j.jaxb.Context.<clinit>(Context.java:56)
at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:666)
at org.docx4j.openpackaging.io.LoadFromZipNG.process(LoadFromZipNG.java:206)
at org.docx4j.openpackaging.io.LoadFromZipNG.get(LoadFromZipNG.java:193)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:301)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:245)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:195)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:178)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:172)
2013-06-05 15:29:12.0455 ERROR Thread-18 org.docx4j.jaxb.NamespacePrefixMapperUtils – JAXB: neither Reference Implementation nor Java 6 implementation present?
javax.xml.bind.PropertyException: name: com.sun.xml.bind.namespacePrefixMapper value: org.docx4j.jaxb.NamespacePrefixMapper@2a3c7c
at org.eclipse.persistence.jaxb.JAXBMarshaller.setProperty(JAXBMarshaller.java:590)
at org.docx4j.jaxb.NamespacePrefixMapperUtils.tryUsingRI(NamespacePrefixMapperUtils.java:73)
at org.docx4j.jaxb.NamespacePrefixMapperUtils.getPrefixMapper(NamespacePrefixMapperUtils.java:64)
at org.docx4j.jaxb.Context.<clinit>(Context.java:56)
at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:666)
at org.docx4j.openpackaging.io.LoadFromZipNG.process(LoadFromZipNG.java:206)
at org.docx4j.openpackaging.io.LoadFromZipNG.get(LoadFromZipNG.java:193)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:301)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:245)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:195)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:178)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:172)
如上所述,我正在使用JDK 6,所以这本来是不可能的消息。
但是上面的消息在内部被Docx4J抑制,而是引发以下异常:
2013-06-05 15:46:38.0392 ERROR Thread-18 com.jonathan.business.catalog.impl.ProductCatalogServiceImpl – Bad [Content_Types].xml
org.docx4j.openpackaging.exceptions.InvalidFormatException: Bad [Content_Types].xml
at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:699)
at org.docx4j.openpackaging.io.LoadFromZipNG.process(LoadFromZipNG.java:206)
at org.docx4j.openpackaging.io.LoadFromZipNG.get(LoadFromZipNG.java:193)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:301)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:245)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:195)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:178)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:172)
Caused by: java.lang.NullPointerException
at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:666)
... 12 more
2013-06-05 15:46:38.0392 ERROR Thread-18 com.jonathan.business.catalog.impl.ProductCatalogServiceImpl – Bad [Content_Types].xml
org.docx4j.openpackaging.exceptions.InvalidFormatException: Bad [Content_Types].xml
at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:699)
at org.docx4j.openpackaging.io.LoadFromZipNG.process(LoadFromZipNG.java:206)
at org.docx4j.openpackaging.io.LoadFromZipNG.get(LoadFromZipNG.java:193)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:301)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:245)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:195)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:178)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:172)
Caused by: java.lang.NullPointerException
at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:666)
... 12 more
Docx4J论坛中建议使用I tried this,但没有用。
This question也不会给出答案。
Java 6应该在内部具有它自己的JAXB实现,但是到目前为止,我已经尝试过:
不要在库中放入任何jaxb jar
放置jaxb jar版本:2.1.7、2.2.4和2.2.6,均无效。
另外,如果有什么帮助,如果我从void main运行它,同样的方法也可以工作,但是如果它是从WebLogic服务器执行的,则它就不起作用,因此我确信存在类加载问题。
最佳答案
据报道,要使docx4j与Weblogic 12c一起使用,您可以升级eclipselink,或切换到JAXB参考实现。
要升级Eclipselink,请参见http://www.docx4java.org/forums/weblogic-f25/how-to-update-to-eclipselink-2-5-in-web-t1574.html
http://www.docx4java.org/forums/weblogic-f25/classcastexception-in-weblogic-12c-t1643.html#p5675建议,就目前而言,切换到JAXB RI是更好的方法。
请注意,要将Eclipselink JAXB实现与docx4j一起使用,应使用docx4j 3 beta或更高版本。
关于java - Docx4J带有WebLogic 12c的错误[Content_Types] .xml,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16934344/