我已经通过Arquillian(1.1.12. -final)部署了一个应用程序,该应用程序被查询了Webervice。该应用程序具有APACHE CXF 3.1.10作为提供的依赖关系;所有CXF和Spring Jar都添加到Tomcat上的endorsed
库目录中(我已经确认了所有认可的罐子都正确加载了)。
尽管如此,我遇到了上述错误消息。堆栈的相关位是
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)
[SNIP]
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()是无效的,为什么?这对我来说仍然没有意义,因为我认为这意味着使用BootClassPath加载了CXF(!?!)。
问题是由将CXF JARS放置在$CATALINA_HOME/endoresed
中引起的。这是放置所有WebApp共有的罐子的错误位置。如http://tomcat.apache.org/tomcat-7.0.0-doc/class-loader-howto.html," xml Parsers and Java"部分。