java – 当xercesImpl.jar位于类路径上时,NetBeans Web服务客户端出现问题

当xercesImpl.jar作为库包含时,我无法在NetBeans Web应用程序中创建Web服务客户端.

使用NetBeans 6.9和GlassFish 3.0.1:

1.)创建新的Web应用程序
2.)创建一个新的Web服务
3.)向创建的Web服务添加一个新操作(只是让它返回null – 实现并不重要)
4.)将Web服务部署到GlassFish(工作正常)
5.)将xercesImpl.jar(我使用的是版本2.9.1)添加为Web服务的库(我需要使用xerces作为我正在使用的第三方库)
6.)停止Glassfish.
7.)清理并构建项目.
8.)运行项目.测试Web服务是否仍然有效(确实如此).
9.)创建一个新的Web服务客户端.将它指向WSDL(我正在使用http://www.webservicex.com/CurrencyConvertor.asmx?wsdl作为测试).
10.)停止Glassfish.
11.)清理并构建项目.

显示错误消息:

C:\NetBeansprojects\WSTest\nbproject\jaxws-build.xml:43:
Error starting wsimport: BUILD Failed
(total time: 1 second)

第43行是:

12.)重新启动NetBeans.
13.)清理并构建项目. (现在构建工作)
14.)运行项目.除了这个单行错误消息外,GlassFish启动正常:

SEVERE: Error in resolving the catalog

15.)加载Web Service Tester页面会在GlassFish日志中产生以下异常:

WARNING: Servlet web service endpoint 'NewWebService' failure
java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load resource [meta-inf/services/org.apache.xerces.xni.parser.XMLParserConfiguration],because it has not yet been started,or was already stopped
at org.glassfish.web.loader.WebappClassLoader.findResourceInternal(WebappClassLoader.java:2085)
at org.glassfish.web.loader.WebappClassLoader.findResource(WebappClassLoader.java:1018)
at org.glassfish.web.loader.WebappClassLoader.getResourceAsstream(WebappClassLoader.java:1255)
at org.apache.xerces.parsers.SecuritySupport$6.run(UnkNown Source)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.xerces.parsers.SecuritySupport.getResourceAsstream(UnkNown Source)
at org.apache.xerces.parsers.ObjectFactory.findJarServiceProvider(UnkNown Source)
at org.apache.xerces.parsers.ObjectFactory.createObject(UnkNown Source)
at org.apache.xerces.parsers.ObjectFactory.createObject(UnkNown Source)
at org.apache.xerces.parsers.SAXParser.Nown Source)
at org.apache.xerces.parsers.SAXParser.Nown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.Nown Source)
at org.apache.xerces.jaxp.SAXParserImpl.Nown Source)
at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(UnkNown Source)
at com.sun.org.apache.xml.internal.resolver.readers.SAXCatalogReader.readCatalog(SAXCatalogReader.java:238)
at com.sun.org.apache.xml.internal.resolver.Catalog.parseCatalog(Catalog.java:680)
at com.sun.xml.ws.util.xml.XmlUtil.createEntityResolver(XmlUtil.java:270)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:560)
at org.glassfish.webservices.JAXWSServlet.registerEndpoint(JAXWSServlet.java:405)
at org.glassfish.webservices.JAXWSServlet.doInit(JAXWSServlet.java:264)
at org.glassfish.webservices.JAXWSServlet.init(JAXWSServlet.java:99)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1428)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:1060)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:187)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:619)

WARNING: StandardWrapperValve[NewWebService]: PWC1382: Allocate exception for servlet NewWebService
javax.servlet.servletexception
at org.glassfish.webservices.JAXWSServlet.doInit(JAXWSServlet.java:271)
at org.glassfish.webservices.JAXWSServlet.init(JAXWSServlet.java:99)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1428)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:1060)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:187)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load resource [meta-inf/services/org.apache.xerces.xni.parser.XMLParserConfiguration],or was already stopped
at org.glassfish.web.loader.WebappClassLoader.findResourceInternal(WebappClassLoader.java:2085)
at org.glassfish.web.loader.WebappClassLoader.findResource(WebappClassLoader.java:1018)
at org.glassfish.web.loader.WebappClassLoader.getResourceAsstream(WebappClassLoader.java:1255)
at org.apache.xerces.parsers.SecuritySupport$6.run(UnkNown Source)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.xerces.parsers.SecuritySupport.getResourceAsstream(UnkNown Source)
at org.apache.xerces.parsers.ObjectFactory.findJarServiceProvider(UnkNown Source)
at org.apache.xerces.parsers.ObjectFactory.createObject(UnkNown Source)
at org.apache.xerces.parsers.ObjectFactory.createObject(UnkNown Source)
at org.apache.xerces.parsers.SAXParser.Nown Source)
at org.apache.xerces.parsers.SAXParser.Nown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.Nown Source)
at org.apache.xerces.jaxp.SAXParserImpl.Nown Source)
at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(UnkNown Source)
at com.sun.org.apache.xml.internal.resolver.readers.SAXCatalogReader.readCatalog(SAXCatalogReader.java:238)
at com.sun.org.apache.xml.internal.resolver.Catalog.parseCatalog(Catalog.java:680)
at com.sun.xml.ws.util.xml.XmlUtil.createEntityResolver(XmlUtil.java:270)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:560)
at org.glassfish.webservices.JAXWSServlet.registerEndpoint(JAXWSServlet.java:405)
at org.glassfish.webservices.JAXWSServlet.doInit(JAXWSServlet.java:264)
... 26 more

关于我能做些什么来解决这个问题的任何想法?请注意,它仅在我创建新的Web服务客户端/参考之后发生.即使有人可以建议我应该创建一个错误的项目(即它是一个NetBeans错误吗?一个Glassfish错误一个JAX-WS错误?等等),这将是好事.

最佳答案
好吧,我终于找到了解决方案:

http://forums.java.net/jive/thread.jspa?threadID=59445

我需要做的是从xercesImpl.jar文件删除这些文件

meta-inf/services/javax.xml.parsers.DocumentBuilderFactory
meta-inf/services/javax.xml.parsers.SAXParserFactory

修改后的JAR文件包含在我的项目中时,它不再导致任何问题.

如果有人有更整洁的解决方案,请告诉我.

相关文章

Java中的String是不可变对象 在面向对象及函数编程语言中,不...
String, StringBuffer 和 StringBuilder 可变性 String不可变...
序列化:把对象转换为字节序列的过程称为对象的序列化. 反序...
先说结论,是对象!可以继续往下看 数组是不是对象 什么是对...
为什么浮点数 float 或 double 运算的时候会有精度丢失的风险...
面试题引入 这里引申出一个经典问题,看下面代码 Integer a ...