gpt4 book ai didi

java - 奇怪的 Xerces 方法访问错误

转载 作者:行者123 更新时间:2023-11-30 05:05:32 24 4
gpt4 key购买 nike

我已在 Xerces 2.9.1 和 Xerces-J-2.11.0 上尝试过此操作,结果相同。

我正在编写一个 Spring3 Webflow 应用程序,使用 Xerces 进行 XML 解析。部署 EAR 时,我遇到问题

Caused by: java.lang.IllegalAccessError: tried to access method org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(Lorg/apache/xerces/jaxp/DocumentBuilderFactoryImpl;Ljava/util/Hashtable;Ljava/util/Hashtable;)V from class org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.setAttribute(Unknown Source)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:99)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:70)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
... 30 more

如果我在 Java 反编译器中跟踪 xercesImpl.jar 中的代码,我可以看到 DocumentBuilderFactoryImpl.setAttribute() 调用尝试创建一个新的 DocumentBuilderImpl ,这似乎是 IllegalAccessError 的原因。 DocumentBuilderImpl 的构造函数具有默认(包)访问权限,但 DocumentBuilderImplDocumentBuilderFactoryImpl 驻留在同一包 (org. apache.xerces.jaxp)。

据我所知,错误发生时没有 SecurityManager 处于 Activity 状态(而且我什至不确定 SecurityManager 是否会影响方法访问权限,我以为只是类加载和资源访问权限)。

我能做什么的任何想法(除了以较少限制的访问权限重新编译 xerces JAR 之外,我想找出问题的根源,而不是解决它!,我也更喜欢使用标准我可以的 JAR)。

我应该提到,我正在使用 Spring 3.0.5、OC4J 10.0.3.5.0(使用 Xerces XML 解析器而不是 Oracle XML 解析器的解决方法)和 Java 1.6.0- 21.

谢谢格雷厄姆

最佳答案

您遇到了类加载器问题,因为您正在捆绑 Xerxes; Java 1.6 已经捆绑了 Xerces。

我在 xerces、激活以及我们在 java 1.6 之前外部的一些其他库(现在捆绑在 JRE 中)方面遇到了许多“意外”问题。 :(

关于java - 奇怪的 Xerces 方法访问错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5221267/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com