zoukankan      html  css  js  c++  java
  • NullPointerException org.apache.commons.digester.Digester.getXMLReader(Digester.java:1058)

    http://pwu-developer.blogspot.com/2010/01/nullpointerexception.html

    Maven is great build tool making it easy to fetch all the library dependencies for a particular build. But what happens when you've got an application that uses wide variety of libraries of which can be dependent on the same library but different versions. Indeed we can have conflicts and the title of this blog is what I got as a result of some transitive dependency of Apache CXF.

    The root cause of the above error is because an older version of the SAXParserFactory was being used. The class loaders for commons digester was using the SAXParserFactory from another JAR file in the classpath rather than the one provided in the JDK 1.6.
    Others have had similar problems as in this forum

    It turns out I had ther xercesImpl-2.6.2 in my classpath. This I needed to remove and boilied down to adding exclusions in my POM file as follows:

    <!-- 
        ========================
        Apache CXF Web services
        ========================
        -->
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-bundle-minimal</artifactId>
            <version>2.2.4</version>
            
            <exclusions>
                <exclusion>
                    <groupId>xalan</groupId>                
                    <artifactId>xalan</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>xalan</groupId>                
                    <artifactId>serializer</artifactId>
                </exclusion>
    
                <exclusion>
                    <groupId>xom</groupId>
                    <artifactId>xom</artifactId>
                </exclusion>        
    
                <exclusion>
                    <groupId>xerces</groupId>
                    <artifactId>xerces</artifactId>
                </exclusion>
    
                <exclusion>
                    <groupId>xerces</groupId>
                    <artifactId>xercesImpl</artifactId>
                </exclusion>
    
                <exclusion>
                    <groupId>xerces</groupId>
                    <artifactId>xmlParserAPIs</artifactId>
                </exclusion>
                
                <exclusion>
                    <groupId>org.apache.santuario</groupId>
                    <artifactId>xmlsec</artifactId>
                </exclusion>            
                
            </exclusions>        
            
        </dependency>  

    ---------------

    maven 引入依赖时,会进行传递依赖也引入。

    比如 a.jar 依赖 x.jar; b.jar 页依赖x.jar;

    但是 a.jar依赖的是 x-1.1.jar; b.jar 依赖的是 x-1.0.jar;

    这样的话,项目的就会同时引入了 x-1.1.jar 和 x-1.0.jar

    这样的话,需要将 x-1.0.jar 进行排除出去;因为 a.jar 依赖x-1.1jar,但是因为同时存在 x-1.1.jar 和 x-1.0.jar 的话,a.jar 可能会使用x-1.0.jar而没有使用 x-1.1.jar;

    这样可能会导致a.jar报错。所以需要将 x-1.0.jar 排除出去;

    而 b.jar 依赖于 x-1.0.jar,因为 x-1.1.jar版本比 x-1.0.jar高,所以 b.jar使用 x-1.1.jar 和 使用 x-1.0.jar都应该没有问题;一般高版本会兼容低版本;

    反过来就不行。

    自己项目中删除掉 xerces-2.6.2.jar包就好了。

    注意tomcat也要进行清理,不能仅仅在 eclipse 中删除,因为 删除了eclipse中项目中的jar包,tomcat中的可能并没有删除。所以需要进行 一下 clean.

  • 相关阅读:
    Gartner:安全软件在经济危机中独善其身 狼人:
    美军正式成立网络战司令部 保护美军网络 狼人:
    警惕“搜房网”“凯业房园”等网站被挂马 狼人:
    Gartner:08年全球杀毒软件市场份额排名 微软第七 狼人:
    专访梭子鱼:以“立体交付”保障Web应用安全 狼人:
    安全专家称Opera Unite或成黑客“好友” 狼人:
    微软正式提供免费杀毒软件下载 仅限7.5万份 狼人:
    电信故障引发全国多地上网难 京沪等地受影响 狼人:
    中国拟修订保守国家秘密法 严防通过互联网泄密 狼人:
    Google推反恶意广告网站 防护恶意软件威胁 狼人:
  • 原文地址:https://www.cnblogs.com/digdeep/p/6419159.html
Copyright © 2011-2022 走看看