【发布时间】:2011-07-10 10:14:30
【问题描述】:
我在 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 的构造函数具有默认(包)访问权限,但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.
谢谢 格雷厄姆
【问题讨论】:
-
谁收藏了这个?我几乎没有提出这个问题,它被标记为最喜欢的。只是好奇。