2011-03-07 102 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