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