You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2026/10/20 20:11:00 UTC

[jira] [Resolved] (CAMEL-25876) camel-main - log why Camel Main failed to start, once, instead of only the JVM printing it on stderr

     [ https://issues.apache.org/jira/browse/CAMEL-25876?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-25876.
---------------------------------
    Resolution: Fixed

> camel-main - log why Camel Main failed to start, once, instead of only the JVM printing it on stderr
> ----------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-25876
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25876
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-main
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> A Camel Main application that fails to start does not log why. {{MainSupport.run()}} passes a failure to start to the caller on purpose ("if we have an issue starting then propagate the exception to caller"), and only logs failures that happen while running. The main class of an application ({{main.run(args)}} in the main class of camel export, the archetypes and most applications) does not catch it, so the exception leaves {{main()}} and only the JVM prints it, on stderr:
> {noformat}
> 2026-10-20 09:55:49.909  INFO 16017 --- [main] he.camel.cli.connector.LocalCliConnector : Camel CLI connector enabled
> Exception in thread "main" java.lang.reflect.InvocationTargetException
> 	at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:106)
> 	...
> Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route: boom ...
> {noformat}
> (the launcher of the fat jar calls main by reflection, hence the InvocationTargetException). So the log file of the application ends before the failure. That matters in production, where an application often logs to a file, and for camel run --runtime=main, whose log is kept as the previous run (CAMEL-25832): camel log --previous and the AI tools of the camel-jbang-mcp server have no reason to show.
> KameletMain, which camel run uses by default, already logs it ({{doFail}}: "Error starting Camel"). Spring Boot logs "Application run failed" and Quarkus "Failed to start application", each once.
> Proposal:
> * {{MainSupport.logStartupFailure(e)}} logs "Error starting Camel: ..." with the stack trace. {{Main}} (and so the fat-jar {{Main}} of camel export) and {{KameletMain}} call it from {{doFail}}. It is not in the base class, as Camel Quarkus extends {{MainCommandLineSupport}} and logs the failure itself.
> * As Spring Boot does, the JVM then does not print the same failure a second time when it leaves main: the thread that started Camel gets an uncaught exception handler that skips the logged failure, also when it is wrapped (such as in the InvocationTargetException of the launcher). Any other exception is printed as before. Only when ERROR is logged, so an application without logging still sees the failure on stderr.
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v8.20.10#820010)