Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error: java.lang.IllegalStateException: Writer already obtained

Status
Not open for further replies.

inunix

Technical User
Jul 30, 2002
53
US
I'm getting this error when try to stream crystals reports from Servlet.

This application was running on Unix-WebSphere.

I requested to restart Cyrstal server and recycle my web application running on WebSphere. Still the same problem exits.

The error is
"java.lang.IllegalStateException: Writer already obtained"


Below is the error message I got from the websphere server:
**************************************
[11/21/03 9:22:14:306 EST] 54622b7c SystemErr R java.lang.IllegalStateException: Writer already obtained
[11/21/03 9:22:14:307 EST] 54622b7c SystemErr R at com.ibm.ws.webcontainer.srt.SRTServletResponse.getOutputStream(SRTServletResponse.java:490)
[11/21/03 9:22:14:307 EST] 54622b7c SystemErr R at com.xyz.myapp.ViewReport.exportReport(ViewReport.java:267)
[11/21/03 9:22:14:307 EST] 54622b7c SystemErr R at com.xyz.myapp.ViewReport.doPost(ViewReport.java:99)
[11/21/03 9:22:14:307 EST] 54622b7c SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
[11/21/03 9:22:14:307 EST] 54622b7c SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
[11/21/03 9:22:14:307 EST] 54622b7c SystemErr R at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java(Compiled Code))
[11/21/03 9:22:14:307 EST] 54622b7c SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java(Compiled Code))
[11/21/03 9:22:14:307 EST] 54622b7c SystemErr R at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java(Compiled Code))
[11/21/03 9:22:14:308 EST] 54622b7c SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java(Inlined Compiled Code))
[11/21/03 9:22:14:308 EST] 54622b7c SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java(Compiled Code))
[11/21/03 9:22:14:308 EST] 54622b7c SystemErr R at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java(Compiled Code))
[11/21/03 9:22:14:308 EST] 54622b7c SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java(Inlined Compiled Code))
[11/21/03 9:22:14:308 EST] 54622b7c SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java(Compiled Code))
[11/21/03 9:22:14:308 EST] 54622b7c SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java(Compiled Code))
[11/21/03 9:22:14:308 EST] 54622b7c SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java(Compiled Code))
[11/21/03 9:22:14:308 EST] 54622b7c SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java(Compiled Code))
[11/21/03 9:22:14:308 EST] 54622b7c SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java(Compiled Code))
[11/21/03 9:22:14:309 EST] 54622b7c SystemErr R at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java(Compiled Code))
[11/21/03 9:22:14:309 EST] 54622b7c SystemErr R at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java(Compiled Code))
[11/21/03 9:22:14:309 EST] 54622b7c SystemErr R at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java(Compiled Code))
[11/21/03 9:22:14:309 EST] 54622b7c SystemErr R at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java(Compiled Code))
[11/21/03 9:22:14:309 EST] 54622b7c SystemErr R at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java(Compiled Code))
[11/21/03 9:22:14:309 EST] 54622b7c SystemErr R at com.ibm.ws.http.HttpConnection.run(HttpConnection.java(Compiled Code))
[11/21/03 9:22:14:309 EST] 54622b7c SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)
**************************************

Any help would be appreciated.

Thanks in advance.
 
can you check the state before you begin writing. For instance, when working with object you always wants to check
to make sure the object is of the right type by using instanceOf function. I'm sure there is some equivalent function that can check the state before you begin writing.

~za~
You can't bring back a dead thread!
 
Somwhere in your code, you are calling for some kind of outputstream from your HttpServletResponse object twice - and this causes an IllegalStateException. Check for multiple calls of :

response.getOutputStream();
reponse.getWriter();

in your servlets, and any JSP pages that the servlet may hand the session request/response onto.
 
Thanks Max and Sedj.

This code was working fine till last thursday, since Friday I'm having this problem.

Sedj, I just checked my code, we used writer and outputStream only once.

Any more suggestions...

Thanks again.
 
FYI... Looks like recently our WebSphere server was updated from 5.0.1 to 5.0.2..

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top