Problem running Spring Boot app with CXF

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem running Spring Boot app with CXF

Felipe Jaekel
Hi,

I have a Spring Boot (2.2.1) app that uses CXF for SOAP contract last web
services. It works fine with Tomcat (9.0.24), but when I try to run it on
TomEE (7.0.5, 8.0.0), I get the following exception:

Caused by: java.lang.ClassCastException: Cannot cast
org.apache.cxf.management.jmx.InstrumentationManagerImpl to
org.apache.cxf.management.InstrumentationManager at
java.lang.Class.cast(Class.java:3369) at
org.apache.cxf.bus.extension.ExtensionManagerImpl.getBeanOfType(ExtensionManagerImpl.java:307)
at
org.apache.cxf.bus.spring.SpringBeanLocator.getBeanOfType(SpringBeanLocator.java:128)
at
org.apache.cxf.bus.extension.ExtensionManagerBus.getExtension(ExtensionManagerBus.java:181)
at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:104)
at org.apache.cxf.endpoint.ServerImpl.(ServerImpl.java:64) at
org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:182)
at
org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:460) at
org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:338) ... 62
more

Sample project: https://github.com/iancesar/webservice

Any ideias?
Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Problem running Spring Boot app with CXF

Andy McCright
Hi Felipe,

I'm not a TomEE guy - or even much of a JAX-WS guy, so take my advice with
a grain of salt...

I have seen problems like that in WebSphere and OpenLiberty - and that
usually happens when the application archive(s) package the same jars as
the runtime.  For example, I know that TomEE packages some CXF modules (as
WebSphere and Liberty does) - and so if a user packaged those same CXF
module jars in their application, then it is likely that they would see
these ClassCastExceptions since the classes are loaded from different class
loaders.

I would start by checking your application archives (WARs/EARs/etc.) to see
if it packages CXF.  If so, you may need to use the <scope>provided<scope>
line in your pom.xml to avoid pulling in CXF jars.  Then you would use the
CXF modules that are provided by TomEE - and there should no longer be any
conflict.

Hope this helps,

Andy

On Wed, Nov 27, 2019 at 12:57 PM Felipe Jaekel <[hidden email]> wrote:

> Hi,
>
> I have a Spring Boot (2.2.1) app that uses CXF for SOAP contract last web
> services. It works fine with Tomcat (9.0.24), but when I try to run it on
> TomEE (7.0.5, 8.0.0), I get the following exception:
>
> Caused by: java.lang.ClassCastException: Cannot cast
> org.apache.cxf.management.jmx.InstrumentationManagerImpl to
> org.apache.cxf.management.InstrumentationManager at
> java.lang.Class.cast(Class.java:3369) at
>
> org.apache.cxf.bus.extension.ExtensionManagerImpl.getBeanOfType(ExtensionManagerImpl.java:307)
> at
>
> org.apache.cxf.bus.spring.SpringBeanLocator.getBeanOfType(SpringBeanLocator.java:128)
> at
>
> org.apache.cxf.bus.extension.ExtensionManagerBus.getExtension(ExtensionManagerBus.java:181)
> at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:104)
> at org.apache.cxf.endpoint.ServerImpl.(ServerImpl.java:64) at
>
> org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:182)
> at
>
> org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
> at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:460) at
> org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:338) ... 62
> more
>
> Sample project: https://github.com/iancesar/webservice
>
> Any ideias?
> Thanks
>
Reply | Threaded
Open this post in threaded view
|

Re: Problem running Spring Boot app with CXF

Ian Cesar Vidinha Rego
Hi Andy,
Thanks for your suggestion, i work with Felipe and we tried this approach,
unfortunately it didn't work. Others problemas relationated with Spring had
occurred. We decided to deploy Spring Boot applications only on Tomcat.

Thanks
Ian César

Em qua., 27 de nov. de 2019 às 18:56, Andy McCright <
[hidden email]> escreveu:

> Hi Felipe,
>
> I'm not a TomEE guy - or even much of a JAX-WS guy, so take my advice with
> a grain of salt...
>
> I have seen problems like that in WebSphere and OpenLiberty - and that
> usually happens when the application archive(s) package the same jars as
> the runtime.  For example, I know that TomEE packages some CXF modules (as
> WebSphere and Liberty does) - and so if a user packaged those same CXF
> module jars in their application, then it is likely that they would see
> these ClassCastExceptions since the classes are loaded from different class
> loaders.
>
> I would start by checking your application archives (WARs/EARs/etc.) to see
> if it packages CXF.  If so, you may need to use the <scope>provided<scope>
> line in your pom.xml to avoid pulling in CXF jars.  Then you would use the
> CXF modules that are provided by TomEE - and there should no longer be any
> conflict.
>
> Hope this helps,
>
> Andy
>
> On Wed, Nov 27, 2019 at 12:57 PM Felipe Jaekel <[hidden email]> wrote:
>
> > Hi,
> >
> > I have a Spring Boot (2.2.1) app that uses CXF for SOAP contract last web
> > services. It works fine with Tomcat (9.0.24), but when I try to run it on
> > TomEE (7.0.5, 8.0.0), I get the following exception:
> >
> > Caused by: java.lang.ClassCastException: Cannot cast
> > org.apache.cxf.management.jmx.InstrumentationManagerImpl to
> > org.apache.cxf.management.InstrumentationManager at
> > java.lang.Class.cast(Class.java:3369) at
> >
> >
> org.apache.cxf.bus.extension.ExtensionManagerImpl.getBeanOfType(ExtensionManagerImpl.java:307)
> > at
> >
> >
> org.apache.cxf.bus.spring.SpringBeanLocator.getBeanOfType(SpringBeanLocator.java:128)
> > at
> >
> >
> org.apache.cxf.bus.extension.ExtensionManagerBus.getExtension(ExtensionManagerBus.java:181)
> > at
> org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:104)
> > at org.apache.cxf.endpoint.ServerImpl.(ServerImpl.java:64) at
> >
> >
> org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:182)
> > at
> >
> >
> org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
> > at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:460) at
> > org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:338) ... 62
> > more
> >
> > Sample project: https://github.com/iancesar/webservice
> >
> > Any ideias?
> > Thanks
> >
>