We are facing a strange issue while using servlet 3.0 with WebLogic.
We are using DeferredResult provided by Api. Below Code works fine with Tomcat7.
@RequestMapping(value = "/search/new", produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody
DeferredResult<String> getOutagesNew(HttpServletRequest httpRequest, HttpServletResponse response) throws IOException {
DeferredResult<String> deferredResult = new DeferredResult<String>();
deferredResult.setResult("Hello");
response.setHeader("Access-Control-Allow-Origin", "*");
return deferredResult;
}
But with WebLogic we get this exception
java.lang.IllegalStateException: strict servlet API: cannot call getOutputStream
() after getWriter()
at weblogic.servlet.internal.ServletResponseImpl.getOutputStream(Servlet
ResponseImpl.java:292)
at javax.servlet.ServletResponseWrapper.getOutputStream(ServletResponseW
rapper.java:138)
at javax.servlet.ServletResponseWrapper.getOutputStream(ServletResponseW
rapper.java:138)
at org.springframework.security.web.context.SaveContextOnUpdateOrErrorRe
sponseWrapper.getOutputStream(SaveContextOnUpdateOrErrorResponseWrapper.java:100
)
at org.springframework.http.server.ServletServerHttpResponse.getBody(Ser
vletServerHttpResponse.java:71)
at org.springframework.http.converter.StringHttpMessageConverter.writeIn
ternal(StringHttpMessageConverter.java:108)
at org.springframework.http.converter.StringHttpMessageConverter.writeIn
ternal(StringHttpMessageConverter.java:42)
at org.springframework.http.converter.AbstractHttpMessageConverter.write
(AbstractHttpMessageConverter.java:179)
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessage
ConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMeth
odProcessor.java:148)
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessage
ConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMeth
odProcessor.java:90)
at org.springframework.web.servlet.mvc.method.annotation.RequestResponse
BodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:18
9)
Please help