camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Block (JIRA)" <>
Subject [jira] [Commented] (CAMEL-8570) NullPointerException when using CXF-component in a spring-boot application with loglevel >= INFO
Date Mon, 30 Mar 2015 22:34:52 GMT


Andrew Block commented on CAMEL-8570:

Part of the issue is due to the CXF bus not being registered to the Camel endpoint. When the
endpoint spins up, it finds that the bus is null and instantiates it. By doing so, the BusApplicationContext
refreshes the Spring context which causes the Camel Spring Boot RoutesCollector to recreate
the routes in the context (routes that are spun up are shut down and reinitialized). By doing
so, the route which was registered in the routeservice is no longer present which causes the
nullpointerexception. To mitigate, we can define the CXFEndpoint and specify the bus as follows
within the PingPongRoute class

	private Bus bus;
	public void configure() throws Exception {
		CxfEndpoint endpoint = new CxfEndpoint();

		// @formatter:off

> NullPointerException when using CXF-component in a spring-boot application with loglevel
> ------------------------------------------------------------------------------------------------
>                 Key: CAMEL-8570
>                 URL:
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core, camel-cxf, camel-spring-boot
>    Affects Versions: 2.15.0, 2.15.1
>            Reporter: Jakob Thun
> I get a NullPointerException when using log-level INFO or finer in a spring-boot application
with CXF. 
> The exception is thrown from, where it tries to log how
many routes have been started.
> I have made an example project to reproduce it, it's available here: 
> I have tried with camel version: 2.15.0 & 2.15-SNAPSHOT. Both have the same behaviour.
> +Andrew Block started som analysis:+
> It is running into issues in this code block which is executed at logging level >=
>         if (log.isInfoEnabled()) { 
>             // count how many routes are actually started 
>             int started = 0; 
>             for (Route route : getRoutes()) { 
>                 if (getRouteStatus(route.getId()).isStarted()) { 
>                     started++; 
>                 } 
>             } 
>   "Total " + getRoutes().size() + " routes, of which " + started +
" is started."); 
>   "Apache Camel " + getVersion() + " (CamelContext: " + getName()
+ ") started in " + TimeUtils.printDuration(stopWatch.taken())); 
>         } 
> The exception occurs when the status for the route is pulled from the route service.
It is null and the exception is thrown. The route is initially spun up but then refreshes
when the CXF consumer is initialized. 
> Swapping it to test with a direct consumer does not result in a similar situation and
startup succeeds at all logging level. 
> It appears the route is not being registered with the route service

This message was sent by Atlassian JIRA

View raw message