[
https://issues.apache.org/jira/browse/CAMEL-8570?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14388444#comment-14388444
]
Jakob Thun commented on CAMEL-8570:
-----------------------------------
I was a bit too quick in respoding with my previous comment. The workaround
described above got successful startup of routes, but the service itself did
not execute as expected.
Instead I got a NullPointer in: _DefaultConsumer.java:88_
UnitOfWork uow =
*endpoint.getCamelContext()*.getUnitOfWorkFactory().createUnitOfWork(exchange);
getCamelContext returns null, that is solved by getting the camelContext
instance and setting it on the endpoint, as below:
{noformat}
@Autowired
Bus bus;
@Autowired
CamelContext camelContext;
@Override
public void configure() throws Exception {
CxfEndpoint cxfPingPongEndpoint = new CxfEndpoint();
cxfPingPongEndpoint.setAddress("/PingPong");
cxfPingPongEndpoint.setBus(bus);
cxfPingPongEndpoint.setCamelContext(camelContext);
cxfPingPongEndpoint.setServiceClass(PingPongService.class);
// @formatter:off
from(cxfPingPongEndpoint)
{noformat}
> NullPointerException when using CXF-component in a spring-boot application
> with loglevel >= INFO
> ------------------------------------------------------------------------------------------------
>
> Key: CAMEL-8570
> URL: https://issues.apache.org/jira/browse/CAMEL-8570
> 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 DefaultCamelContext.java:2449, where it tries to
> log how many routes have been started.
> I have made an example project to reproduce it, it's available here:
> https://github.com/jakobthun/spring-boot-camel-cxf-logging-bug
> 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 >= INFO
> if (log.isInfoEnabled()) {
> // count how many routes are actually started
> int started = 0;
> for (Route route : getRoutes()) {
> if (getRouteStatus(route.getId()).isStarted()) {
> started++;
> }
> }
> log.info("Total " + getRoutes().size() + " routes, of which " +
> started + " is started.");
> log.info("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
(v6.3.4#6332)