Quantcast

NPE in cxf-core ClassLoaderUtils - possible bug?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

NPE in cxf-core ClassLoaderUtils - possible bug?

M. D.

 
 
   Hello group,
 

 
Please ignore my incompetence as I have never used CXF and neither do I have any knowledge about the product.
So there is a chance that this is a really stupid question.
 


 
In order to keep this inquiry short I will spare as much details as possible.
So here it is: I am trying to deploy parts of CXF 3.1.11 in our OSGi container.

So far I have the following Karaf features installed:

 cxf-core  cxf-jaxws  cxf-transports-jms  cxf-ws-mex  cxf-features-logging  cxf-ws-security  cxf-ws-rm

(I could be missing something but at least I have these deployed).

All resolves fine. During startup of the container however, I see this exception:  
Error registering CXF OSGi servlet null: java.lang.NullPointerException
  at org.apache.cxf.common.classloader.ClassLoaderUtils.getResource(ClassLoaderUtils.java:92)
  at org.apache.cxf.common.classloader.ClassLoaderUtils.getResourceAsStream(ClassLoaderUtils.java:227)
  at org.apache.cxf.transport.servlet.AbstractHTTPServlet.getResourceAsStream(AbstractHTTPServlet.java:150)
  at org.apache.cxf.transport.servlet.AbstractHTTPServlet.finalizeServletInit(AbstractHTTPServlet.java:128)
  at org.apache.cxf.transport.servlet.CXFNonSpringServlet.init(CXFNonSpringServlet.java:88)
  at org.apache.felix.http.base.internal.handler.ServletHandler.init(ServletHandler.java:55)   at org.apache.felix.http.base.internal.handler.HandlerRegistry.addServlet(HandlerRegistry.java:65)
  at org.apache.felix.http.base.internal.service.HttpServiceImpl.registerServlet(HttpServiceImpl.java:95)
  at org.apache.cxf.transport.http.osgi.ServletExporter.updated(ServletExporter.java:108)
  at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189)
  at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152)  at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)  at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1463)
  at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1419)  at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141)
  at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109)  at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_121]  
   The ClassLoaderUtils throws the NPE because the TCCL is not set (we are running in an OSGi container after all)  
We don't really use the CXF http transport but the jms one.
  However, seems the
cxf-rt-transports-http is a mandatory dependency of cxf-core so we have to deploy it anyway.  So is there a way to work around this issue? Or am I missing something obvious here (again, I apologize for my ignorance because I have zero exp with CXF but the fact is that our team need to have it deployed in the platform for reasons)?

Thank you in advance!

Best regards,
M.D

 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NPE in cxf-core ClassLoaderUtils - possible bug?

Andy McCright
Hi M.D.,

That looks like a bug to me.  The line from the NPE is:

        URL url =
Thread.currentThread().getContextClassLoader().getResource(resourceName);


Ordinarily, there is always a context classloader on the thread, but a null
value is allowed - it means that the JVM's boot classloader should be
used.  This code should be updated to something like:

        ClassLoader loader = Thread.currentThread.getContextClassLoader();

        if (loader == null) loader = ClassLoader.getSystemClassLoader();

        URL url = loader.getResource(resourceName);


I'll plan to provide a fix for CXF 3.1.12.


Thanks for reporting this,


Andy

On Thu, Apr 27, 2017 at 8:36 AM, M. D. <[hidden email]> wrote:

