奇怪的 Xerces 方法访问错误
我已在 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
如果我在 xercesImpl.jar 中的 Java 反编译器中跟踪代码,我可以看到 DocumentBuilderFactoryImpl.setAttribute()
调用尝试创建一个新的 DocumentBuilderImpl
,这似乎是 IllegalAccessError
的原因。 DocumentBuilderImpl
的构造函数具有默认(包)访问权限,但 DocumentBuilderImpl
和 DocumentBuilderFactoryImpl
驻留在同一包 (org. apache.xerces.jaxp
)。
据我所知,错误发生时没有 SecurityManager
处于活动状态(而且我什至不确定 SecurityManager
是否会影响方法访问权限,我认为这只是为了类加载和资源访问权限)。
任何我能做什么的想法(除了以较少限制的访问权限重新编译 xerces JAR 之外,我想找出问题的根源,而不是解决它!,我也更喜欢使用标准 JAR,其中我能)。
我应该提到,我正在使用 Spring 3.0.5、OC4J 10.0.3.5.0(已采取解决方法以使用 Xerces XML 解析器而不是 Oracle XML 解析器)和 Java 1.6.0-21。
谢谢 格雷厄姆
I've tried this on both Xerces 2.9.1, and Xerces-J-2.11.0 with the same results.
I'm writing a Spring3 Webflow app, using Xerces for XML parsing. When deploying the EAR, I get an issue
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
If I trace the code in a Java Decompilor, in xercesImpl.jar
I can see the DocumentBuilderFactoryImpl.setAttribute()
call tries to create a new DocumentBuilderImpl
, this seems to be the cause of the IllegalAccessError
. The constructor for the DocumentBuilderImpl
has default (package) access, but both DocumentBuilderImpl
, and DocumentBuilderFactoryImpl
reside in the same package (org.apache.xerces.jaxp
).
As far as I'm aware, there is no SecurityManager
active at the time of the error (and I'm not even sure whether the SecurityManager
would affect method access permissions, I thought it was just for class loading, and resource access permissions).
Any ideas what I can do (short of recompiling the xerces JAR with less restrictive access permissions, I'd like to sort out the root of the problem, not work around it!, I'd also prefer to use the standard JARs where I can).
I should mention, I'm using Spring 3.0.5, OC4J 10.0.3.5.0 (with the work-around in place to use the Xerces XML parser instead of the Oracle XML parser), and Java 1.6.0-21.
Thanks
Graham
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您遇到了类加载器问题,因为您正在捆绑 Xerxes; Java 1.6 已经捆绑了 Xerces。
我在 xerces、activation 以及我们在 java 1.6 之前外部的一些其他库(现在捆绑在 JRE 中)遇到了许多“意外”问题。 :(
You're having a class-loader issue because you're bundling Xerxes; and Java 1.6 already bundles Xerces.
I've had many "unexpected" problems with xerces, activation, and a few other libraries that we external before java 1.6 and are now bundled in the JRE. :(