I see, I just missed the whole discussion about about classloaders on the dev list :-)
On Wed, May 11, 2011 at 3:56 PM, Sergey Beryozkin <[email protected]> wrote: > Hi > > Should we have a handler there in case of 'null' ? Default it to something ? > So that users don't have to start changing the client code ? > > Sergey > > On Wed, May 11, 2011 at 3:49 PM, Willem Jiang <[email protected]> wrote: >> Hi, >> >> You may consider to set the TCCL like this >> >> ClassLoader old = Thread.currentThread().getContextClassLoader(); >> try { >> >> Thread.currentThread().setContextClassloader(YourApplicationClassLoader); >> JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); >> this.client = dcf.createClient(new URL(wsdlUrl)); >> } finally { >> Thread.currentThread().setContextClassLoader(old); >> } >> >> On 5/11/11 10:36 PM, Martin Thurau wrote: >>> >>> Hello everyone >>> >>> I have code, which calls SOAP services using the dynamic client >>> feature of Apache CXF. The code basically looks like this: >>> >>> JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); >>> this.client = dcf.createClient(new URL(wsdlUrl)); >>> >>> The Exception is thrown within createClient, but only under certain >>> circumstances. If I run the code within a simple test app everything >>> runs fine. However, if I move my code to the actual context, as a >>> plugin within another software, the Exception occurs. The other >>> software is "Kettle", a tool of the Pentaho BI Suite. I suspect, that >>> this is because Kettle installs an own classloader in the thread >>> context and the CXF code that gets executed is somehow incompatible >>> with this specific classloader. >>> >>> Does anyone has a had similar problems when embedding CXF into another >>> application? What further actions are recommended? >>> >>> -- >>> >>> I have debugged the NullPointerException within Kettle and have the >>> exact position where the fault occurs. However, I have no clue *what* >>> the code inquestion is doing, why it is doing this and what would be a >>> correct behaviour. >>> >>> The NullPointerException is thrown at >>> org.apache.cxf.wsdl11.WSDLServiceFactory within the constructor >>> "public WSDLServiceFactory(Bus b, URL url)" at line 67. This line >>> looks like this: >>> >>> definition = >>> getBus().getExtension(WSDLManager.class).getDefinition(wsdlUrl); >>> >>> The NullPointerException occures, because the getExtension method >>> returns null. At run time, the getBus() method returns an instance of >>> org.apache.cxf.bus.CXFBusImpl. Its complete getExtension in this class >>> looks like: >>> >>> public final<T> T getExtension(Class<T> extensionType) { >>> Object obj = extensions.get(extensionType); >>> if (obj == null) { >>> ConfiguredBeanLocator loc = >>> (ConfiguredBeanLocator)extensions.get(ConfiguredBeanLocator.class); >>> if (loc == null) { >>> loc = createConfiguredBeanLocator(); >>> } >>> if (loc != null) { >>> //force loading >>> Collection<?> objs = loc.getBeansOfType(extensionType); >>> if (objs != null) { >>> for (Object o : objs) { >>> extensions.put(extensionType, o); >>> } >>> } >>> obj = extensions.get(extensionType); >>> } >>> } >>> if (null != obj) { >>> return extensionType.cast(obj); >>> } >>> return null; >>> } >>> >>> As you can see, there is a code path that may return null. A case in >>> which the code at org.apache.cxf.wsdl11.WSDLServiceFactory *will* >>> fail. In my understanding this is a bug. Am I seeing this right? >>> >>> Regards >>> Martin Thurau >>> >> >> >> -- >> Willem >> ---------------------------------- >> FuseSource >> Web: http://www.fusesource.com >> Blog: http://willemjiang.blogspot.com (English) >> http://jnn.javaeye.com (Chinese) >> Twitter: willemjiang >> >> Connect at CamelOne May 24-26 >> The Open Source Integration Conference >> http://camelone.com >> > > > > -- > Sergey Beryozkin > > Application Integration Division of Talend > http://sberyozkin.blogspot.com > -- Sergey Beryozkin Application Integration Division of Talend http://sberyozkin.blogspot.com