>
>
>
>    Hello group,
>
>
>
> Please ignore my incompetence as I have never used CXF and neither do I
> have any knowledge about the product.
> So there is a chance that this is a really stupid question.
>
>
>
>
> In order to keep this inquiry short I will spare as much details as
> possible.
> So here it is: I am trying to deploy parts of CXF 3.1.11 in our OSGi
> container.
>
> So far I have the following Karaf features installed:
>
>  cxf-core  cxf-jaxws  cxf-transports-jms  cxf-ws-mex
> cxf-features-logging  cxf-ws-security  cxf-ws-rm
>
> (I could be missing something but at least I have these deployed).
>
> All resolves fine. During startup of the container however, I see this
> exception:
> Error registering CXF OSGi servlet null: java.lang.NullPointerException
>   at org.apache.cxf.common.classloader.ClassLoaderUtils.
> getResource(ClassLoaderUtils.java:92)
>   at org.apache.cxf.common.classloader.ClassLoaderUtils.
> getResourceAsStream(ClassLoaderUtils.java:227)
>   at org.apache.cxf.transport.servlet.AbstractHTTPServlet.
> getResourceAsStream(AbstractHTTPServlet.java:150)
>   at org.apache.cxf.transport.servlet.AbstractHTTPServlet.
> finalizeServletInit(AbstractHTTPServlet.java:128)
>   at org.apache.cxf.transport.servlet.CXFNonSpringServlet.
> init(CXFNonSpringServlet.java:88)
>   at org.apache.felix.http.base.internal.handler.ServletHandler.init(ServletHandler.java:55)
>  at org.apache.felix.http.base.internal.handler.
> HandlerRegistry.addServlet(HandlerRegistry.java:65)
>   at org.apache.felix.http.base.internal.service.HttpServiceImpl.
> registerServlet(HttpServiceImpl.java:95)
>   at org.apache.cxf.transport.http.osgi.ServletExporter.updated(
> ServletExporter.java:108)
>   at org.apache.felix.cm.impl.helper.ManagedServiceTracker.
> updated(ManagedServiceTracker.java:189)
>   at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(
> ManagedServiceTracker.java:152)  at org.apache.felix.cm.impl.
> helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)
> at org.apache.felix.cm.impl.ConfigurationManager$
> ManagedServiceUpdate.provide(ConfigurationManager.java:1463)
>   at org.apache.felix.cm.impl.ConfigurationManager$
> ManagedServiceUpdate.run(ConfigurationManager.java:1419)  at
> org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141)
>   at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109)  at
> java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_121]
>    The ClassLoaderUtils throws the NPE because the TCCL is not set (we are
> running in an OSGi container after all)
> We don't really use the CXF http transport but the jms one.
>   However, seems the
> cxf-rt-transports-http is a mandatory dependency of cxf-core so we have to
> deploy it anyway.  So is there a way to work around this issue? Or am I
> missing something obvious here (again, I apologize for my ignorance because
> I have zero exp with CXF but the fact is that our team need to have it
> deployed in the platform for reasons)?
>
> Thank you in advance!
>
> Best regards,
> M.D
>
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NPE in cxf-core ClassLoaderUtils - possible bug?

M. D.
Hi Andy,

Thanks for the confirmation!

Could you please provide just a little clarification:
- What is the consequence of this bug? Apparently some servlet cannot be started... but what does this servlet do? Should we care about it if we plan not to use the http transport but the jms one?

Best regards,
Marin








 >-------- Оригинално писмо --------

 >От: Andy McCright [hidden email]

 >Относно: Re: NPE in cxf-core ClassLoaderUtils - possible bug?

 >До: [hidden email]

 >Изпратено на: 27.04.2017 17:20


Hi M.D.,



That looks like a bug to me.  The line from the NPE is:



        URL url =

Thread.currentThread().getContextClassLoader().getResource(resourceName);





Ordinarily, there is always a context classloader on the thread, but a null

value is allowed - it means that the JVM's boot classloader should be

used.  This code should be updated to something like:



        ClassLoader loader = Thread.currentThread.getContextClassLoader();



        if (loader == null) loader = ClassLoader.getSystemClassLoader();



        URL url = loader.getResource(resourceName);





I'll plan to provide a fix for CXF 3.1.12.





Thanks for reporting this,





Andy



On Thu, Apr 27, 2017 at 8:36 AM, M. D.  [hidden email] > wrote:



>

>

>

>    Hello group,

>

>

>

> Please ignore my incompetence as I have never used CXF and neither do I

> have any knowledge about the product.

> So there is a chance that this is a really stupid question.

>

>

>

>

> In order to keep this inquiry short I will spare as much details as

> possible.

> So here it is: I am trying to deploy parts of CXF 3.1.11 in our OSGi

> container.

>

> So far I have the following Karaf features installed:

>

>  cxf-core  cxf-jaxws  cxf-transports-jms  cxf-ws-mex

> cxf-features-logging  cxf-ws-security  cxf-ws-rm

>

> (I could be missing something but at least I have these deployed).

>

> All resolves fine. During startup of the container however, I see this

> exception:

> Error registering CXF OSGi servlet null: java.lang.NullPointerException

