Runtime error after upgrading to camel 3.0 - stepwise construction of camel RouteDefinition

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

Runtime error after upgrading to camel 3.0 - stepwise construction of camel RouteDefinition

reji.mathews
This post was updated on .
Hello Camel users community

I have a code snippet which builds RouteDefinition via handler chains. I just upgraded to camel 3.0 version

Following is the code snippet

@Override
public RouteDefinition handle(RestDefinition restDef, Step flowStep) throws Exception {
    LOGGER.info("File handler called");
    FileType fileType = readConfig(flowStep);
    LOGGER.info("File path is "+fileType.filepath);
    String uri = String.format("file:%s", fileType.filepath);
    LOGGER.info("URI=->"+uri);
    return from(uri);
}


Compilation is successful. However, following stack trace shows up when file consumer handler is encountered in execution and its thrown at line "return from(uri)"  . Has anyone encountered such issues after upgrade from 2.24.1 to 3.0.x version

2020-01-03 13:49:49.420 - INFO 18692 --- [main] c.h.c.core.handlers.source.FileHandler  [lineno:28]     : File handler called
2020-01-03 13:49:49.431 - INFO 18692 --- [main] c.h.c.core.handlers.source.FileHandler  [lineno:30]     : File path is input
2020-01-03 13:49:49.431 - INFO 18692 --- [main] c.h.c.core.handlers.source.FileHandler  [lineno:32]     : URI=->file:input
org.apache.camel.RuntimeCamelException: java.lang.NullPointerException
                at org.apache.camel.RuntimeCamelException.wrapRuntimeCamelException(RuntimeCamelException.java:52)
                at org.apache.camel.model.RouteDefinitionHelper.initRouteInput(RouteDefinitionHelper.java:460)
                at org.apache.camel.model.RouteDefinitionHelper.prepareRouteImp(RouteDefinitionHelper.java:374)
                at org.apache.camel.model.RouteDefinitionHelper.prepareRoute(RouteDefinitionHelper.java:347)
                at org.apache.camel.model.RoutesDefinition.route(RoutesDefinition.java:196)
                at org.apache.camel.model.RoutesDefinition.from(RoutesDefinition.java:167)
                at org.apache.camel.builder.RouteBuilder.from(RouteBuilder.java:230)
                at com.reji.camel.core.handlers.source.FileHandler.handle(FileHandler.java:33)
                at com.reji.camel.core.route.FlowRoutes.configure(FlowRoutes.java:78)
                at org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:471)
                at org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:438)
                at org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:418)
                at org.apache.camel.impl.engine.AbstractCamelContext.lambda$addRoutes$0(AbstractCamelContext.java:1114)
                at org.apache.camel.impl.engine.AbstractCamelContext.doWithDefinedClassLoader(AbstractCamelContext.java:2455)
                at org.apache.camel.impl.engine.AbstractCamelContext.addRoutes(AbstractCamelContext.java:1114)
                at com.reji.camel.core.FlowManager.createFlow(FlowManager.java:86)
                at com.reji.camel.data.source.FileSource.start(FileSource.java:65)
                at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182)
                at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53)
                at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360)
                at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158)
                at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122)
                at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:893)
                at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:161)
                at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552)
                at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
                at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742)
                at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389)
                at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
                at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213)
                at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202)
                at com.reji.camel.Application.main(Application.java:45)
Caused by: java.lang.NullPointerException
                at org.apache.camel.model.ProcessorDefinitionHelper.resolvePropertyPlaceholders(ProcessorDefinitionHelper.java:805)
                at org.apache.camel.model.RouteDefinitionHelper.initRouteInput(RouteDefinitionHelper.java:458)
                ... 30 more
Reply | Threaded
Open this post in threaded view
|

Re: Runtime error after upgrading to camel 3.0 - stepwise construction of camel RouteDefinition

Claus Ibsen-2
Hi

If you enable TRACE logging on camel, then you should see this line
before the exception

