Henrik created CAMEL-25086:
------------------------------

             Summary: camel-platform-http-starter: fails to start outside a 
servlet web application (ServerProperties/WebMvcProperties)
                 Key: CAMEL-25086
                 URL: https://issues.apache.org/jira/browse/CAMEL-25086
             Project: Camel
          Issue Type: Bug
          Components: camel-platform-http, camel-spring-boot
    Affects Versions: 4.22.1, 4.22.0
            Reporter: Henrik
             Fix For: 4.22.2, 4.23.0


h3. Summary

Since 4.22.0 an application context that is not a servlet web application fails 
to start when {{camel-platform-http-starter}} is on the classpath:

{noformat}
Error creating bean with name 'platform-http-engine' ... Unsatisfied dependency 
expressed through method
'springBootPlatformHttpEngine' parameter 1: No qualifying bean of type
'org.springframework.boot.web.server.autoconfigure.ServerProperties' available
{noformat}

and, from {{SpringBootPlatformWebMvcConfiguration}}, the same for 
{{org.springframework.boot.webmvc.autoconfigure.WebMvcProperties}}.

The common case is {{@SpringBootTest(webEnvironment = WebEnvironment.NONE)}} on 
an application with platform-http or Rest DSL routes, which worked on 4.21.0.

h3. Cause

"camel-platform-http-starter: align auto-configuration with Spring Boot 4 
idioms" (595c737) made the engine inject {{ServerProperties}} instead of 
reading {{server.port}}, and stopped enabling {{WebMvcProperties}} on the 
grounds that the owning auto-configuration does. Spring Boot only registers 
both beans in a servlet web application, so neither exists in a non-web context.

{{@ConditionalOnWebApplication}} is not a fix: without an engine bean 
{{PlatformHttpComponent.getOrCreateEngine}} fails to resolve one, so the routes 
fail to start instead.

h3. Proposed fix

Inject both as {{ObjectProvider}}. The engine port uses {{ServerProperties}} 
when present, otherwise the {{server.port}} property, otherwise 8080 (the 4.21 
behaviour). A missing {{WebMvcProperties}} means no async request timeout was 
configured.

h3. Found in

On the 4.21.0 -> 4.22.1 upgrade: every {{WebEnvironment.NONE}} test context 
failed to start.




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

Reply via email to