>   at org.apache.cxf.common.classloader.ClassLoaderUtils.

> getResource(ClassLoaderUtils.java:92)

>   at org.apache.cxf.common.classloader.ClassLoaderUtils.

> getResourceAsStream(ClassLoaderUtils.java:227)

>   at org.apache.cxf.transport.servlet.AbstractHTTPServlet.

> getResourceAsStream(AbstractHTTPServlet.java:150)

>   at org.apache.cxf.transport.servlet.AbstractHTTPServlet.

> finalizeServletInit(AbstractHTTPServlet.java:128)

>   at org.apache.cxf.transport.servlet.CXFNonSpringServlet.

> init(CXFNonSpringServlet.java:88)

>   at org.apache.felix.http.base.internal.handler.ServletHandler.init(ServletHandler.java:55)

>  at org.apache.felix.http.base.internal.handler.

> HandlerRegistry.addServlet(HandlerRegistry.java:65)

>   at org.apache.felix.http.base.internal.service.HttpServiceImpl.

> registerServlet(HttpServiceImpl.java:95)

>   at org.apache.cxf.transport.http.osgi.ServletExporter.updated(

> ServletExporter.java:108)

>   at org.apache.felix.cm.impl.helper.ManagedServiceTracker.

> updated(ManagedServiceTracker.java:189)

>   at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(

> ManagedServiceTracker.java:152)  at org.apache.felix.cm.impl.

> helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)

> at org.apache.felix.cm.impl.ConfigurationManager$

> ManagedServiceUpdate.provide(ConfigurationManager.java:1463)

>   at org.apache.felix.cm.impl.ConfigurationManager$

> ManagedServiceUpdate.run(ConfigurationManager.java:1419)  at

> org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141)

>   at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109)  at

> java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_121]

>    The ClassLoaderUtils throws the NPE because the TCCL is not set (we are

> running in an OSGi container after all)

> We don't really use the CXF http transport but the jms one.

>   However, seems the

> cxf-rt-transports-http is a mandatory dependency of cxf-core so we have to

> deploy it anyway.  So is there a way to work around this issue? Or am I

> missing something obvious here (again, I apologize for my ignorance because

> I have zero exp with CXF but the fact is that our team need to have it

> deployed in the platform for reasons)?

>

> Thank you in advance!

>

> Best regards,

> M.D

>

>

>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: NPE in cxf-core ClassLoaderUtils - possible bug?

Andy McCright
Hi Marin,

The servlet is what drives the REST requests.  It is failing while trying
to find a static resource file called "cxfServletStaticResourcesMap.txt".
This file is not required for CXF to work, but the NPE occurring while
looking for it breaks things.

If you are not using the HTTP transport, then this probably is not a real
problem.  I don't have much expertise in the JMS transport, but I would
assume that it can operate independent of this servlet.  If this really is
the case, then the NPE might just be noise (but still needs to be fixed).

Hope this helps,

Andy

On Fri, Apr 28, 2017 at 1:11 AM, M. D. <[hidden email]> wrote:

