Just to close the loop on this (and in case anyone finds it on google), the problem was that CXF 2.4.0 handles the contextClassLoader differently than 2.3.2.I had to set the thread's contextClassLoader before creating the client. I just added beforehand:
Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); Best, Kevin ________________________________ From: Freeman Fang <[email protected]> To: [email protected] Sent: Tuesday, May 10, 2011 7:53 PM Subject: Re: Upgrade to 2.4, NullPointerException Hi, I see exactly same error when I do upgrade to cxf 2.4.0 in servicemix, for me the error is caused by Bus refactor in 2.4.0, if you have explicitly init a bus like <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl">, you should remove it and use <cxf:bus> instead. Freeman On 2011-5-11, at 上午10:19, Kevin McClusky wrote: > Hi, > I upgraded from 2.3.2 to 2.4, and I'm getting a NullPointerException when >I try to create a dynamic client. > > Code: > > DynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); > Client client = dcf.createClient(wsdlUrl, service, > DynamicClientFactory.class.getClassLoader(), port); > > stacktrace: > > java.lang.NullPointerException > at >org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:67) > at >org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:84) > at org.apache.cxf.endpoint.ClientImpl.<init>(ClientImpl.java:152) > at >org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:255) > at >org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:198) > at >org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:191) > > > Line 67 in WSDLServiceFactory is: > definition = >getBus().getExtension(WSDLManager.class).getDefinition(wsdlUrl); > > I tested, and getBus().getExtension(WSDLManager.class) is returning null. > > > What's the proper way to make sure the bus has the extension manager / is > properly initialized? With 2.3.2, I didn't need to worry about it, but it > looks like I do with 2.4.0. > > > > A little more information: I'm including my code in an application that has a > somewhat complex class loader hierarchy. It worked as-is with 2.3.2. The > class loader used to load the CXF jars should be this class's classloader's > parent. > > Also, if I just write a POJO with a main method, and thow this in, it *does > not* give me the NPE; the NPE only comes from inside the full application: > > DynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); > Bus bus = CXFBusFactory.getThreadDefaultBus(); > WSDLManager extension = bus.getExtension(WSDLManager.class); > > Thank you, > Kevin --------------------------------------------- Freeman Fang FuseSource Email:[email protected] Web: fusesource.com Twitter: freemanfang Blog: http://freemanfang.blogspot.com Connect at CamelOne May 24-26 The Open Source Integration Conference
