我在 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。
谢谢格雷厄姆