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

CXF客户端调用时出错解决方法

    博客分类:
  • CXF
阅读更多
我在CXF客户端调用时出现如下错误:
2008-10-2 15:34:36 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1960f05: display name [org.springframework.context.support.ClassPathXmlApplicationContext@1960f05]; startup date [Thu Oct 02 15:34:36 CST 2008]; root of context hierarchy
2008-10-2 15:34:36 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [beanRefClient.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [beanRefClient.xml]; nested exception is javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found
Caused by: javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found
at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:87)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:68)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:361)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:313)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:290)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:173)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:112)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:79)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:101)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:394)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:324)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:122)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:66)
at ws.cxf.client.SurveyServiceClient.main(SurveyServiceClient.java:22)



解决方法 设置两个属性(javax.xml.parsers.DocumentBuilderFactory,javax.xml.parsers.SAXParserFactory)值如下:
System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
       "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
System.setProperty("javax.xml.parsers.SAXParserFactory",
       "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
再运行就没有错了.

最后发现原因是我使用MyEclipse创建项目时引用了J2EE 1.4 Library Container库(JAVA构建路径-->库)
使得sun.boot.class.path增加了myelipse下的jar文件,然后就把javax.xml.parsers.DocumentBuilderFactory变量的值设为org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
即还有第二种解决方法,就是去掉J2EE 1.4 Library Container库,编译,再运行就没有错了.

(JDK版本为1.5与6.0都测试通过).

请参考我的另外两篇转载的文章
DocumentBuilderFactory以及SAXParserFactory具体实现的查找步骤
http://lengweiping1983.iteye.com/blog/248553
XML api折射出sun与IBM的恩仇
http://lengweiping1983.iteye.com/blog/248560
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics