在 Tomcat 上部署 Web 服务时出现 Xerces 错误
Xerces error when deploying Web Service on Tomcat
每当我尝试在 Tomcat 8 上部署 JAX-WS Web 服务时,我都会收到以下错误:
4-Mar-2015 10:35:35.730 SEVERE [http-nio-8085-exec-5] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class com.sun.xml.ws.transport.http.servlet.WSServletContextListener
com.sun.xml.ws.transport.http.servlet.WSServletException: WSSERVLET11: failed to parse runtime descriptor: java.lang.ClassCastException: org.apache.xerces.parsers.XML11Configuration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration
at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:139)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4760)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5184)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:581)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:455)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1496)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
即使有错误,我也能在 20% 的时间内部署 Web 服务,但大多数时候部署失败。
更新
按照评论中的建议,我列出了 WEB-INF\lib:
的内容
03/09/2015 08:53 AM 62,983 activation-1.1.jar
03/10/2015 04:43 PM 4,467 aopalliance-1.0.jar
03/16/2015 07:53 AM 63,966 avalon-framework-4.1.3.jar
03/16/2015 07:53 AM 21,007 commonj.sdo-2.1.1.jar
03/16/2015 07:50 AM 232,019 commons-beanutils-1.8.3.jar
03/16/2015 07:50 AM 284,184 commons-codec-1.10.jar
03/16/2015 07:48 AM 34,827 commons-csv-1.0.jar
03/16/2015 07:48 AM 160,519 commons-dbcp-1.4.jar
03/16/2015 07:48 AM 185,140 commons-io-2.4.jar
03/10/2015 04:43 PM 284,220 commons-lang-2.6.jar
03/16/2015 07:50 AM 412,739 commons-lang3-3.3.2.jar
03/16/2015 07:53 AM 52,915 commons-logging-1.1.jar
03/16/2015 07:48 AM 96,221 commons-pool-1.5.4.jar
03/16/2015 07:53 AM 8,613,667 eclipselink-2.5.1.jar
03/16/2015 07:50 AM 206,853 gson-2.3.jar
03/16/2015 07:48 AM 31,245 gt-epsg-extension-11.2.jar
03/16/2015 07:48 AM 1,960,275 gt-epsg-hsql-11.2.jar
03/16/2015 07:48 AM 505,719 gt-metadata-11.2.jar
03/16/2015 07:48 AM 345,672 gt-opengis-11.2.jar
03/16/2015 07:48 AM 1,143,704 gt-referencing-11.2.jar
03/16/2015 07:48 AM 1,395,415 hsqldb-2.2.8.jar
03/16/2015 07:48 AM 590,533 httpclient-4.3.5.jar
03/16/2015 07:48 AM 282,269 httpcore-4.3.2.jar
03/16/2015 07:50 AM 38,605 jackson-annotations-2.4.0.jar
03/16/2015 07:50 AM 225,316 jackson-core-2.4.2.jar
03/16/2015 07:50 AM 1,075,759 jackson-databind-2.4.2.jar
03/16/2015 07:48 AM 1,900,631 jai_core-1.1.3.jar
03/16/2015 07:53 AM 2,497 javax.inject-1.jar
03/16/2015 07:53 AM 162,126 javax.persistence-2.1.0.jar
03/24/2015 03:59 PM 102,528 jaxb-api-2.2.12-b141001.1542.jar
03/19/2015 03:32 PM 854,901 jaxb-impl-2.1.7.jar
03/16/2015 07:53 AM 144,283 jaxb2-basics-runtime-0.9.1.jar
03/09/2015 08:53 AM 33,428 jaxws-api-2.1.jar
03/19/2015 03:32 PM 1,284,131 jaxws-rt-2.1.4.jar
03/16/2015 07:50 AM 16,458 jcl-over-slf4j-1.7.1.jar
03/16/2015 07:48 AM 11,497 jgridshift-1.0.jar
03/16/2015 07:50 AM 586,201 joda-time-2.4.jar
03/16/2015 07:48 AM 54,203 json-smart-1.2.jar
03/16/2015 07:48 AM 91,347 jsr-275-1.0-beta-2.jar
03/16/2015 07:48 AM 710,293 jts-1.11.jar
03/19/2015 03:32 PM 121,658 junit-3.8.jar
03/16/2015 07:50 AM 489,884 log4j-1.2.17.jar
03/16/2015 07:53 AM 72,150 logkit-1.0.1.jar
03/09/2015 09:46 AM 388,864 mail-1.4.jar
03/19/2015 03:32 PM 38,665 mimepull-1.2.jar
03/25/2015 10:33 AM 429,408 mojo-MojoGlobal-1.0-SNAPSHOT.jar
03/20/2015 11:43 AM 75,239 MojoAlerts-1.0-SNAPSHOT.jar
03/25/2015 10:33 AM 757,460 MojoInterfaces-1.0-SNAPSHOT.jar
03/25/2015 10:33 AM 571,604 MojoSimulation-1.0.jar
03/24/2015 02:03 PM 3,389,454 ojdbc6-6.jar
03/16/2015 07:50 AM 2,097,954 PDFRenderer-0.9.0.jar
03/09/2015 08:53 AM 68,177 resolver-20050927.jar
03/09/2015 08:53 AM 18,817 saaj-api-1.3.jar
03/19/2015 03:32 PM 278,293 saaj-impl-1.3.1.jar
03/19/2015 03:32 PM 332,055 sjsxp-1.0.1.jar
03/16/2015 07:53 AM 26,065 slf4j-api-1.7.1.jar
03/16/2015 07:50 AM 8,867 slf4j-log4j12-1.7.9.jar
03/16/2015 07:50 AM 337,694 spring-aop-3.2.8.RELEASE.jar
03/16/2015 07:50 AM 612,569 spring-beans-3.2.8.RELEASE.jar
03/16/2015 07:50 AM 866,273 spring-context-3.2.8.RELEASE.jar
03/16/2015 07:48 AM 873,608 spring-core-3.2.8.RELEASE.jar
03/16/2015 07:50 AM 383,327 spring-data-commons-1.6.1.RELEASE.jar
03/16/2015 07:50 AM 196,367 spring-expression-3.2.8.RELEASE.jar
03/16/2015 07:52 AM 405,717 spring-jdbc-3.2.8.RELEASE.jar
03/16/2015 07:50 AM 374,411 spring-ldap-core-2.0.2.RELEASE.jar
03/16/2015 07:50 AM 366,941 spring-security-core-3.2.5.RELEASE.jar
03/16/2015 07:50 AM 242,436 spring-tx-3.2.8.RELEASE.jar
03/19/2015 03:32 PM 26,310 stax-api-1.0.jar
03/09/2015 08:53 AM 11,074 stax-ex-1.2.jar
03/19/2015 03:32 PM 57,984 streambuffer-0.7.jar
03/16/2015 07:48 AM 249,354 vecmath-1.3.2.jar
03/26/2015 08:53 AM 895,924 xercesImpl-2.4.0.jar
更新 2
将 xercesImpl 版本从 2.4.0 更改为 2.11.0(最新版本)似乎解决了 ClassCastException
但它产生了以下错误:
INFO: Illegal access: this web application instance has been stopped already. Could not load META-INF/services/org.apache.xerces.xni.parser.XMLParserConfiguration. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
Mar 26, 2015 11:47:43 AM com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextInitialized
SEVERE: WSSERVLET11: failed to parse runtime descriptor: java.lang.NullPointerException
java.lang.NullPointerException
at org.apache.catalina.loader.WebappClassLoader.getResourceAsStream(WebappClassLoader.java:1542)
at org.apache.xerces.parsers.SecuritySupport.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.<init>(Unknown Source)
at org.apache.xerces.parsers.SAXParser.<init>(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.<init>(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.<init>(Unknown 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:687)
at com.sun.xml.ws.util.xml.XmlUtil.createEntityResolver(XmlUtil.java:270)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.createEntityResolver(DeploymentDescriptorParser.java:402)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:253)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:147)
at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:108)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5016)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5524)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:672)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:547)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1668)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1516)
at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:912)
at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:371)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:613)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
据我所知,Illegal access
似乎仍然与 xerces 依赖关系有关
我遇到了两个与 Xerces 相关的错误,所以我发布了解决每个错误的方法:
ClassCastException
错误已通过更新到最新版本的 xerces 解决:
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
如评论中所述,确保删除任何其他与 Xerces 相关的依赖项并仅保留上面的依赖项。
为了解决 Illegal Access
问题,我发现 this post 提出了从 xerces-Impl.jar
中删除以下文件的建议解决方案
META-INF/service/javax.xml.parsers.DocumentBuilderFactory
META-INF/services/javax.xml.parsers.SAXParserFactory
我意识到更改依赖关系有点麻烦,如果删除本地 maven 存储库中的文件并从 Maven Central 重新下载它可能会适得其反,但这是我能找到的最佳解决方案。
我解决了这个问题,从 lib 文件夹中删除了 xerces-Impl.jar
我遇到了同样的问题。我正在使用 gradle 构建部署到 tomcat 的网络应用程序。我通过 "gradle dependencies" 命令确定了正在使用的 xerces 版本。然后我在 build.gradle 文件中指出将提供 xerces。
提供编译"xerces:xercesImpl:2.9.1"
问题似乎已解决。
我知道您可以使用提供的范围在 Maven 中做同样的事情。
每当我尝试在 Tomcat 8 上部署 JAX-WS Web 服务时,我都会收到以下错误:
4-Mar-2015 10:35:35.730 SEVERE [http-nio-8085-exec-5] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class com.sun.xml.ws.transport.http.servlet.WSServletContextListener
com.sun.xml.ws.transport.http.servlet.WSServletException: WSSERVLET11: failed to parse runtime descriptor: java.lang.ClassCastException: org.apache.xerces.parsers.XML11Configuration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration
at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:139)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4760)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5184)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:581)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:455)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1496)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
即使有错误,我也能在 20% 的时间内部署 Web 服务,但大多数时候部署失败。
更新
按照评论中的建议,我列出了 WEB-INF\lib:
的内容03/09/2015 08:53 AM 62,983 activation-1.1.jar
03/10/2015 04:43 PM 4,467 aopalliance-1.0.jar
03/16/2015 07:53 AM 63,966 avalon-framework-4.1.3.jar
03/16/2015 07:53 AM 21,007 commonj.sdo-2.1.1.jar
03/16/2015 07:50 AM 232,019 commons-beanutils-1.8.3.jar
03/16/2015 07:50 AM 284,184 commons-codec-1.10.jar
03/16/2015 07:48 AM 34,827 commons-csv-1.0.jar
03/16/2015 07:48 AM 160,519 commons-dbcp-1.4.jar
03/16/2015 07:48 AM 185,140 commons-io-2.4.jar
03/10/2015 04:43 PM 284,220 commons-lang-2.6.jar
03/16/2015 07:50 AM 412,739 commons-lang3-3.3.2.jar
03/16/2015 07:53 AM 52,915 commons-logging-1.1.jar
03/16/2015 07:48 AM 96,221 commons-pool-1.5.4.jar
03/16/2015 07:53 AM 8,613,667 eclipselink-2.5.1.jar
03/16/2015 07:50 AM 206,853 gson-2.3.jar
03/16/2015 07:48 AM 31,245 gt-epsg-extension-11.2.jar
03/16/2015 07:48 AM 1,960,275 gt-epsg-hsql-11.2.jar
03/16/2015 07:48 AM 505,719 gt-metadata-11.2.jar
03/16/2015 07:48 AM 345,672 gt-opengis-11.2.jar
03/16/2015 07:48 AM 1,143,704 gt-referencing-11.2.jar
03/16/2015 07:48 AM 1,395,415 hsqldb-2.2.8.jar
03/16/2015 07:48 AM 590,533 httpclient-4.3.5.jar
03/16/2015 07:48 AM 282,269 httpcore-4.3.2.jar
03/16/2015 07:50 AM 38,605 jackson-annotations-2.4.0.jar
03/16/2015 07:50 AM 225,316 jackson-core-2.4.2.jar
03/16/2015 07:50 AM 1,075,759 jackson-databind-2.4.2.jar
03/16/2015 07:48 AM 1,900,631 jai_core-1.1.3.jar
03/16/2015 07:53 AM 2,497 javax.inject-1.jar
03/16/2015 07:53 AM 162,126 javax.persistence-2.1.0.jar
03/24/2015 03:59 PM 102,528 jaxb-api-2.2.12-b141001.1542.jar
03/19/2015 03:32 PM 854,901 jaxb-impl-2.1.7.jar
03/16/2015 07:53 AM 144,283 jaxb2-basics-runtime-0.9.1.jar
03/09/2015 08:53 AM 33,428 jaxws-api-2.1.jar
03/19/2015 03:32 PM 1,284,131 jaxws-rt-2.1.4.jar
03/16/2015 07:50 AM 16,458 jcl-over-slf4j-1.7.1.jar
03/16/2015 07:48 AM 11,497 jgridshift-1.0.jar
03/16/2015 07:50 AM 586,201 joda-time-2.4.jar
03/16/2015 07:48 AM 54,203 json-smart-1.2.jar
03/16/2015 07:48 AM 91,347 jsr-275-1.0-beta-2.jar
03/16/2015 07:48 AM 710,293 jts-1.11.jar
03/19/2015 03:32 PM 121,658 junit-3.8.jar
03/16/2015 07:50 AM 489,884 log4j-1.2.17.jar
03/16/2015 07:53 AM 72,150 logkit-1.0.1.jar
03/09/2015 09:46 AM 388,864 mail-1.4.jar
03/19/2015 03:32 PM 38,665 mimepull-1.2.jar
03/25/2015 10:33 AM 429,408 mojo-MojoGlobal-1.0-SNAPSHOT.jar
03/20/2015 11:43 AM 75,239 MojoAlerts-1.0-SNAPSHOT.jar
03/25/2015 10:33 AM 757,460 MojoInterfaces-1.0-SNAPSHOT.jar
03/25/2015 10:33 AM 571,604 MojoSimulation-1.0.jar
03/24/2015 02:03 PM 3,389,454 ojdbc6-6.jar
03/16/2015 07:50 AM 2,097,954 PDFRenderer-0.9.0.jar
03/09/2015 08:53 AM 68,177 resolver-20050927.jar
03/09/2015 08:53 AM 18,817 saaj-api-1.3.jar
03/19/2015 03:32 PM 278,293 saaj-impl-1.3.1.jar
03/19/2015 03:32 PM 332,055 sjsxp-1.0.1.jar
03/16/2015 07:53 AM 26,065 slf4j-api-1.7.1.jar
03/16/2015 07:50 AM 8,867 slf4j-log4j12-1.7.9.jar
03/16/2015 07:50 AM 337,694 spring-aop-3.2.8.RELEASE.jar
03/16/2015 07:50 AM 612,569 spring-beans-3.2.8.RELEASE.jar
03/16/2015 07:50 AM 866,273 spring-context-3.2.8.RELEASE.jar
03/16/2015 07:48 AM 873,608 spring-core-3.2.8.RELEASE.jar
03/16/2015 07:50 AM 383,327 spring-data-commons-1.6.1.RELEASE.jar
03/16/2015 07:50 AM 196,367 spring-expression-3.2.8.RELEASE.jar
03/16/2015 07:52 AM 405,717 spring-jdbc-3.2.8.RELEASE.jar
03/16/2015 07:50 AM 374,411 spring-ldap-core-2.0.2.RELEASE.jar
03/16/2015 07:50 AM 366,941 spring-security-core-3.2.5.RELEASE.jar
03/16/2015 07:50 AM 242,436 spring-tx-3.2.8.RELEASE.jar
03/19/2015 03:32 PM 26,310 stax-api-1.0.jar
03/09/2015 08:53 AM 11,074 stax-ex-1.2.jar
03/19/2015 03:32 PM 57,984 streambuffer-0.7.jar
03/16/2015 07:48 AM 249,354 vecmath-1.3.2.jar
03/26/2015 08:53 AM 895,924 xercesImpl-2.4.0.jar
更新 2
将 xercesImpl 版本从 2.4.0 更改为 2.11.0(最新版本)似乎解决了 ClassCastException
但它产生了以下错误:
INFO: Illegal access: this web application instance has been stopped already. Could not load META-INF/services/org.apache.xerces.xni.parser.XMLParserConfiguration. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
Mar 26, 2015 11:47:43 AM com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextInitialized
SEVERE: WSSERVLET11: failed to parse runtime descriptor: java.lang.NullPointerException
java.lang.NullPointerException
at org.apache.catalina.loader.WebappClassLoader.getResourceAsStream(WebappClassLoader.java:1542)
at org.apache.xerces.parsers.SecuritySupport.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.<init>(Unknown Source)
at org.apache.xerces.parsers.SAXParser.<init>(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.<init>(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.<init>(Unknown 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:687)
at com.sun.xml.ws.util.xml.XmlUtil.createEntityResolver(XmlUtil.java:270)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.createEntityResolver(DeploymentDescriptorParser.java:402)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:253)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:147)
at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:108)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5016)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5524)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:672)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:547)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1668)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1516)
at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:912)
at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:371)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:613)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
据我所知,Illegal access
似乎仍然与 xerces 依赖关系有关
我遇到了两个与 Xerces 相关的错误,所以我发布了解决每个错误的方法:
ClassCastException
错误已通过更新到最新版本的 xerces 解决:
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
如评论中所述,确保删除任何其他与 Xerces 相关的依赖项并仅保留上面的依赖项。
为了解决 Illegal Access
问题,我发现 this post 提出了从 xerces-Impl.jar
META-INF/service/javax.xml.parsers.DocumentBuilderFactory
META-INF/services/javax.xml.parsers.SAXParserFactory
我意识到更改依赖关系有点麻烦,如果删除本地 maven 存储库中的文件并从 Maven Central 重新下载它可能会适得其反,但这是我能找到的最佳解决方案。
我解决了这个问题,从 lib 文件夹中删除了 xerces-Impl.jar
我遇到了同样的问题。我正在使用 gradle 构建部署到 tomcat 的网络应用程序。我通过 "gradle dependencies" 命令确定了正在使用的 xerces 版本。然后我在 build.gradle 文件中指出将提供 xerces。
提供编译"xerces:xercesImpl:2.9.1"
问题似乎已解决。
我知道您可以使用提供的范围在 Maven 中做同样的事情。