本文介绍了将camel-cxf升级到2.15.2后发生错误.类强制转换异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将驼峰骆驼cxf升级到2.15.2和cxf 3.0.4之后,启动骆驼路线时出现以下问题.

After upgrading to apache camel-cxf to 2.15.2 and cxf 3.0.4 I have the following problem when starting up my camel routes.

该路线与Payment Gateway进行了肥皂整合.

The route does a soap integration with a Payment Gateway.

有没有人找到解决方法?

Has any body found a workaround for this?

请参阅下面的堆栈跟踪.

Please see stack trace below.

Caused by: org.apache.camel.FailedToCreateProducerException: Failed to create Producer for endpoint:

端点[cxf:// https://staging.payu.co.za/service/PayUAPI?dataFormat=PAYLOAD&portName=%7Bhttp%3A%2F%2Fsoap.api.controller.web. payjar.com%2F%7DEnterpriseAPISoapPort& serviceName =%7Bhttp%3A%2F%2Fsoap.api.controller.web.payjar.com%2F%7DEnterpriseAPISoapService& wsdlURL = https%3A%2F%2Fstaging.payu.co.za%2Fservice %2FPayUAPI%3Fwsdl] . 原因:org.apache.camel.RuntimeCamelException: java.lang.ClassCastException:无法转换 org.apache.cxf.wsdl11.WSDLManagerImpl转换为 org.apache.cxf.wsdl.WSDLManager位于 org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:407) 在 org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:123) 在 org.apache.camel.processor.SendProcessor.doStart(SendProcessor.java:219) 在 org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) 在 org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74) 在 org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59) 在 org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103) 在 org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89) 在 org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:79) 在 org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) 在 org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74) 在 org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59) 在 org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103) 在 org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89) 在 org.apache.camel.processor.RedeliveryErrorHandler.doStart(RedeliveryErrorHandler.java:1272) 在 org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:44) 在 org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:31) 在 org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74) 在 org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59) 在 org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103) 在 org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89) 在 org.apache.camel.processor.interceptor.DefaultChannel.doStart(DefaultChannel.java:155) 在 org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) 在 org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74) 在 org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59) 在 org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103) 在 org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:61) 在 org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103) 在 org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89) 在 org.apache.camel.processor.MulticastProcessor.doStart(MulticastProcessor.java:1122) 在 org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) 在 org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74) 在 org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59) 在 org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103) 在 org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89) 在 org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:79) 在 org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) 在 org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74) 在 org.apache.camel.impl.RouteService.startChildService(RouteService.java:340) 在org.apache.camel.impl.RouteService.warmUp(RouteService.java:182) 在 org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:3090) 在 org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3020) 在 org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:2797) 在 org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:2653) 在 org.apache.camel.impl.DefaultCamelContext.access $ 000(DefaultCamelContext.java:167) 在 org.apache.camel.impl.DefaultCamelContext $ 2.call(DefaultCamelContext.java:2467) 在 org.apache.camel.impl.DefaultCamelContext $ 2.call(DefaultCamelContext.java:2463) 在 org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2486) 在 org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2463) 在 org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) 在 org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2432) 在 com.unijunction.ordercloud.common.bootstrap.CamelInstantiator.init(CamelInstantiator.java:58) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:606)在 org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptor.java:96) 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 在 org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doLifecycleInterception(Jsr299BindingsInterceptor.java:114) 在 org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:103) 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 在 org.jboss.invocation.InterceptorContext $ Invocation.proceed(InterceptorContext.java:437) 在 org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:73) 在 org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:83) 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 在 org.jboss.as.weld.injection.WeldInjectionInterceptor.processInvocation(WeldInjectionInterceptor.java:53) 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 在 org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory $ ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:107) 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 在 org.jboss.as.ee.component.AroundConstructInterceptorFactory $ 1.processInvocation(AroundConstructInterceptorFactory.java:28) 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 在 org.jboss.as.weld.injection.WeldInterceptorInjectionInterceptor.processInvocation(WeldInterceptorInjectionInterceptor.java:56) 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 在 org.jboss.as.weld.ejb.Jsr299BindingsCreateInterceptor.processInvocation(Jsr299BindingsCreateInterceptor.java:100) 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 在 org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) 在 org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) 在 org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275) ...另外27个

Endpoint[cxf://https://staging.payu.co.za/service/PayUAPI?dataFormat=PAYLOAD&portName=%7Bhttp%3A%2F%2Fsoap.api.controller.web.payjar.com%2F%7DEnterpriseAPISoapPort&serviceName=%7Bhttp%3A%2F%2Fsoap.api.controller.web.payjar.com%2F%7DEnterpriseAPISoapService&wsdlURL=https%3A%2F%2Fstaging.payu.co.za%2Fservice%2FPayUAPI%3Fwsdl]. Reason: org.apache.camel.RuntimeCamelException: java.lang.ClassCastException: Cannot cast org.apache.cxf.wsdl11.WSDLManagerImpl to org.apache.cxf.wsdl.WSDLManager at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:407) at org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:123) at org.apache.camel.processor.SendProcessor.doStart(SendProcessor.java:219) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59) at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103) at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89) at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:79) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59) at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103) at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89) at org.apache.camel.processor.RedeliveryErrorHandler.doStart(RedeliveryErrorHandler.java:1272) at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:44) at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:31) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59) at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103) at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89) at org.apache.camel.processor.interceptor.DefaultChannel.doStart(DefaultChannel.java:155) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59) at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:61) at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103) at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89) at org.apache.camel.processor.MulticastProcessor.doStart(MulticastProcessor.java:1122) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:59) at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:103) at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:89) at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:79) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:74) at org.apache.camel.impl.RouteService.startChildService(RouteService.java:340) at org.apache.camel.impl.RouteService.warmUp(RouteService.java:182) at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:3090) at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3020) at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:2797) at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:2653) at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:167) at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2467) at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2463) at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2486) at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2463) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2432) at com.unijunction.ordercloud.common.bootstrap.CamelInstantiator.init(CamelInstantiator.java:58) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptor.java:96) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doLifecycleInterception(Jsr299BindingsInterceptor.java:114) at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:103) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:437) at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:73) at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:83) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.weld.injection.WeldInjectionInterceptor.processInvocation(WeldInjectionInterceptor.java:53) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:107) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.ee.component.AroundConstructInterceptorFactory$1.processInvocation(AroundConstructInterceptorFactory.java:28) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.weld.injection.WeldInterceptorInjectionInterceptor.processInvocation(WeldInterceptorInjectionInterceptor.java:56) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.weld.ejb.Jsr299BindingsCreateInterceptor.processInvocation(Jsr299BindingsCreateInterceptor.java:100) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275) ... 27 more

Caused by: org.apache.camel.RuntimeCamelException: java.lang.ClassCastException: Cannot cast

org.apache.cxf.wsdl11.WSDLManagerImpl更改为 org.apache.cxf.wsdl.WSDLManager位于 org.apache.camel.component.cxf.WSDLServiceFactoryBean.getDefinition(WSDLServiceFactoryBean.java:66) 在 org.apache.camel.component.cxf.WSDLServiceFactoryBean.buildServiceFromWSDL(WSDLServiceFactoryBean.java:101) 在 org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:525) 在 org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:261) 在 org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:215) 在 org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102) 在 org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91) 在 org.apache.camel.component.cxf.CxfEndpoint.createClient(CxfEndpoint.java:634) 在 org.apache.camel.component.cxf.CxfProducer.doStart(CxfProducer.java:76) 在 org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) 在 org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:2869) 在 org.apache.camel.impl.DefaultCamelContext.doAddService(DefaultCamelContext.java:1097) 在 org.apache.camel.impl.DefaultCamelContext.addService(DefaultCamelContext.java:1058) 在 org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:405) ...还有104个

org.apache.cxf.wsdl11.WSDLManagerImpl to org.apache.cxf.wsdl.WSDLManager at org.apache.camel.component.cxf.WSDLServiceFactoryBean.getDefinition(WSDLServiceFactoryBean.java:66) at org.apache.camel.component.cxf.WSDLServiceFactoryBean.buildServiceFromWSDL(WSDLServiceFactoryBean.java:101) at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:525) at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:261) at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:215) at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102) at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91) at org.apache.camel.component.cxf.CxfEndpoint.createClient(CxfEndpoint.java:634) at org.apache.camel.component.cxf.CxfProducer.doStart(CxfProducer.java:76) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:2869) at org.apache.camel.impl.DefaultCamelContext.doAddService(DefaultCamelContext.java:1097) at org.apache.camel.impl.DefaultCamelContext.addService(DefaultCamelContext.java:1058) at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:405) ... 104 more

Caused by: java.lang.ClassCastException: Cannot cast org.apache.cxf.wsdl11.WSDLManagerImpl to

org.apache.cxf.wsdl.WSDLManager位于 java.lang.Class.cast(Class.java:3186)在 org.apache.cxf.bus.extension.ExtensionManagerImpl.getBeanOfType(ExtensionManagerImpl.java:322) 在 org.apache.cxf.bus.extension.ExtensionManagerBus.getExtension(ExtensionManagerBus.java:216) 在 org.apache.camel.component.cxf.WSDLServiceFactoryBean.getDefinition(WSDLServiceFactoryBean.java:64) ...还有117

org.apache.cxf.wsdl.WSDLManager at java.lang.Class.cast(Class.java:3186) at org.apache.cxf.bus.extension.ExtensionManagerImpl.getBeanOfType(ExtensionManagerImpl.java:322) at org.apache.cxf.bus.extension.ExtensionManagerBus.getExtension(ExtensionManagerBus.java:216) at org.apache.camel.component.cxf.WSDLServiceFactoryBean.getDefinition(WSDLServiceFactoryBean.java:64) ... 117 more

推荐答案

骆驼和cfx常见的问题:

Common problems found with camel and cfx:

  • 带阴影的jar文件上的camel/cfx的重复版本,因为我发现了cxf的问题-3.0.12和3.1.10.
  • 骆驼TypeConverter上的问题.

解决方案:

  • Maven依赖项,apache cxf版本2.7.18和apache camel版本2.17.2.

cxf捆绑包

骆驼核

camel-cxf

camel-cxf

  • 将此内容包含在阴影的maven pom中,

  • Include this in the shaded maven pom,

            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                <resource>META-INF/services/org/apache/camel/TypeConverter</resource>
            </transformer>

这篇关于将camel-cxf升级到2.15.2后发生错误.类强制转换异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 23:14