if (LOG.isTraceEnabled()) {
    LOG.trace("There are {} properties on: {}", readProperties.size(),
definition);
}

What does the log says

On Fri, Jan 3, 2020 at 8:06 PM Reji Mathews <[hidden email]> wrote:

>
> Hello Camel users community
>
> I have a code snippet which builds RouteDefinition via handler chains. I just upgraded to camel 3.0 version
>
> Following is the code snippet
>
> @Override
> public RouteDefinition handle(RestDefinition restDef, Step flowStep) throws Exception {
>     LOGGER.info("File handler called");
>     FileType fileType = readConfig(flowStep);
>     LOGGER.info("File path is "+fileType.filepath);
>     String uri = String.format("file:%s", fileType.filepath);
>     LOGGER.info("URI=->"+uri);
>     return from(uri);
> }
>
>
> Compilation is successful. However, following stack trace shows up when file consumer handler is encountered in execution and its thrown at line "return from(uri)"  . Has anyone encountered such issues after upgrade from 2.24.1 to 3.0.x version
>
> 2020-01-03 13:49:49.420 - INFO 18692 --- [main] c.h.c.core.handlers.source.FileHandler  [lineno:28]     : File handler called
> 2020-01-03 13:49:49.431 - INFO 18692 --- [main] c.h.c.core.handlers.source.FileHandler  [lineno:30]     : File path is input
> 2020-01-03 13:49:49.431 - INFO 18692 --- [main] c.h.c.core.handlers.source.FileHandler  [lineno:32]     : URI=->file:input
> org.apache.camel.RuntimeCamelException: java.lang.NullPointerException
>                 at org.apache.camel.RuntimeCamelException.wrapRuntimeCamelException(RuntimeCamelException.java:52)
>                 at org.apache.camel.model.RouteDefinitionHelper.initRouteInput(RouteDefinitionHelper.java:460)
>                 at org.apache.camel.model.RouteDefinitionHelper.prepareRouteImp(RouteDefinitionHelper.java:374)
>                 at org.apache.camel.model.RouteDefinitionHelper.prepareRoute(RouteDefinitionHelper.java:347)
>                 at org.apache.camel.model.RoutesDefinition.route(RoutesDefinition.java:196)
>                 at org.apache.camel.model.RoutesDefinition.from(RoutesDefinition.java:167)
>                 at org.apache.camel.builder.RouteBuilder.from(RouteBuilder.java:230)
>                 at com.huawei.camel.core.handlers.source.FileHandler.handle(FileHandler.java:33)
>                 at com.huawei.camel.core.route.FlowRoutes.configure(FlowRoutes.java:78)
>                 at org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:471)
>                 at org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:438)
>                 at org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:418)
>                 at org.apache.camel.impl.engine.AbstractCamelContext.lambda$addRoutes$0(AbstractCamelContext.java:1114)
>                 at org.apache.camel.impl.engine.AbstractCamelContext.doWithDefinedClassLoader(AbstractCamelContext.java:2455)
>                 at org.apache.camel.impl.engine.AbstractCamelContext.addRoutes(AbstractCamelContext.java:1114)
>                 at com.huawei.camel.core.FlowManager.createFlow(FlowManager.java:86)
>                 at com.huawei.camel.data.source.FileSource.start(FileSource.java:65)
>                 at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182)
>                 at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53)
>                 at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360)
>                 at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158)
>                 at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122)
>                 at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:893)
>                 at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:161)
>                 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552)
>                 at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
>                 at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742)
>                 at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389)
>                 at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
>                 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213)
>                 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202)
>                 at com.huawei.camel.Application.main(Application.java:45)
> Caused by: java.lang.NullPointerException
>                 at org.apache.camel.model.ProcessorDefinitionHelper.resolvePropertyPlaceholders(ProcessorDefinitionHelper.java:805)
>                 at org.apache.camel.model.RouteDefinitionHelper.initRouteInput(RouteDefinitionHelper.java:458)
>                 ... 30 more



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2