`
sd6292766
  • 浏览: 103829 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

找不到org.apache.xerces.jaxp.DocumentBuilderFactoryImpl的处理方法

阅读更多
    最近打算复习下SPRING,顺便写个例子,结果在跑程序的时候,出现了“org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found”的报错信息,程序没有从SPRING配置文件里面读取到相应的注入BEAN,程序样例为:
   
   
        Resource res = new ClassPathResource("SPRING配置文件路径");
        BeanFactory factory = new XmlBeanFactory(res);    
   

在用Bean工厂解析配置文件时出现上述错误,在网上找到了解决的原因。DocumentBuilderFactoryImpl 类是BeanFactory 默认采用的解析xml类,解决方法是,在上面两句话之前加上一句,
System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
				"com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");


源代码为:
   
System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
				"com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
        Resource res = new ClassPathResource("SPRING配置文件路径");
        BeanFactory factory = new XmlBeanFactory(res);  

之后,获取Bean对象,测试通过。
分享到:
评论

相关推荐

    xerces-2.9.0.jar

    如果找不到 `org.apache.xerces.jaxp.DocumentBuilderFactoryImpl` 这个提供商,那么会抛出这个异常,这意味着 Xerces 解析器可能没有正确地添加到类路径(classpath)或者系统没有配置正确的服务提供者。...

    apache-xml-xerces.jar.zip

    - **配置解析器**:在Java代码中,可以通过`org.apache.xerces.jaxp.DocumentBuilderFactoryImpl`或`org.apache.xerces.jaxp.SAXParserFactoryImpl`来创建并配置解析器。 - **错误处理**:解析过程中如果遇到错误,...

    xerces-2.6.0.jar

    System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp....

    xercesimpl-2.8.1.jar

    import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; public class XercesDemo { public static void main(String[] args) { try { DocumentBuilderFactory factory = DocumentBuilderFactory.new...

    Java解析XML

    - `com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl` 和 `com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl`:这是Java默认的XML解析器,基于Xerces实现。 - `org.w3c.dom` 和 `...

    Java类加载器学习总结.pdf

    - `DocumentBuilderFactory`类:用于创建XML解析器工厂实例,它支持SPI机制,可以通过`newInstance()`方法指定具体的实现类,如`org.apache.xerces.jaxp.DocumentBuilderFactoryImpl`。 了解Java类加载器的工作原理...

    CXF support WAS Weblogic

    ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl** 当使用Oracle OC4J时,可能会遇到此类错误。解决方案通常是更换XML解析器,例如用Xerces替换Oracle自带的解析器。 **2. HTTP 500访问...

    AntiSamy-1.5.7-With-ColdFusion-10:我演示如何在ColdFusion 10和JavaLoader 1.2组件的帮助下使用AntiSamy 1.5.7

    特别感兴趣的是, index.cfm页面展示了JavaLoader方法.switchThreadContextClassLoader() ,这是AntiSamy 1.5.7所必需的,以避免出现类装入错误,例如: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl无法...

Global site tag (gtag.js) - Google Analytics