> Hi Andy,
>
> Thanks for the confirmation!
>
> Could you please provide just a little clarification:
> - What is the consequence of this bug? Apparently some servlet cannot be
> started... but what does this servlet do? Should we care about it if we
> plan not to use the http transport but the jms one?
>
> Best regards,
> Marin
>
>
>
>
>
>
>
>
>  >-------- Оригинално писмо --------
>
>  >От: Andy McCright [hidden email]
>
>  >Относно: Re: NPE in cxf-core ClassLoaderUtils - possible bug?
>
>  >До: [hidden email]
>
>  >Изпратено на: 27.04.2017 17:20
>
>
> Hi M.D.,
>
>
>
> That looks like a bug to me.  The line from the NPE is:
>
>
>
>         URL url =
>
> Thread.currentThread().getContextClassLoader().getResource(resourceName);
>
>
>
>
>
> Ordinarily, there is always a context classloader on the thread, but a null
>
> value is allowed - it means that the JVM's boot classloader should be
>
> used.  This code should be updated to something like:
>
>
>
>         ClassLoader loader = Thread.currentThread.getContextClassLoader();
>
>
>
>         if (loader == null) loader = ClassLoader.getSystemClassLoader();
>
>
>
>         URL url = loader.getResource(resourceName);
>
>
>
>
>
> I'll plan to provide a fix for CXF 3.1.12.
>
>
>
>
>
> Thanks for reporting this,
>
>
>
>
>
> Andy
>
>
>
> On Thu, Apr 27, 2017 at 8:36 AM, M. D.  [hidden email] > wrote:
>
>
>
> >
>
> >
>
> >
>
> >    Hello group,
>
> >
>
> >
>
> >
>
> > Please ignore my incompetence as I have never used CXF and neither do I
>
> > have any knowledge about the product.
>
> > So there is a chance that this is a really stupid question.
>
> >
>
> >
>
> >
>
> >
>
> > In order to keep this inquiry short I will spare as much details as
>
> > possible.
>
> > So here it is: I am trying to deploy parts of CXF 3.1.11 in our OSGi
>
> > container.
>
> >
>
> > So far I have the following Karaf features installed:
>
> >
>
> >  cxf-core  cxf-jaxws  cxf-transports-jms  cxf-ws-mex
>
> > cxf-features-logging  cxf-ws-security  cxf-ws-rm
>
> >
>
> > (I could be missing something but at least I have these deployed).
>
> >
>
> > All resolves fine. During startup of the container however, I see this
>
> > exception:
>
> > Error registering CXF OSGi servlet null: java.lang.NullPointerException
>
> >   at org.apache.cxf.common.classloader.ClassLoaderUtils.
>
> > getResource(ClassLoaderUtils.java:92)
>
> >   at org.apache.cxf.common.classloader.ClassLoaderUtils.
>
> > getResourceAsStream(ClassLoaderUtils.java:227)
>
> >   at org.apache.cxf.transport.servlet.AbstractHTTPServlet.
>
> > getResourceAsStream(AbstractHTTPServlet.java:150)
>
> >   at org.apache.cxf.transport.servlet.AbstractHTTPServlet.
>
> > finalizeServletInit(AbstractHTTPServlet.java:128)
>
> >   at org.apache.cxf.transport.servlet.CXFNonSpringServlet.
>
> > init(CXFNonSpringServlet.java:88)
>
> >   at org.apache.felix.http.base.internal.handler.ServletHandler.init(
> ServletHandler.java:55)
>
> >  at org.apache.felix.http.base.internal.handler.
>
> > HandlerRegistry.addServlet(HandlerRegistry.java:65)
>
> >   at org.apache.felix.http.base.internal.service.HttpServiceImpl.
>
> > registerServlet(HttpServiceImpl.java:95)
>
> >   at org.apache.cxf.transport.http.osgi.ServletExporter.updated(
>
> > ServletExporter.java:108)
>
> >   at org.apache.felix.cm.impl.helper.ManagedServiceTracker.
>
> > updated(ManagedServiceTracker.java:189)
>
> >   at org.apache.felix.cm.impl.helper.ManagedServiceTracker.
> updateService(
>
> > ManagedServiceTracker.java:152)  at org.apache.felix.cm.impl.
>
> > helper.ManagedServiceTracker.provideConfiguration(
> ManagedServiceTracker.java:85)
>
> > at org.apache.felix.cm.impl.ConfigurationManager$
>
> > ManagedServiceUpdate.provide(ConfigurationManager.java:1463)
>
> >   at org.apache.felix.cm.impl.ConfigurationManager$
>
> > ManagedServiceUpdate.run(ConfigurationManager.java:1419)  at
>
> > org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141)
>
> >   at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109)
> at
>
> > java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_121]
>
> >    The ClassLoaderUtils throws the NPE because the TCCL is not set (we
> are
>
> > running in an OSGi container after all)
>
> > We don't really use the CXF http transport but the jms one.
>
> >   However, seems the
>
> > cxf-rt-transports-http is a mandatory dependency of cxf-core so we have
> to
>
> > deploy it anyway.  So is there a way to work around this issue? Or am I
>
> > missing something obvious here (again, I apologize for my ignorance
> because
>
> > I have zero exp with CXF but the fact is that our team need to have it
>
> > deployed in the platform for reasons)?
>
> >
>
> > Thank you in advance!
>
> >
>
> > Best regards,
>
> > M.D
>
> >
>
> >
>
> >
>
>
Loading...