2011-03-07 101 views
1

我已经在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的构造函数具有默认(包)访问权限,但DocumentBuilderImplDocumentBuilderFactoryImpl都位于同一个包(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。

感谢 格雷厄姆

+0

谁收藏这个?我几乎没有问题,它被标记为最喜欢的。只是好奇。 – GKelly 2011-03-07 15:14:15

回答

2

,你现在的类加载器的问题,因为你捆绑薛西斯; Java 1.6已经捆绑了Xerces。

我在java 1.6之前使用了xerces,激活以及其他一些库,这些问题我们都是外部的,现在已经捆绑在JRE中了。 :(

+0

所以,我不应该捆绑JAR文件?我会试试这个。谢谢。 – GKelly 2011-03-07 15:50:17

+0

是,将它们从您的应用程序中删除。不幸的是,我还没有找到现在已经捆绑在java中的库的列表,并且不应该添加:(。 – Augusto 2011-03-07 15:59:15

+0

谢谢,我试着删除对xerces JAR的所有引用,它似乎现在工作。 – GKelly 2011-03-08 11:13:57