hoho,把你的xerces的包从加载路进上去掉,看看是否会出错,如果出错,证明用的就是!!!

解决方案 »

  1.   

    把你的xercesImpl.jar  xmlParserAPIs.jar加到classpath的最前面。
      

  2.   

    呵呵,修改一下javax.xml.parsers.SAXParserFactory.newInstance()的源码。
      

  3.   

    刚才又试了一下,把xercesImpl.jar xmlParserAPIs.jar 加到classpath的最前面也没反应
      

  4.   

    源代码是这样写的。你看看就明白了。
    public static SAXParserFactory newInstance()
            throws FactoryConfigurationError
        {
            try {
                return (SAXParserFactory) FactoryFinder.find(
                    /* The default property name according to the JAXP spec */
                    "javax.xml.parsers.SAXParserFactory",
                    /* The fallback implementation class name */
                    "org.apache.crimson.jaxp.SAXParserFactoryImpl");
            } catch (FactoryFinder.ConfigurationError e) {
                throw new FactoryConfigurationError(e.getException(),
                                                    e.getMessage());
            }
        }
      

  5.   

    呵呵,多谢,明白了。
    可我想找个不用修改源代码的方法:
    刚才发现jdk文档中是这样描述是按什么顺序来决定使用哪个类的:
    (1)Use the javax.xml.parsers.DocumentBuilderFactory system property. 
    (2)Use the properties file "lib/jaxp.properties" in the JRE directory. This configuration file is in standard java.util.Properties format and contains the fully qualified name of the implementation class with the key being the system property defined above. 
    (3)Use the Services API (as detailed in the JAR specification), if available, to determine the classname. The Services API will look for a classname in the file META-INF/services/javax.xml.parsers.DocumentBuilderFactory in jars available to the runtime. 
    (4)Platform default DocumentBuilderFactory instance.照此看来,我用的应该是方法2,我看不懂的是最优先使用的也就是第一个中所说的  the javax.xml.parsers.DocumentBuilderFactory system property 是什么东西?
      

  6.   

    是不是就是把"org.apache.crimson.jaxp.SAXParserFactoryImpl"中的crimson改为xerces就行了? 我怎么改了这个和DocumentBuilderFactory后重新生成class文件放入到rt.jar中,还是没又使用xerces,???
      

  7.   

    还有,按照文档中说明的顺序,代码中所修改的是不是最后一个"Platform default DocumentBuilderFactory instance",所以,我用第二中方法没有作用,那肯定就是第一种方法决定了使用默认的crimson解析器,如果真的是这样,那么改源码也就没有用了吧,可问题是第一种方法是什么呢?
      

  8.   

    (!) java -D org.xml.sax.driver=org.apache.xerces.parsers.SAXParser  xxx.class
      

  9.   

    追风的方法可行;多谢但是这还是没有达到我的目的,我要再eclipse下用啊。  能估计一下我用jaxp.properties的方法出现了什么错误吗?
    这个文件中的内容是不是就我上面写的那两句? 位置再JAVA_HOME\jre\lib下,没错吧?
      

  10.   

    搂主,那些说改JDK的是给你开玩笑的,你别当真阿
     znjq1001(追风)给的正解
    或者你在程序里面一开始就调用
      

  11.   

    靠刚才不小心点提交了
    System.setProperty(“org.xml.sax.driver”,“org.apache.xerces.parsers.SAXParser”)还可以在Eclipse里指定VM argument:
    org.xml.sax.driver=org.apache.xerces.parsers.SAXParser
      

  12.   

    啊,我还真的去改了源码并替换了原来rt.jar中对于的class。不过,添加jaxp.properties的方法应该也是正解,因为这在JDK文档中也这样说了,
    追风的方法是优先级最高的,添加jaxp.properties的方式排在第二,只是在我这儿这种方法总是不起作用,我把jaxp。properties输入些乱七八糟的东西,也不报错,  谁能估计是那些原因吗?
    我在其余的地方找了好久,也没找到答案
      

  13.   

    Eclipse不能加参数么? :)
    或者你在程序里面 System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); 试拭
      

  14.   

    通过这种方法也可以,但用jaxp.proties的方法要方便些,而且更换解析器时可以不用修改代码,所以我想弄明白,呵呵
      

  15.   

    理论上应该是没有问题了。
    是不是在什么地方设置了System Proper
    你在DocumentBuilderFactory.newInstance()前,取系统属性System.getProperty("javax.xml.parsers.DocumentBuilderFactory") 看看有没有值?要下班了。:)
      

  16.   

    返回的时null, 呵呵,真是奇怪,感觉好像没去读jaxp.properties文件一样
      

  17.   

    >>但用jaxp.proties的方法要方便些这不是好的做法,假如这台机器还跑着其它的应用程序,他们都会受影响