You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@aries.apache.org by João Assunção <jo...@exploitsys.com> on 2019/09/26 16:50:52 UTC

Apache Aries JAX-RS Whiteboard > = 1.5.0 causes java.lang.ClassCastException

Hello all,
I recently upgraded to JAX-RS Whiteboard 1.6.0 (was using 1.1.0) and I'm
experiencing some  class loading issues related to CXF. One of the
components in my application exposes a CXF based web service that is now
failing with the following stack trace:

java.lang.ClassCastException: Cannot cast
org.apache.cxf.service.factory.FactoryBeanListenerManager to
org.apache.cxf.service.factory.FactoryBeanListenerManager
        at java.lang.Class.cast(Class.java:3369) ~[?:?]
        at
org.apache.cxf.bus.extension.ExtensionManagerImpl.getBeanOfType(ExtensionManagerImpl.java:317)
~[?:?]
        at
org.apache.cxf.bus.extension.ExtensionManagerBus.getExtension(ExtensionManagerBus.java:185)
~[?:?]
        at
org.apache.cxf.service.factory.AbstractServiceFactoryBean.setBus(AbstractServiceFactoryBean.java:98)
~[?:?]
        at
org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.initializeServiceFactory(AbstractWSDLBasedEndpointFactory.java:248)
~[?:?]
        at
org.apache.cxf.frontend.ServerFactoryBean.initializeServiceFactory(ServerFactoryBean.java:242)
~[?:?]
        at
org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
~[?:?]
        at
org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:168)
~[?:?]
        at
org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
~[?:?]

I think this is related to the change made in 1.5.0 where the JAX-RS
Whiteboard team changed the way CXF is embedded.
I'm using CXF 3.2.5 with Karaf 4.2.6

Regards,
João Assunção

Email: joao.assuncao@exploitsys.com
Mobile: +351 916968984
Phone: +351 211933149
Web: www.exploitsys.com

Re: Apache Aries JAX-RS Whiteboard > = 1.5.0 causes java.lang.ClassCastException

Posted by Carlos Sierra Andrés <cs...@gmail.com>.
Hi again,

> I think that is the case but I can't find the cause. To give you a
> better idea of the situation, we have a bundle (Bundle A) that
> launches a CXF server that will publish a SOAP WS at port 8085. We
> then have another bundle (Bundle B) providing a few REST endpoints
> that will be published by JAX RS whiteboard using the default Karaf
> Jetty server (port 8181). If the JAX RS whiteboard bundle is
> installed, when Bundle A starts it will fail with the
> ClassCastException. Bundle B doesn't use CXF and doesn't need to be
> installed for the issue to happen.
> As a workaround I reverted back to JAX-RS Whiteboard 1.4.0

I can't think of anything like this from the top of my head. Do you have
any shell (like gogo shell) in which you can trace where the packages
are being imported from? Maybe that would shed some light on why this is
happening.


