简体   繁体   中英

Tomcat8 org.apache.cxf.BusFactory.getBusFactoryClass Failed to determine BusFactory implementation class name

I've got an application deployed to Tomcat 8.5.11 via Arquillian (1.1.12.Final) where a webervice is queried. The application has Apache CXF 3.1.10 as a provided dependency; all cxf and spring JARs were added to the endorsed libraries directory on Tomcat (I've verified all endorsed JARs are loaded correctly).

Despite this I encounter the aforementioned error message. The relevant bits of the stacktrace are

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)

The NPE occurs during the initialization of the webservice. The code that fails is

// org.apache.cxf.bus.extension.ExtensionManagerImpl
final void load(String resource) throws IOException {
    if (loader != getClass().getClassLoader()) {
        load(resource, getClass().getClassLoader());
    }
    load(resource, loader);
}

It turns out that the call to getClass().getClassLooader() returns null . I was puzzled by this result only to find out getClass().getClassLoader() is null, why? which still doesn't make sense to me, as I think this means CXF was loaded using the bootclasspath (!?!).

The problem was caused by placing CXF jars in $CATALINA_HOME/endoresed . This is the wrong location for placing jars that are common to all webapps. As explained at http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html in the "XML Parsers and Java" section.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM