Hi I am trying to expose a camel cxf soap ws using camel spring boot.
while running the camel spring application i am getting the error Caused by: java.lang.NoClassDefFoundError: org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.
Any help appreciated.
Below is the configurations:
Pom XML:
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.mycompany</groupId>
<artifactId>camel-ose-springboot-xml</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Fabric8 :: Quickstarts :: Spring-Boot :: Camel XML</name>
<description>Spring Boot example running a Camel route defined in XML</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- dependency versions -->
<fabric8.version>2.3.7</fabric8.version>
<spring-boot.version>1.5.4.RELEASE</spring-boot.version>
<fuse.version>7.1.0.fuse-710019-redhat-00002</fuse.version>
<!-- maven plugin versions -->
<fabric8.maven.plugin.version>3.5.34</fabric8.maven.plugin.version>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
</properties>
<dependencyManagement>
<dependencies>
<!--<dependency> <groupId>io.fabric8</groupId> <artifactId>fabric8-project-bom-camel-spring-boot</artifactId>
<version>${fabric8.version}</version> <type>pom</type> <scope>import</scope>
</dependency> -->
<dependency>
<groupId>org.jboss.redhat-fuse</groupId>
<artifactId>fuse-springboot-bom</artifactId>
<version>${fuse.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf-starter</artifactId>
</dependency>
<!--<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-cxf</artifactId>
<version>2.18.0</version> </dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>spring-boot:run</defaultGoal>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>org.mycompany.Application</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- <plugin> <groupId>io.fabric8</groupId> <artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric8.maven.plugin.version}</version> <executions> <execution>
<goals> <goal>resource</goal> <goal>build</goal> </goals> </execution> </executions>
</plugin> -->
</plugins>
</build>
</project>
Route XML:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<import resource="endpoints.xml"/>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route handleFault="true" id="NotificationRoute" streamCache="true">
<from id="NotificationEndpoint" uri="cxf:bean:NotificationService"/>
<log id="route-log" message=">>> ${body}"/>
</route>
</camelContext>
</beans>
Endpoint xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xmlns:http="http://cxf.apache.org/transports/http/configuration"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:prop="http://camel.apache.org/schema/placeholder"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<cxf:cxfEndpoint
address="http://localhost:8088/eu/deferred/NotificationService"
endpointName="nms:ICalculator" id="NotificationService"
serviceName="nms:CalculatorService"
wsdlURL="wsdl/notification/calculator.wsdl" xmlns:nms="http://Example.org">
<cxf:properties>
<entry key="dataFormat" value="PAYLOAD"/>
</cxf:properties>
<cxf:inInterceptors>
<ref bean="wss4jInInterceptor"/>
<!-- <ref bean="authenticationInterceptor"/>
<ref bean="authorizationInterceptor"/> -->
</cxf:inInterceptors>
</cxf:cxfEndpoint>
</beans>
Java Class:
package org.mycompany;
import java.util.Arrays;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
/**
* A spring-boot application that includes a Camel route builder to setup the Camel routes
*/
@SpringBootApplication
@ImportResource({"classpath:spring/camel-context.xml","classpath:spring/endpoints.xml"})
public class Application {
// must have a main method spring-boot can run
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Error logs:
17:30:04.825 [main] INFO o.e.j.server.handler.ContextHandler - Stopped o.s.b.c.e.j.JettyEmbeddedWebAppContext@5583098b{/,[file:///C:/Users/jmjl29k/AppData/Local/Temp/jetty-docbase.4312198013866550633.8080/],UNAVAILABLE}
17:30:04.855 [main] INFO o.s.b.a.l.AutoConfigurationReportLoggingInitializer -
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
17:30:04.872 [main] ERROR o.s.boot.SpringApplication - Application startup failed
org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route NotificationRoute: Route(NotificationRoute)[[From[cxf:bean:NotificationService]... because of Failed to resolve endpoint: cxf://bean:NotificationService due to: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NotificationService': Failed to introspect bean class [org.apache.camel.component.cxf.CxfSpringEndpoint] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1830)
at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:136)
at org.apache.camel.spring.CamelContextFactoryBean.start(CamelContextFactoryBean.java:369)
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:416)
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:94)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at org.mycompany.Application.main(Application.java:36)
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route NotificationRoute: Route(NotificationRoute)[[From[cxf:bean:NotificationService]... because of Failed to resolve endpoint: cxf://bean:NotificationService due to: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NotificationService': Failed to introspect bean class [org.apache.camel.component.cxf.CxfSpringEndpoint] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:209)
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:1143)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3729)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3443)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:209)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3251)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3247)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3270)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3247)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3163)
at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:133)
... 18 common frames omitted
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: cxf://bean:NotificationService due to: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NotificationService': Failed to introspect bean class [org.apache.camel.component.cxf.CxfSpringEndpoint] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:758)
at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:80)
at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:219)
at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:115)
at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:121)
at org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:69)
at org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:97)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1283)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:204)
... 29 common frames omitted
Caused by: org.apache.camel.RuntimeCamelException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NotificationService': Failed to introspect bean class [org.apache.camel.component.cxf.CxfSpringEndpoint] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1830)
at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookupByNameAndType(PropertyPlaceholderDelegateRegistry.java:65)
at org.apache.camel.util.CamelContextHelper.lookup(CamelContextHelper.java:146)
at org.apache.camel.util.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:187)
at org.apache.camel.component.cxf.CxfComponent.createCxfSpringEndpoint(CxfComponent.java:144)
at org.apache.camel.component.cxf.CxfComponent.createEndpoint(CxfComponent.java:107)
at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:126)
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:711)
... 37 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NotificationService': Failed to introspect bean class [org.apache.camel.component.cxf.CxfSpringEndpoint] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:269)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1126)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:331)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1086)
at org.apache.camel.spring.spi.ApplicationContextRegistry.lookupByNameAndType(ApplicationContextRegistry.java:47)
at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookupByNameAndType(PropertyPlaceholderDelegateRegistry.java:63)
... 43 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:247)
... 52 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 59 common frames omitted
17:30:04.875 [main] INFO o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@d83da2e: startup date [Tue Sep 25 17:29:33 CEST 2018]; root of context hierarchy
17:30:04.997 [main] INFO o.s.c.s.DefaultLifecycleProcessor - Stopping beans in phase 2147483646
17:30:04.998 [main] INFO o.s.j.e.a.AnnotationMBeanExporter - Unregistering JMX-exposed beans on shutdown
Fuse does not support
spring-boot-starter-jetty
, so replace it withspring-boot-starter-undertow
(also remove the<version>
tag for this dependency).Similar for
cxf-rt-transports-http-jetty
, change it tocxf-rt-transports-http-undertow
. You'll need to set the version for this dependency to3.1.11.fuse-710022-redhat-00001
, as for some reason it's not in the Fuse BOM.Finally for the
spring-boot-maven-plugin
, you can change the groupId / version to this:That was enough for me to run your sample project and browse the endpoint WSDL.