> Out of topic. The decision to use the Aries DSL to register services
> results in cleaner code but makes stack traces longer and almost
> unreadable. Debugging is also harder. Do Aries contributors have any
> techniques to make it easier ? 
> Thank you for your time.
>
none that I can think of, I am afraid :-(

That's one of the drawbacks of heavy use of lambdas. I have been looking
into ways to improve on this, but with no luck so far. Any ideas are
welcome.

Thx.

> Regards,
> João Assunção
Carlos.

Re: Apache Aries JAX-RS Whiteboard > = 1.5.0 causes java.lang.ClassCastException

Posted by João Assunção <jo...@exploitsys.com>.
Hi Carlos,

I think that is the case but I can't find the cause. To give you a better
idea of the situation, we have a bundle (Bundle A) that launches a CXF
server that will publish a SOAP WS at port 8085. We then have another
bundle (Bundle B) providing a few REST endpoints that will be published by
JAX RS whiteboard using the default Karaf Jetty server (port 8181). If the
JAX RS whiteboard bundle is installed, when Bundle A starts it will fail
with the ClassCastException. Bundle B doesn't use CXF and doesn't need to
be installed for the issue to happen.
As a workaround I reverted back to JAX-RS Whiteboard 1.4.0

Out of topic. The decision to use the Aries DSL to register services
results in cleaner code but makes stack traces longer and almost
unreadable. Debugging is also harder. Do Aries contributors have any
techniques to make it easier ?
Thank you for your time.

Regards,
João Assunção

Email: joao.assuncao@exploitsys.com
Mobile: +351 916968984
Phone: +351 211933149
Web: www.exploitsys.com




On Fri, Sep 27, 2019 at 8:04 AM Carlos Sierra Andrés <cs...@gmail.com>
wrote:

> Hi there,
>
> is it possible that your application and the whiteboard are importing
> FactoryBeanListenerManager from different bundles?. In order to use CXF
> directly with the whiteboard you would need to export the packages from the
> whiteboard using a fragment and then import them from your bundles.
>
> Carlos.
> El 26/9/19 a las 18:50, João Assunção escribió:
>
> Hello all,
> I recently upgraded to JAX-RS Whiteboard 1.6.0 (was using 1.1.0) and I'm
> experiencing some  class loading issues related to CXF. One of the
> components in my application exposes a CXF based web service that is now
> failing with the following stack trace:
>
> java.lang.ClassCastException: Cannot cast
> org.apache.cxf.service.factory.FactoryBeanListenerManager to
> org.apache.cxf.service.factory.FactoryBeanListenerManager
>         at java.lang.Class.cast(Class.java:3369) ~[?:?]
>         at
> org.apache.cxf.bus.extension.ExtensionManagerImpl.getBeanOfType(ExtensionManagerImpl.java:317)
> ~[?:?]
>         at
> org.apache.cxf.bus.extension.ExtensionManagerBus.getExtension(ExtensionManagerBus.java:185)
> ~[?:?]
>         at
> org.apache.cxf.service.factory.AbstractServiceFactoryBean.setBus(AbstractServiceFactoryBean.java:98)
> ~[?:?]
>         at
> org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.initializeServiceFactory(AbstractWSDLBasedEndpointFactory.java:248)
> ~[?:?]
>         at
> org.apache.cxf.frontend.ServerFactoryBean.initializeServiceFactory(ServerFactoryBean.java:242)
> ~[?:?]
>         at
> org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
> ~[?:?]
>         at
> org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:168)
> ~[?:?]
>         at
> org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
> ~[?:?]
>
> I think this is related to the change made in 1.5.0 where the JAX-RS
> Whiteboard team changed the way CXF is embedded.
> I'm using CXF 3.2.5 with Karaf 4.2.6
>
> Regards,
> João Assunção
>
> Email: joao.assuncao@exploitsys.com
> Mobile: +351 916968984
> Phone: +351 211933149
> Web: www.exploitsys.com
>
>
>

Re: Apache Aries JAX-RS Whiteboard > = 1.5.0 causes java.lang.ClassCastException

Posted by Carlos Sierra Andrés <cs...@gmail.com>.
Hi there,

is it possible that your application and the whiteboard are importing
FactoryBeanListenerManager from different bundles?. In order to use CXF
directly with the whiteboard you would need to export the packages from
the whiteboard using a fragment and then import them from your bundles.

Carlos.

El 26/9/19 a las 18:50, João Assunção escribió:
> Hello all,
> I recently upgraded to JAX-RS Whiteboard 1.6.0 (was using 1.1.0) and
> I'm experiencing some  class loading issues related to CXF. One of the
> components in my application exposes a CXF based web service that is
> now failing with the following stack trace:
>
> java.lang.ClassCastException: Cannot cast
> org.apache.cxf.service.factory.FactoryBeanListenerManager to
> org.apache.cxf.service.factory.FactoryBeanListenerManager
>         at java.lang.Class.cast(Class.java:3369) ~[?:?]
>         at
> org.apache.cxf.bus.extension.ExtensionManagerImpl.getBeanOfType(ExtensionManagerImpl.java:317)
> ~[?:?]
>         at
> org.apache.cxf.bus.extension.ExtensionManagerBus.getExtension(ExtensionManagerBus.java:185)
> ~[?:?]
>         at
> org.apache.cxf.service.factory.AbstractServiceFactoryBean.setBus(AbstractServiceFactoryBean.java:98)
> ~[?:?]
>         at
> org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.initializeServiceFactory(AbstractWSDLBasedEndpointFactory.java:248)
> ~[?:?]
>         at
> org.apache.cxf.frontend.ServerFactoryBean.initializeServiceFactory(ServerFactoryBean.java:242)
> ~[?:?]
>         at
> org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
> ~[?:?]
>         at
> org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:168)
> ~[?:?]
>         at
> org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
> ~[?:?]
>
> I think this is related to the change made in 1.5.0 where the JAX-RS
> Whiteboard team changed the way CXF is embedded.
> I'm using CXF 3.2.5 with Karaf 4.2.6
>
> Regards,
> João Assunção
>
> Email: joao.assuncao@exploitsys.com <ma...@exploitsys.com>
> Mobile: +351 916968984
> Phone: +351 211933149
> Web: www.exploitsys.com <http://www.exploitsys.com>
>
>