Open alexandru-crossover opened 3 years ago
Do you have a test repository I can use to try and replicate. My guess is that by default we try and initialize Spring's default DispatcherServlet which has no knowledge of the new camelServlet
registration.
I added a registerServlets() method in #399 so you could try to override it and register the camelServlet there.
Serverless Java Container version: 1.5.2
Implementations: Spring Boot 2
Framework version: Spring Boot 2.4.4
Frontend service: REST API using Apache Camel
Deployment method: Console
Scenario
Trying to test a simple
/test
REST endpoint served by Apache Camel.Expected behavior
The
/test
should return a status code of 200 and the expected result.Actual behavior
The endpoint returns a 404.
Steps to reproduce
Configure a simple Spring Boot 2 app with Apache Camel and define a route for it.
Example servlet config:
Example route:
Full log output
Implementation details
The problem is caused by this check from
ServletExecutionFilter
.By default,
getServletInfo()
returns an empty string, notnull
. The servlet used by Apache Camel,CamelHttpTransportServlet
, does not override that method.Because of this,
ServletExecutionFilter
thinks that the servlet is already initialized and it never calls itsinit()
method. Consequently, the servlet resolve strategy is not initialized and the consumer for a specific request is never found.Workaround
This can be worked around by overriding the
getServletInfo()
method: