Can't use /rest or /api prefix for my endpoints?

Hi,

I have an app using Spring Boot with below versions :

Spring-Boot: (v2.2.6.RELEASE)
Camunda BPM: (v7.12.0)
Camunda BPM Spring Boot Starter: (v3.4.0)

it is working as expected so far : I have a custom controller, for which I receive a payload, extract informations from it before passing it to the processEngine.

My endpoint is POST /decisionCalculation, and I also use the Camunda endpoints under the /rest/history resources.

Now I need to make some changes, and to make it clearer, I wanted to move my endpoint under /api/decisionCalculation . To my surprise, this doesn’t work. I tried with another prefix, like /test-vincent/decisionCalculation and it worked.

When I have /api/decisionCalculation as an endpoint, I get a strange error 500. The log is identical to the test that works, up to the WARN below. And then I get a “java.lang.IllegalStateException: Cannot create a session after the response has been committed” which leads to the 500 error

2020-04-01 17:26:35.664  INFO 2300 --- [o-auto-1-exec-2] o.s.web.servlet.DispatcherServlet        : Completed initialization in 39 ms
2020-04-01 17:26:35.679 TRACE 2300 --- [o-auto-1-exec-2] o.s.web.filter.RequestContextFilter      : Bound request context to thread: org.apache.catalina.connector.RequestFacade@174bb6e6
2020-04-01 17:26:35.938  WARN 2300 --- [o-auto-1-exec-2] o.a.c.util.SessionIdGeneratorBase        : Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [253] milliseconds.
2020-04-01 17:26:35.947 TRACE 2300 --- [o-auto-1-exec-2] o.s.web.filter.RequestContextFilter      : Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@174bb6e6
2020-04-01 17:26:35.953 ERROR 2300 --- [o-auto-1-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception

java.lang.IllegalStateException: Cannot create a session after the response has been committed
	at org.apache.catalina.connector.Request.doGetSession(Request.java:2995) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
	at org.apache.catalina.connector.Request.getSession(Request.java:2442) ~[tomcat-embed-core-9.0.33.jar:9.0.33]

I tried using /rest as a prefix, but then I get a 404… probably because the /rest prefix is already “reserved” for the Camunda API.

The issue is quite strange and the error message not helping… Maybe I missed it, but during my investigations, I haven’t found anything mentioning that issue. Since /api is a quite common prefix, I assume others would face it too and be puzzled.

Is there a way to still use the /api prefix for my own API when using the Spring Boot starter ?

(in the meantime, I am going with the /rest-api/ prefix, which works)

Thanks !