我已经在Xerces 2.9.1和Xerces-J-2.11.0上试了这个,结果相同。奇怪的Xerces方法访问错误
我在写一个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 Decompilor的代码,在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。
感谢 格雷厄姆
谁收藏这个?我几乎没有问题,它被标记为最喜欢的。只是好奇。 – GKelly 2011-03-07 15:14:15