英文:
Unable to start Springboot 2.3.3 with apache camel 3.4.3 and Swagger
问题
我正在尝试从Camel 2.x迁移到3.x。
目标是创建一个带有Swagger文档的API。我可以运行应用程序,但是一旦我添加了Swagger配置,就会出现以下错误:
2020-08-24 16:04:27.174 INFO 21736 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-08-24 16:04:27.176 INFO 21736 --- [ restartedMain] o.a.c.c.s.CamelHttpTransportServlet : Destroyed CamelHttpTransportServlet[CamelServlet]
2020-08-24 16:04:27.195 INFO 21736 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-08-24 16:04:27.211 ERROR 21736 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.apache.camel.FailedToStartRouteException: Failed to start route doc-api because of null
at org.apache.camel.impl.engine.RouteService.warmUp(RouteService.java:125) ~[camel-base-3.4.3.jar:3.4.3]
...
Caused by: org.apache.camel.RuntimeCamelException: java.lang.IllegalStateException: Cannot find RestApiProcessorFactory in Registry or classpath (such as the camel-openapi-java component)
at org.apache.camel.component.rest.RestApiEndpoint.createProducer(RestApiEndpoint.java:207) ~[camel-rest-3.4.3.jar:3.4.3]
...
我的pom.xml如下:
<!-- 代码略 -->
和我的rest配置如下:
<!-- 代码略 -->
请注意,我已经将原始代码片段中的关键部分进行了翻译,并删除了非必要的细节。如果您有更多需要帮助的问题,请随时提问。
英文:
I'm trying to migrate from camel 2.x to 3.x.
The goal is to create an API with Swagger documentation. I can run the application, but as soon as I add the swagger configuration I get this error:
2020-08-24 16:04:27.174 INFO 21736 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-08-24 16:04:27.176 INFO 21736 --- [ restartedMain] o.a.c.c.s.CamelHttpTransportServlet : Destroyed CamelHttpTransportServlet[CamelServlet]
2020-08-24 16:04:27.195 INFO 21736 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-08-24 16:04:27.211 ERROR 21736 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.apache.camel.FailedToStartRouteException: Failed to start route doc-api because of null
at org.apache.camel.impl.engine.RouteService.warmUp(RouteService.java:125) ~[camel-base-3.4.3.jar:3.4.3]
at org.apache.camel.impl.engine.InternalRouteStartupManager.doWarmUpRoutes(InternalRouteStartupManager.java:263) ~[camel-base-3.4.3.jar:3.4.3]
at org.apache.camel.impl.engine.InternalRouteStartupManager.safelyStartRouteServices(InternalRouteStartupManager.java:156) ~[camel-base-3.4.3.ja
r:3.4.3]
at org.apache.camel.impl.engine.InternalRouteStartupManager.doStartOrResumeRoutes(InternalRouteStartupManager.java:114) ~[camel-base-3.4.3.jar:3
.4.3]
at org.apache.camel.impl.engine.AbstractCamelContext.doStartCamel(AbstractCamelContext.java:2809) ~[camel-base-3.4.3.jar:3.4.3]
at org.apache.camel.impl.engine.AbstractCamelContext.doStartContext(AbstractCamelContext.java:2657) ~[camel-base-3.4.3.jar:3.4.3]
at org.apache.camel.impl.engine.AbstractCamelContext.doStart(AbstractCamelContext.java:2620) ~[camel-base-3.4.3.jar:3.4.3]
at org.apache.camel.spring.boot.SpringBootCamelContext.doStart(SpringBootCamelContext.java:43) ~[camel-spring-boot-3.4.3.jar:3.4.3]
at org.apache.camel.support.service.BaseService.start(BaseService.java:115) ~[camel-api-3.4.3.jar:3.4.3]
at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2452) ~[camel-base-3.4.3.jar:3.4.3]
at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:121) ~[camel-spring-3.4.3.jar:3.4.3]
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:157) ~[camel-spring-3.4.3.jar:3.4.3]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-con
text-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-conte
xt-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-conte
xt-5.2.8.RELEASE.jar:5.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404) ~[spring-context-5.2.8.RELEA
SE.jar:5.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361) ~[spring-context-5.2.8.RELEA
SE.jar:5.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:898) ~[spring-context-5.2.8.RELE
ASE.jar:5.2.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554) ~[spring-context-5.2.8.RELEASE.ja
r:5.2.8.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring
-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at se.capgemini.kafka.producer.service.KafkaProducerServiceApplication.main(KafkaProducerServiceApplication.java:16) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_252]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_252]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_252]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_252]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.3.3.RELEASE.jar:2.3.3.RELEASE]
Caused by: org.apache.camel.RuntimeCamelException: java.lang.IllegalStateException: Cannot find RestApiProcessorFactory in Registry or classpath (such a
s the camel-openapi-java component)
at org.apache.camel.RuntimeCamelException.wrapRuntimeCamelException(RuntimeCamelException.java:52) ~[camel-api-3.4.3.jar:3.4.3]
at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:67) ~[camel-support-3.4.3.jar:3.4.3]
at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:84) ~[camel-api-3.4.3.jar:3.4.3]
at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:101) ~[camel-api-3.4.3.jar:3.4.3]
at org.apache.camel.processor.channel.DefaultChannel.doStart(DefaultChannel.java:143) ~[camel-base-3.4.3.jar:3.4.3]
at org.apache.camel.support.service.BaseService.start(BaseService.java:115) ~[camel-api-3.4.3.jar:3.4.3]
at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:84) ~[camel-api-3.4.3.jar:3.4.3]
at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:87) ~[camel-api-3.4.3.jar:3.4.3]
at org.apache.camel.processor.Pipeline.doStart(Pipeline.java:154) ~[camel-base-3.4.3.jar:3.4.3]
at org.apache.camel.support.service.BaseService.start(BaseService.java:115) ~[camel-api-3.4.3.jar:3.4.3]
at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:84) ~[camel-api-3.4.3.jar:3.4.3]
at org.apache.camel.support.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78) ~[camel-support-3.4.3.jar:3.4.3]
at org.apache.camel.support.service.BaseService.start(BaseService.java:115) ~[camel-api-3.4.3.jar:3.4.3]
at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:84) ~[camel-api-3.4.3.jar:3.4.3]
at org.apache.camel.impl.engine.RouteService.startChildService(RouteService.java:334) ~[camel-base-3.4.3.jar:3.4.3]
at org.apache.camel.impl.engine.RouteService.doWarmUp(RouteService.java:184) ~[camel-base-3.4.3.jar:3.4.3]
at org.apache.camel.impl.engine.RouteService.warmUp(RouteService.java:123) ~[camel-base-3.4.3.jar:3.4.3]
... 31 common frames omitted
Caused by: java.lang.IllegalStateException: Cannot find RestApiProcessorFactory in Registry or classpath (such as the camel-openapi-java component)
at org.apache.camel.component.rest.RestApiEndpoint.createProducer(RestApiEndpoint.java:207) ~[camel-rest-3.4.3.jar:3.4.3]
at org.apache.camel.support.DefaultEndpoint.createAsyncProducer(DefaultEndpoint.java:200) ~[camel-support-3.4.3.jar:3.4.3]
at org.apache.camel.processor.SendProcessor.doStart(SendProcessor.java:232) ~[camel-base-3.4.3.jar:3.4.3]
at org.apache.camel.support.service.BaseService.start(BaseService.java:115) ~[camel-api-3.4.3.jar:3.4.3]
at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:84) ~[camel-api-3.4.3.jar:3.4.3]
at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:101) ~[camel-api-3.4.3.jar:3.4.3]
at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler.doStart(RedeliveryErrorHandler.java:1459) ~[camel-base-3.4.3.jar:3.4.3]
at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:60) ~[camel-support-3.4.3.jar:3.4.3]
... 46 common frames omitted
My pom.xml looks like this:^
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>se.capgemini</groupId>
<artifactId>kafka-producer-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>kafka-producer-service</name>
<description>Demo Spring Boot with Camel and Kafka Producer</description>
<packaging>war</packaging>
<properties>
<java.version>1.8</java.version>
<camel.version>3.4.3</camel.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-http-starter</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-rest-openapi-starter</artifactId>
<version>${camel.version}</version>
<!-- use the same version as your Camel core version -->
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-servlet-starter</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-jackson-starter</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-rest-swagger-starter</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
and my rest configuration looks like this:
@Component
public class KafkaProducerAPI extends RouteBuilder {
@Override
public void configure() throws Exception {
restConfiguration()
//.component("servlet")
.contextPath("/kafka-producer-service")
.port(8080)
.apiContextPath("/")
.apiProperty("api.title", "Test REST API")
.apiProperty("api.version", "v1")
.apiContextRouteId("doc-api")
.bindingMode(RestBindingMode.json);
rest()
.tag("Kafka Producer API")
.consumes(APPLICATION_JSON_VALUE)
.produces(APPLICATION_JSON_VALUE)
//.bindingMode(RestBindingMode.json)
.description("something")
.get("/test")
//.outType(Status.class)
.route()
.process(exchange -> {
exchange.getIn().setBody("Hello world!");
})
.end()
.endRest();
}
}
Probably I'm missing something simple, as I have a prety similar implementation with camel 2.x and it works just fine.
答案1
得分: 4
我最终通过添加以下内容来修复它:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-swagger-java</artifactId>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
此外,com.fasterxml.jackson.core 2.11.2引发了问题,所以我不得不降级到2.10.5。
感谢Claus Ibsen的建议。
英文:
I finally fixed it by adding the following:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-swagger-java</artifactId>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
Also the com.fasterxml.jackson.core 2.11.2 was giving problems so I had to downgrade to 2.10.5.
Thank you for the suggestions Claus Ibsen
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论