Exception in thread "main" java.lang.AbstractMethodError: org.apache.crimson.tree.ElementNode.getTextContent()Ljava/lang/String;
是包沖突,我遇到過
經過google ,發現一個網址 http://www.wangchao.net.cn/bbsdetail_54929.html
上面說:
在系統中存在著多個解析器的時候,這時候程序是如何選擇解析器的呢?
比如你引用了別人的jar包,很有可能不同的jar包使用了不同的解析器從而引起沖突。
通過閱讀JDK源碼javax.xml.parsers.FactoryFinder,javax.xml.parsers.SAXParserFactory以及DocumentBuilderFactory發現JDK按照如下順序:
1. 系統屬性javax.xml.parsers.DocumentBuilderFactory或javax.xml.parsers.SAXParserFactory
2. 在jdk-dir/lib/jaxp.properties中設定的javax.xml.parsers.DocumentBuilderFactory或javax.xml.parsers.SAXParserFactory屬性
3. 運行時jar包中META-INF/services/javax.xml.parsers.DocumentBuilderFactory或javax.xml.parsers.SAXParserFactory文件中設定的值
4. 如果上面的解析器都沒有找到,則使用Crimson。如果還沒有。。。。。。那只能ClassNotFound了。
然后我在程序中添加這么一行System.setProperty("javax.xml.parsers.DocumentBuilderFactory","com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
這樣就可以引用到正確的構造工廠。。。。
posted on 2010-09-03 11:39 tobyxiong 閱讀(8736) 評論(0) 編輯 收藏 所屬分類: java