我通过Arquillian(1.1.12.Final)向Tomcat 8.5.11部署了一个应用程序,其中查询了webervice。该应用程序将Apache CXF 3.1.10作为提供的依赖项;所有cxf和spring JAR都被添加到Tomcat上的endorsed
库目录中(我已验证所有已批准的JAR都已正确加载)。
尽管如此,我还是遇到了上述错误消息。堆栈跟踪的相关位是
java.lang.NullPointerException
at org.apache.cxf.BusFactory.getBusFactoryClass(BusFactory.java:397)
at org.apache.cxf.BusFactory.newInstance(BusFactory.java:317)
at org.apache.cxf.BusFactory.newInstance(BusFactory.java:304)
at org.apache.cxf.BusFactory.getDefaultBus(BusFactory.java:107)
at org.apache.cxf.BusFactory.createThreadBus(BusFactory.java:244)
at org.apache.cxf.BusFactory.getThreadDefaultBus(BusFactory.java:228)
at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:135)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:129)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:82)
at javax.xml.ws.Service.<init>(Service.java:77)
[剪断]
java.lang.NullPointerException
at org.apache.cxf.bus.extension.ExtensionManagerImpl.load(ExtensionManagerImpl.java:166)
at org.apache.cxf.bus.extension.ExtensionManagerImpl.load(ExtensionManagerImpl.java:160)
at org.apache.cxf.bus.extension.ExtensionManagerImpl.load(ExtensionManagerImpl.java:107)
at org.apache.cxf.bus.extension.ExtensionManagerBus.<init>(ExtensionManagerBus.java:178)
at org.apache.cxf.bus.extension.ExtensionManagerBus.<init>(ExtensionManagerBus.java:185)
at org.apache.cxf.bus.CXFBusFactory.createBus(CXFBusFactory.java:40)
at org.apache.cxf.bus.CXFBusFactory.createBus(CXFBusFactory.java:36)
at org.apache.cxf.bus.CXFBusFactory.createBus(CXFBusFactory.java:32)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:146)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:122)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:94)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:83)
at org.apache.cxf.BusFactory.getDefaultBus(BusFactory.java:107)
at org.apache.cxf.BusFactory.createThreadBus(BusFactory.java:244)
at org.apache.cxf.BusFactory.getThreadDefaultBus(BusFactory.java:228)
at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:135)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:129)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:82)
at javax.xml.ws.Service.<init>(Service.java:77)
NPE在Web服务初始化期间发生。失败的代码是
// org.apache.cxf.bus.extension.ExtensionManagerImpl
final void load(String resource) throws IOException {
if (loader != getClass().getClassLoader()) {
load(resource, getClass().getClassLoader());
}
load(resource, loader);
}
事实证明,对getClass().getClassLooader()
的调用会返回null
。我对这个结果感到困惑,却发现getClass().getClassLoader() is null, why?对我来说仍然没有意义,因为我认为这意味着CXF是使用bootclasspath加载的(!?!)。
答案 0 :(得分:0)
问题是由于在$CATALINA_HOME/endoresed
中放置了CXF广告牌引起的。这是放置所有webapps共有的jar的错误位置。正如在{XML Parsers and Java“部分的http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html中所解释的那样。