我在春季启动应用中使用camelServlet和camel kafka,但遇到了我无法理解的错误
当我尝试调用配置为REST DSL路由的get端点时,出现以下错误
路线:
rest().get("/getBatchID")
.to("direct:getBatchID");
我已经定义了骆驼servlet bean如下:
@Bean
public ServletRegistrationBean camelServletRegistrationBean() {
ServletRegistrationBean registration = new ServletRegistrationBean(new CamelHttpTransportServlet(), "/camel/*");
registration.setName("CamelServlet");
return registration;
Stacktrace:
2018-11-25 23:22:10,066|INFO |http-nio-9000-exec-2|o.a.c.c.s.CamelHttpTransportServlet - Initialized CamelHttpTransportServlet[name=CamelServlet, contextPath=]
2018-11-25 23:22:10,183|ERROR|http-nio-9000-exec-2|o.a.c.c.C.[.[.[.[CamelServlet] - Servlet.service() for servlet [CamelServlet] in context with path [] threw exception
java.lang.IllegalArgumentException: CamelContext must be specified on: HttpMessage@0x36ed8347
at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:342)
at org.apache.camel.impl.DefaultMessage.createHeaders(DefaultMessage.java:254)
at org.apache.camel.impl.DefaultMessage.setHeader(DefaultMessage.java:171)
at org.apache.camel.http.common.HttpMessage.<init>(HttpMessage.java:41)
at org.apache.camel.http.common.CamelServlet.doService(CamelServlet.java:169)
at org.apache.camel.http.common.CamelServlet.service(CamelServlet.java:74)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:90)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
发出获取请求时,我是否需要在标头中添加camelContext?