Jacek Szymański created CAMEL-19257:
---------------------------------------
Summary: camel-jslt: Exception when using camel-jslt in Tomcat
Servlet
Key: CAMEL-19257
URL: https://issues.apache.org/jira/browse/CAMEL-19257
Project: Camel
Issue Type: Bug
Affects Versions: 4.0-M2, 3.20.3
Reporter: Jacek Szymański
When a JSLT transformation is used in a route which is called from a Tomcat
Servlet in Spring Boot, an exception is thrown after the Exchange is completely
processed and the response is being returned to the client:
{{java.lang.IllegalStateException: getWriter() has already been called for this
response}}
{{at org.apache.catalina.connector.Response.getOutputStream(Response.java:552)
~[tomcat-embed-core-9.0.70.jar:9.0.70]}}
{{at
org.apache.catalina.connector.ResponseFacade.getOutputStream(ResponseFacade.java:210)
~[tomcat-embed-core-9.0.70.jar:9.0.70]}}
{{at
org.apache.camel.http.common.DefaultHttpBinding.doWriteDirectResponse(DefaultHttpBinding.java:537)
~[camel-http-common-3.20.3.jar:3.20.3]}}
{{at
org.apache.camel.http.common.DefaultHttpBinding.doWriteResponse(DefaultHttpBinding.java:439)
~[camel-http-common-3.20.3.jar:3.20.3]}}
{{at
org.apache.camel.http.common.DefaultHttpBinding.writeResponse(DefaultHttpBinding.java:362)
~[camel-http-common-3.20.3.jar:3.20.3]}}
{{at
org.apache.camel.http.common.CamelServlet.afterProcess(CamelServlet.java:349)
~[camel-http-common-3.20.3.jar:3.20.3]}}
This happens because the Response object is held in a header and getWriter()
gets prematurely called when the headers are serialized in
JsltEndpoint.extractVariables().
--
This message was sent by Atlassian Jira
(v8.20.10#820010)