IllegalStateException: getOutputStream() Issue???
I am fairly new to JSP and having problem with this piece of code, any insight will be appreciated. thanks
<%@ page contentType="application/vnd.ms-excel" autoFlush="false"
import="java.io.*, org.apache.poi.hssf.usermodel.HSSFWorkbook"
%>
<jsp:useBean id="FRNW" class="jsptutorial.JSPExcelUsingHSSFBean" scope="application" />
<%
try {
HSSFWorkbook wb = FRNW.createSheet() ;
ServletOutputStream os = response.getOutputStream();
wb.write(os);
os.flush();
} catch (Exception e) {
out.println("error in JSP");
%>
the code works and output what I excpected to see, but produce this error message on server. "java.lang.IllegalStateException: getOutputStream() has already been called for this response"
any idea what's going on...???
Hi
I am facing the same issue but getting it in Java code ( not JSP ) in my application, basically am using FOP to convert a XML into PDF, when i print my PDF the following error is thrown in the server :
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:606)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:195)
at org.springframework.web.servlet.view.freemarker.FreeMarkerView.processTemplate(FreeMarkerView.java:344)
at org.springframework.web.servlet.view.freemarker.FreeMarkerView.doRender(FreeMarkerView.java:280)
at org.springframework.web.servlet.view.freemarker.FreeMarkerView.renderMergedTemplateModel(FreeMarkerView.java:225)
at org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:174)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:239)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1142)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:879)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:441)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at org.ca.ielts.presentationtier.servlet.AuthorisationAuthenticationFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
My Code:
/* Finally writing it into a PDF */
response.setContentType("application/pdf");
/* filename could be any thing */
response.setHeader("Content-Disposition",
"attachment; filename=Report.pdf");
response.setContentLength(content.length);
response.getOutputStream().write(content);
response.getOutputStream().flush();
response.getOutputStream().close();
response.flushBuffer();
Please respond soon as this is pretty urgent.
Similar Messages
-
IllegalStateException: getOutputStream() has already been called
Hi guys,
I am writing JSP to retrieve data from database and export to the user as csv or zip file. It has to be binary. I would like to a download dialog to show up and allow users to choose where to save the exported file.
Funcitonally, it works fine althrough I get an error page saying nothing to display. But it always complains that IllegalStateException: getOutputStream() has already been called for this session. I have done much research and testing, but....in vain.
Hope somebody could help me with this. so frustrated that I am about to explode.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="application/octet-stream">
<title>Load Page</title>
</head>
<body >
<% OutputStream outRes = response.getOutputStream( ); %><%@page contentType="application/octet-stream"%><%
%><%@page pageEncoding="UTF-8" import="java.sql.*,java.io.*,java.util.*,java.util.zip.*,java.math.BigDecimal;"%><%
%><%
try {
Class.forName(ResourceBundle.getBundle("map").getString("driver"));
} catch (ClassNotFoundException ex) {
//ex.printStackTrace();
return;
String EXPORT_DIR = ResourceBundle.getBundle("map").getString("SUBMITTAL_EXPORT_DIR");
String EXPORT_NAME = ResourceBundle.getBundle("map").getString("SUBMITTAL_NAME");
String EXPORT_ZIP_NAME = ResourceBundle.getBundle("map").getString("SUBMITTAL_ZIP_NAME");
String sqlQuery = "SELECT EMP_ID, EMP_NAME FROM EMP";
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
OutputStream expStream = null;
boolean success = false;
try {
//out.println("<p>Connecting to the source database ...");
// establish database connection
conn = DriverManager.getConnection(
ResourceBundle.getBundle("map").getString("sqlurl"),
ResourceBundle.getBundle("map").getString("ORACLE_DBUSER"),
ResourceBundle.getBundle("map").getString("ORACLE_DBPASSWORD") );
stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(sqlQuery);
//out.println("Done</p>");
// open a file to write
File exportFile = new File(EXPORT_DIR + File.separatorChar + EXPORT_NAME);
if (exportFile.exists()) exportFile.delete();
exportFile.createNewFile();
expStream = new BufferedOutputStream(new FileOutputStream(exportFile));
// iterate all records to save them to the file
//out.print("<p>Exporting the table data ...");
while(rs.next()) {
String recordString = "";
ResultSetMetaData metaData = rs.getMetaData() ;
int colCount = metaData.getColumnCount();
for(int i=1; i<=colCount; i++) {
int colType = metaData.getColumnType(i);
switch(colType) {
case Types.CHAR: {
String sValue = rs.getString(i);
if (rs.wasNull())
recordString += ("'',");
else
recordString += ("'"+ sValue + "',");
break;
case Types.VARCHAR: {
String sValue = rs.getString(i);
if (rs.wasNull())
recordString += ("'',");
else
recordString += ("'"+ sValue + "',");
break;
case Types.FLOAT: {
float fValue = rs.getFloat(i);
if (rs.wasNull())
recordString += (",");
else
recordString += (fValue + ",");
break;
case Types.DOUBLE: {
double dbValue = rs.getDouble(i);
if (rs.wasNull())
recordString += (",");
else
recordString += (dbValue + ",");
break;
case Types.INTEGER: {
int iValue = rs.getInt(i);
if (rs.wasNull())
recordString += (",");
else
recordString += (iValue + ",");
break;
case Types.NUMERIC: {
BigDecimal bdValue = rs.getBigDecimal(i);
if (rs.wasNull())
recordString += (",");
else
recordString += (bdValue + ",");
break;
default:
out.println("<p><font color=#ff0000> Unidentified Column Type "
+ metaData.getColumnTypeName(i) + "</font></p>"); */
success = false;
return;
recordString = recordString.substring(0, recordString.length()-1);
expStream.write(recordString.getBytes());
expStream.write((new String("\n")).getBytes());
expStream.flush();
//out.println("Done</p>");
//out.println("<p>Data have been exported to " + filepath + "</p>");
success = true;
} catch (SQLException ex) {
//out.println(ex.getStackTrace());
} catch (IOException ex) {
//out.println(ex.getStackTrace());
} finally {
if (expStream != null) {
try {
expStream.close();
} catch (IOException ex) {
// out.println(ex.getStackTrace());
if (rs != null) {
try {
rs.close();
} catch(SQLException ex) {
//out.println(ex.getStackTrace());
if (stmt != null) {
try {
stmt.close();
} catch(SQLException ex) {
// out.println(ex.getStackTrace());
if(conn != null) {
try {
conn.close();
} catch(SQLException ex) {
// out.println(ex.getStackTrace());
if (!success) return;
* compress the exported CSV file if necessary
int DATA_BLOCK_SIZE = 1024;
if (request.getParameter("zip")!=null && request.getParameter("zip").equalsIgnoreCase("true")) {
success = false;
BufferedInputStream sourceStream = null;
ZipOutputStream targetStream = null;
try {
File zipFile = new File(EXPORT_DIR + File.separatorChar + EXPORT_ZIP_NAME);
if (zipFile.exists()) zipFile.delete();
zipFile.createNewFile();
FileOutputStream fos = new FileOutputStream ( zipFile );
targetStream = new ZipOutputStream ( fos );
targetStream.setMethod ( ZipOutputStream.DEFLATED );
targetStream.setLevel ( 9 );
* Now that the target zip output stream is created, open the source data file.
FileInputStream fis = new FileInputStream ( EXPORT_DIR + File.separatorChar + EXPORT_NAME );
sourceStream = new BufferedInputStream ( fis );
/* Need to create a zip entry for each data file that is read. */
ZipEntry theEntry = new ZipEntry ( EXPORT_DIR + File.separatorChar + EXPORT_NAME );
* Before writing information to the zip output stream, put the zip entry object
targetStream.putNextEntry ( theEntry );
/* Add comment to zip archive. */
//targetStream.setComment( "comment" );
/* Read the source file and write the data. */
byte[] buf = new byte[DATA_BLOCK_SIZE];
int len;
while ( ( len = sourceStream.read ( buf, 0, DATA_BLOCK_SIZE ) ) >= 0 ) {
targetStream.write ( buf, 0, len );
* The ZipEntry object is updated with the compressed file size,
* uncompressed file size and other file related information when closed.
targetStream.closeEntry ();
targetStream.flush ();
success = true;
} catch ( FileNotFoundException e ) {
//e.printStackTrace ();
} catch ( IOException e ) {
//e.printStackTrace ();
} finally {
try {
if (sourceStream != null)
sourceStream.close ();
if (targetStream != null)
targetStream.close ();
} catch(IOException ex) {
//ex.printStackTrace();
if (!success) return;
* prompt the user to download the file
//response.setContentType("text/plain");
//response.setContentType( "application/octet-stream" );
InputStream inStream = null;
//OutputStream outRes = null;
try {
if (request.getParameter("zip")!=null && request.getParameter("zip").equalsIgnoreCase("true")) {
response.setHeader("Content-Disposition", "attachment;filename=" + EXPORT_ZIP_NAME);
inStream = new BufferedInputStream(new FileInputStream(EXPORT_DIR + File.separatorChar + EXPORT_ZIP_NAME));
else {
response.setHeader("Content-Disposition", "attachment;filename=" + EXPORT_NAME);
inStream = new BufferedInputStream(new FileInputStream(EXPORT_DIR + File.separatorChar + EXPORT_NAME));
out.clearBuffer();
//outRes = response.getOutputStream( );
byte[] buf = new byte[4 * DATA_BLOCK_SIZE]; // 4K buffer
int bytesRead;
while ((bytesRead = inStream.read(buf)) != -1) {
outRes.write(buf, 0, bytesRead);
outRes.flush();
int byteBuf;
while ( (byteBuf = inStream.read()) != -1 ) {
out.write(byteBuf);
out.flush();
} catch (IOException ex) {
//ex.printStackTrace();
finally {
try {
if (inStream != null)
inStream.close();
if (outRes != null)
outRes.close();
} catch(IOException ex) {
//ex.printStackTrace();
%>
</body>
</html>So I went to the API: http://java.sun.com/j2ee/1.4/docs/api/
Looked up ServletResponse, then looked for the getOutputStream() method. It says:
"Throws:
IllegalStateException - if the getWriter method has been called on this response"
You can call only one of the getWriter or getOutputStream methods, not both. You are calling both. When you use a JSP, a variable called 'out' is generated (a PrintWriter) from the the Writer you get when response.getWriter() is called. This is done before your code gets executed as one of the functions that occur when a JSP is translated to a Servlet. You then write to that out variable when you print the HTML in the JSP code.
This is best done in a Servlet, not a JSP, since there is no display and you require control over the servlet response. -
Getting java.lang.IllegalStateException error with response.getOutputStream
Hi,
I am writer a JSP site for displaying JFreeChart. The main JSP page gets some parameters then the second page out put the chart as binary data with a Java class.
I've located the part which generated the error, as follows:
Code:
OutputStream os = response.getOutputStream(); <--- this line cause the error
response.setContentType("image/png");
ChartUtilities.writeChartAsPNG(os, chart, 400, 300);
(other than it, the JSP does nothing with response or out)
Error:
Servlet.service().for servlet jsp threw exception java.lang.IllegalStateException
at org.apache.jasper.runtime.ServletResponseWrapperInclude.getOutputStream(ServletResponseWrapperInclude.java:62)
at org.apache.jsp.build005f005.seriesChart_jsp.jspService(org.apache.jsp.build_005f005.seriesChart_jsp:110)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWarpper.java:325)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
I've searched this forum and google and seeking for solution for thousands times. But sadly, ways such as adding out.reset(); doesn't work.
Would any one has some suggestion for me? Your help is very appreciated. Thanks!A similar question / answers from jGuru.com
Question I used getOutputStream() of response object in JSP. Below is the code for download a file in JSP.
%>
<%@ page import="java.util.*,
java.io.*"
%>
<%@ page language="java"
session="false"
contentType="text/html; charset=8859_1"
%>
<%
//read the file name.
File fFile = new File ("D:/Ibs/outdir/batchres.conf");
String stFileName = "batchres.conf";
//the content type set as excel
response.setContentType ("application/excel");
//the header and also the Nameis set by which user will be prompted to save
response.setHeader ("Content-Disposition", "attachment;filename=\""+stFileName+"\"");
//Open an input stream to the file and post the file contents thru the
//servlet output stream to the client m/c
InputStream isStream = null;
ServletOutputStream sosStream = null;
try
//response.flushBuffer();
isStream = new FileInputStream(fFile);
sosStream = response.getOutputStream();
int ibit = 256;
while ((ibit) >= 0)
ibit = isStream.read();
sosStream.write(ibit);
catch (IOException ioeException)
sosStream.flush();
sosStream.close();
isStream.close();
%>
If run this code in Tomcat i am getting following error.. �<h1>Error: 500</h1> <h2>Location: /imu/jsp/ibUTLCmnDownloadView.jsp</h2>Internal Servlet Error:
java.lang.IllegalStateException: getOutputStream() has already been called
at org.apache.tomcat.facade.HttpServletResponseFacade.getWriter(Unknown Source)
at org.apache.jasper.runtime.JspWriterImpl.initOut(Unknown Source)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(Unknown Source)
at jsp.ibUTLCmnDownloadView_12._jspService(ibUTLCmnDownloadView_12.java, Compiled Code)
at org.apache.jasper.runtime.HttpJspBase.service(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(Unknown Source)
at org.apache.tomcat.core.Handler.invoke(Unknown Source)
at org.apache.tomcat.core.Handler.service(Unknown Source)
at org.apache.tomcat.facade.ServletHandler.service(Unknown Source)
at org.apache.tomcat.facade.RequestDispatcherImpl.doForward(Unknown Source)
at org.apache.tomcat.facade.RequestDispatcherImpl.forward(Unknown Source)
at JP.co.Hitachi.soft.IBS.Common.Servlet.ibUTLCmnDownloadScrGenServlet.doPost(ibUTLCmnDownloadScrGenServlet.java:75)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(Unknown Source)
at org.apache.tomcat.core.Handler.invoke(Unknown Source)
at org.apache.tomcat.core.Handler.service(Unknown Source)
at org.apache.tomcat.facade.ServletHandler.service(Unknown Source)
at org.apache.tomcat.core.ContextManager.internalService(Unknown Source)
at org.apache.tomcat.core.ContextManager.service(Unknown Source)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Unknown Source)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(Unknown Source)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Unknown Source)
at java.lang.Thread.run(Thread.java:479)
Answer
Don't know if this will help--your code worked as is on my system (J2SDK 1.4.1, Tomcat 4.1.12, Linux)--but you're setting the content-type twice, and to two different values. In the page directive, you specify contentType="text/html; charset=8859_1", and then in the scriptlet, you do a response.setContentType ("application/excel");. Try changing the one in the page directive and deleting the one in the scriptlet. The servlet container may be calling getOutputStream() when it sees the text MIME type so it can prepare the out built-in variable.
Also, according to the J2EE design patterns, JSP's should only be used to produce text output. Any binary output (such as Excel files) should be produced with servlets--otherwise, the JSP becomes one big scriptlet (like this one).
If you still want to do this with a JSP, you might want to take out your try ... catch block since you're not doing anything with it. Doing so will allow you to let the servlet container handle the errors (i.e. specify error pages in the web application deployment descriptor). Either that, or at least put the close() and flush()calls in it since they can throw IOExceptions, too. :)
Finally, you should never close the servlet's output stream. Leave that up to the servlet container.
Is this item helpful? yes no Previous votes Yes: 2 No: 3
To transfer file from client to server using jsp programs
chalpati Rao, Aug 11, 2004 [replies:1]
How to Download File using JSP program
Re: To transfer file from client to server using jsp programs
Saravanan Mani, Aug 24, 2004
Try restarting the server.It worked for me (ie.you did all the code changes mentioned in the previous reply)
Breakline problems
David Machado, Jan 27, 2005 [replies:1]
Hi! Maybe a problem with breaklines. Try this: ------------------------------------------------------
%><%@ // don't send breakline here!!!
page import="java.util.*,
java.io.*"
%><%@ // don't send breakline here too!!!
page language="java"
session="false"
contentType="text/html; charset=8859_1"
%><% // finally, don't send breakline here!!!
//read the file name.
File fFile = new File ("D:/Ibs/outdir/batchres.conf");
String stFileName = "batchres.conf";
//the content type set as excel
response.setContentType ("application/excel"); // twice???
//the header and also the Nameis set by which user will be prompted to save
response.setHeader ("Content-Disposition", "attachment;filename=\""+stFileName+"\"");
//Open an input stream to the file and post the file contents thru the
//servlet output stream to the client m/c
InputStream isStream = null;
ServletOutputStream sosStream = null;
try
//response.flushBuffer();
isStream = new FileInputStream(fFile);
sosStream = response.getOutputStream();
int ibit = 256;
while ((ibit) >= 0)
ibit = isStream.read();
sosStream.write(ibit);
catch (IOException ioeException)
sosStream.flush();
sosStream.close();
isStream.close();
%> // make sure that's no breakline an no spaces at the end!!
Re: Breakline problems
Aarthi Sivaram, Apr 19, 2005
In the above code sosStream = response.getOutputStream(); must be removed. Use 'out' instead of sosStream i.e. out.write(""+ibit); If you look at the Java code generated for your JSP, you can find JspWriter out = null ... .. JspWriter calls response.getOutputStream(), thats why when u call getOutputStream, u get IllegalStateException. 'out' variable is available for direct use in all JSP's, like 'request'. So that can be directly used to write.
A quick and working workaround
Leslie Leng, May 20, 2005 [replies:1]
I am not going to discuss the theory behind, as others gurus mentioned before me, are valid.
In short, getOutputStream() could not be used more than once, and also it will conflict with JSPWriter's out.
So, the quick workaround would be, at the end of the JSP page, add the following:
out.clear();
out = pageContext.pushBody();
in example:
catch(Exception e){
System.out.print(e);
out.clear();
out = pageContext.pushBody();
%>
Re: A quick and working workaround
ajit Pandey, Jul 15, 2005
Thanks a ton Leslie ,it worked(Production issue) :) credit goes to you....indebted -
GetOutputStream() has already been called for this response
I have a problem with my servlet,
i compiled my code,it works normally but there is an error occured when it works.
The error is :
java.lang.IllegalStateException: getOutputStream() has already been called for this response
* at org.apache.catalina.connector.Response.getWriter(Response.java:607)*
* at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:196)*
* at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125)*
* at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:118)*
* at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:179)*
* at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:116)*
* at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:76)*
* at org.apache.jsp.KaptchaExample_jsp._jspService(KaptchaExample_jsp.java:209)*
* at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)*
* at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)*
* at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)*
* at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)*
* at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)*
* at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)*
* at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)*
* at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)*
* at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)*
* at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)*
* at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)*
* at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)*
* at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)*
* at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)*
* at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)*
* at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)*
* at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)*
* at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)*
* at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)*
* at java.lang.Thread.run(Thread.java:534)*
here is my code :
Iterator iter = ImageIO.getImageWritersByFormatName(imageFormat);
* if( iter.hasNext() ) {*
* ImageWriter writer = (ImageWriter)iter.next();*
* ImageWriteParam iwp = writer.getDefaultWriteParam();*
* if ( imageFormat.equalsIgnoreCase("jpg") || imageFormat.equalsIgnoreCase("jpeg") ) {*
* iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);*
* iwp.setCompressionQuality(imageQuality);*
* //writer.setOutput(ImageIO.createImageOutputStream(response.getWriter()));*
* IIOImage imageIO = new IIOImage(bufferedImage, null, null);*
* writer.write(null, imageIO, iwp);*
* response.flushBuffer();*
please help me,would u give me a solutions for my problem..i really appreciate if you want to give a solution.
Regards,
Dany FauziActually the stack trace indicates the the error is happening in KaptchaExample.jsp, not in a Servlet. I'm guessing that the code you've presented is in a scriptlet (i.e. inside the JSP in <% %> brackets). This is altogether the wrong place for it. JSPs are purely for generating HTML and to try and generate image responses in one is doomed to failure. Write a servlet class to generate your image file. If you want to embed a dynamically generated image in an HTML page, then you need to generate HTML which accesses the Servlet through the <img src=... tag, i.e. the browser retrieves the image data as a separate transaction.
The immediate source of the crash is that the JSP already opened the output stream in order to write HTML output, so it's too late to try and open it for the writing of image data. -
Production Issue heap space error. Getting ERROR 503 Service not deployed
Hi,
I have deployed my web services (VAS services) in tomcat 6.0 in production .I am using axis2 1.4.1 as web service engine and apache 2.2 for httpd service. My problem is that in every 8-10 hrs when no of transactions increase, a problem occurs in my server and I get an ERROR 503 service not deployed. I dont know the exact cause and solution to this problem. Presently every time I face this problem, I restart my httpd services and tomcat. Please help me to rectify this problem as this is hampering our business in a big way. I am sending the log details of catalina.log in tomcats log folder
17-Nov-2008 17:20:56 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet AxisServlet threw exception
java.lang.OutOfMemoryError: Java heap space
17-Nov-2008 17:21:33 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet AxisServlet threw exception
java.lang.OutOfMemoryError: Java heap space
17-Nov-2008 17:21:33 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet AxisServlet threw exception
java.lang.OutOfMemoryError: Java heap space
17-Nov-2008 17:21:36 org.apache.jk.core.MsgContext action
WARNING: Error sending end packet
java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at org.apache.jk.common.ChannelSocket.send(ChannelSocket.java:531)
at org.apache.jk.common.JkInputStream.endMessage(JkInputStream.java:121)
at org.apache.jk.core.MsgContext.action(MsgContext.java:301)
at org.apache.coyote.Response.action(Response.java:183)
at org.apache.coyote.Response.finish(Response.java:305)
at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:276)
at org.apache.catalina.connector.Response.finishResponse(Response.java:486)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:285)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:686)
at java.lang.Thread.run(Unknown Source)
17-Nov-2008 17:21:36 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet AxisServlet threw exception
java.lang.OutOfMemoryError: Java heap space
17-Nov-2008 17:23:31 org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.OutOfMemoryError: Java heap space
17-Nov-2008 17:23:31 org.apache.jk.common.ChannelSocket processConnection
WARNING: processCallbacks status 2
17-Nov-2008 17:23:31 org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.OutOfMemoryError: Java heap space
17-Nov-2008 17:23:31 org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.OutOfMemoryError: Java heap space
17-Nov-2008 17:23:31 org.apache.jk.core.MsgContext action
WARNING: Error sending end packet
java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at org.apache.jk.common.ChannelSocket.send(ChannelSocket.java:531)
at org.apache.jk.common.JkInputStream.endMessage(JkInputStream.java:121)
at org.apache.jk.core.MsgContext.action(MsgContext.java:301)
at org.apache.coyote.Response.action(Response.java:183)
at org.apache.coyote.Response.finish(Response.java:305)
at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:276)
at org.apache.catalina.connector.Response.finishResponse(Response.java:486)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:285)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:686)
at java.lang.Thread.run(Unknown Source)
17-Nov-2008 17:23:31 org.apache.jk.core.MsgContext action
WARNING: Error sending end packet
java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at org.apache.jk.common.ChannelSocket.send(ChannelSocket.java:531)
at org.apache.jk.common.JkInputStream.endMessage(JkInputStream.java:121)
at org.apache.jk.core.MsgContext.action(MsgContext.java:301)
at org.apache.coyote.Response.action(Response.java:183)
at org.apache.coyote.Response.finish(Response.java:305)
at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:276)
at org.apache.catalina.connector.Response.finishResponse(Response.java:486)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:285)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:686)
at java.lang.Thread.run(Unknown Source)
17-Nov-2008 17:23:34 org.apache.jk.common.ChannelSocket processConnection
WARNING: processCallbacks status 2
17-Nov-2008 17:23:34 org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:604)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:118)
at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:186)
at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:118)
at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:77)
at org.apache.jsp.axis2_002dweb.Error.error500_jsp._jspService(error500_jsp.java:110)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:447)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:424)
at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:343)
at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:287)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:686)
at java.lang.Thread.run(Unknown Source)
17-Nov-2008 17:23:34 org.apache.jk.common.ChannelSocket processConnection
WARNING: processCallbacks status 2
17-Nov-2008 17:23:34 org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.OutOfMemoryError: Java heap space
17-Nov-2008 17:23:34 org.apache.catalina.core.ApplicationDispatcher invoke
Regards,
Paritosh
Edited by: anshu_299 on Nov 18, 2008 9:39 AMHi,
503 error comes when the client finds that the target server is not running or accessible.
Is the java system up and running? Check if the server nodes are up ?
check for the logs in work dir and if only server node is not coming up then check for default traces.
Amit. -
Eclipse as a development environment with Jakarta Tomcat
Hello:
I am setting up the new development environment for my application (project). Below are the components involved::
� Eclipse 3.1
� myEclipse - EnterpriseWorkbenchInstaller_4.0GA_E3.1
� jakarta-tomcat-5.0.28 (Application Server)
� Sysdeo Eclipse Tomcat Launcher plugin - tomcatPluginV31beta
� SDK 1.4.2_08
� Microsoft XP sp2 operating system
I have no issue with creation of project structure in eclipse IDE, compilation, and deployment, but there are some exception upon running the application.
My project folder structure as follows:
MyApplication/
src/
Conf/
Web/
classes
taglib
lib
web.xml
� my application has few dependent projects, therefore I copied all the dependent projects final compiled classes (jars) to �lib� folder.
� I set all necessary classpath according to tomcat documentation.
� I created MyApplication.xml file under D:\jakarta-tomcat-5.0.28\conf\Catalina\localhost\ folder with the below context
<Context path="/MyApplication " docBase="D:/xx/xxx/dev/src/ MyApplication/web" debug="0" reloadable="true" />
� I don�t get any exception during compilation and deployment process.
� I would greatly appreciate if you could give me a tips!!!!!!!!!!!!!!!!!!!!!!
Error as follows:
2005-10-10 17:31:45 StandardContext[balancer]org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: [org.apache.webapp.balancer.RuleChain: [org.apache.webapp.balancer.rules.URLStringMatchRule: Target string: News / Redirect URL: http://www.cnn.com], [org.apache.webapp.balancer.rules.RequestParameterRule: Target param name: paramName / Target param value: paramValue / Redirect URL: http://www.yahoo.com], [org.apache.webapp.balancer.rules.AcceptEverythingRule: Redirect URL: http://jakarta.apache.org]]
2005-10-10 17:31:47 StandardContext[jsp-examples]ContextListener: contextInitialized()
2005-10-10 17:31:47 StandardContext[jsp-examples]SessionListener: contextInitialized()
2005-10-10 17:31:47 StandardContext[servlets-examples]ContextListener: contextInitialized()
2005-10-10 17:31:47 StandardContext[servlets-examples]SessionListener: contextInitialized()
2005-10-10 17:32:27 StandardContext[manager]HTMLManager: init: Associated with Deployer 'localhost'
2005-10-10 17:32:27 StandardContext[manager]HTMLManager: init: Global resources are available
2005-10-10 17:32:27 StandardContext[manager]HTMLManager: list: Listing contexts for virtual host 'localhost'
2005-10-10 17:32:35 StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.coyote.tomcat5.CoyoteResponse.getWriter(CoyoteResponse.java:599)
at org.apache.coyote.tomcat5.CoyoteResponseFacade.getWriter(CoyoteResponseFacade.java:163)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:122)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:115)
at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:190)
at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:115)
at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:75)
at org.apache.jsp.default_jsp._jspService(default_jsp.java:101)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
path setting as follows:
%JAVA_HOME%\bin;D:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\Borland\AppServer\bin;C:\Program Files\CA\PEC\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\system32\nls;%SystemRoot%\system32\nls\ENGLISH;C:\Program Files\Attachmate\E!E2K\;C:\Program Files\CA\AllFusion Harvest Change Manager;D:\jwsdp-1.1\jaxb-1.0\bin;D:\jwsdp-1.1\jwsdp-shared\bin;C:\Borland\classes12.zip;C:\Program Files\UltraEdit;D:\jakarta-tomcat-5.0.28\webapps\cst\WEB-INF\classes;D:\EPS\EB_CST_v3.7.2\dev\src\cst;%PATH%
Classpath setting as follows:
.;%third_pty%\xerces.jar;D:\EPS\EB_CST_v3.7.2\dev\src\cst;D:\jakarta-tomcat-5.0.28\webapps\cst;D:\jakarta-tomcat-5.0.28\common\lib\servlet-api.jar;D:\jakarta-tomcat-5.0.28\common\lib\jsp-api.jar;D:\jwsdp-1.1\jaxb-1.0\lib\jaxb-api.jar;D:\jwsdp-1.1\jaxb-1.0\lib\jaxb-ri.jar;%third_pty%\ant.jar;D:\jwsdp-1.1\jaxp-1.2.2\lib\endorsed\dom.jar;D:\jwsdp-1.1\jwsdp-shared\lib\jax-qname.jar;D:\jwsdp-1.1\jaxb-1.0\lib\jaxb-libs.jar;D:\jwsdp-1.1\jaxb-1.0\lib\jaxb-xjc.jar;D:\jwsdp-1.1\jaxp-1.2.2\lib\jaxp-api.jar;D:\jwsdp-1.1\jaxp-1.2.2\lib\endorsed\sax.jar;D:\jwsdp-1.1\jaxp-1.2.2\lib\endorsed\xercesImpl.jar;%third_pty%\activation.jar;%third_pty%\ant-optional.jar;%third_pty%\j2ee.jar;%third_pty%\jakarta-regexp.jar;%third_pty%\jaxp.jar;%third_pty%\jcert.jar;%third_pty%\jnet.jar;%third_pty%\jsse.jar;%third_pty%\xalan.jar;C:\MSJDBSLib\msbase.jar;C:\MSJDBSLib\mssqlserver.jar;C:\MSJDBSLib\msutil.jar;
Other IDE setting:
As per tomcat documentation.Hello:
I overcame the above issue by changing index.html to index.jsp, but now i am facing another issue as shown below:
On top of the above change i too included j2ee.jar (from websphere) in the classpath to overcome the below issue, but even then i am getting the same error.
Error as follows:
javax.servlet.ServletException: Error instantiating servlet class com.metavante.cst.control.web.LoginMainServlet
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:996)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:687)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:671)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:474)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:409)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:214)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
----- Root Cause -----
java.lang.NoClassDefFoundError: javax/ejb/EJBObject
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1634)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:860)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1307)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:1618)
at java.lang.Class.getConstructor0(Class.java:1930)
at java.lang.Class.newInstance0(Class.java:278)
at java.lang.Class.newInstance(Class.java:261)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:987)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:687)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:671)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:474)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:409)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:214)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534) -
Eclipse as a development environment with Jakarta Tomcat - Need help!!
Hello:
Subject: Eclipse as a development environment with Jakarta Tomcat
I am setting up the new development environment for my application (project). Below are the components involved::
� Eclipse 3.1
� myEclipse - EnterpriseWorkbenchInstaller_4.0GA_E3.1
� jakarta-tomcat-5.0.28 (Application Server)
� Sysdeo Eclipse Tomcat Launcher plugin - tomcatPluginV31beta
� SDK 1.4.2_08
� Microsoft XP sp2 operating system
I have no issue with creation of project structure in eclipse IDE, compilation, and deployment, but there are some exception upon running the application.
My project folder structure as follows:
MyApplication/
src/
Conf/
Web/
classes
taglib
lib
web.xml
� my application has few dependent projects, therefore I copied all the dependent projects final compiled classes (jars) to �lib� folder.
� I set all necessary classpath according to tomcat documentation.
� I created MyApplication.xml file under D:\jakarta-tomcat-5.0.28\conf\Catalina\localhost\ folder with the below context
<Context path="/MyApplication " docBase="D:/xx/xxx/dev/src/ MyApplication/web" debug="0" reloadable="true" />
� I don�t get any exception during compilation and deployment process.
� I would greatly appreciate if you could give me a tips!!!!!!!!!!!!!!!!!!!!!!
Error as follows:
2005-10-10 17:31:45 StandardContext[balancer]org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: [org.apache.webapp.balancer.RuleChain: [org.apache.webapp.balancer.rules.URLStringMatchRule: Target string: News / Redirect URL: http://www.cnn.com], [org.apache.webapp.balancer.rules.RequestParameterRule: Target param name: paramName / Target param value: paramValue / Redirect URL: http://www.yahoo.com], [org.apache.webapp.balancer.rules.AcceptEverythingRule: Redirect URL: http://jakarta.apache.org]]
2005-10-10 17:31:47 StandardContext[jsp-examples]ContextListener: contextInitialized()
2005-10-10 17:31:47 StandardContext[jsp-examples]SessionListener: contextInitialized()
2005-10-10 17:31:47 StandardContext[servlets-examples]ContextListener: contextInitialized()
2005-10-10 17:31:47 StandardContext[servlets-examples]SessionListener: contextInitialized()
2005-10-10 17:32:27 StandardContext[manager]HTMLManager: init: Associated with Deployer 'localhost'
2005-10-10 17:32:27 StandardContext[manager]HTMLManager: init: Global resources are available
2005-10-10 17:32:27 StandardContext[manager]HTMLManager: list: Listing contexts for virtual host 'localhost'
2005-10-10 17:32:35 StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.coyote.tomcat5.CoyoteResponse.getWriter(CoyoteResponse.java:599)
at org.apache.coyote.tomcat5.CoyoteResponseFacade.getWriter(CoyoteResponseFacade.java:163)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:122)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:115)
at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:190)
at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:115)
at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:75)
at org.apache.jsp.default_jsp._jspService(default_jsp.java:101)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
path setting as follows:
%JAVA_HOME%\bin;D:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\Borland\AppServer\bin;C:\Program Files\CA\PEC\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\system32\nls;%SystemRoot%\system32\nls\ENGLISH;C:\Program Files\Attachmate\E!E2K\;C:\Program Files\CA\AllFusion Harvest Change Manager;D:\jwsdp-1.1\jaxb-1.0\bin;D:\jwsdp-1.1\jwsdp-shared\bin;C:\Borland\classes12.zip;C:\Program Files\UltraEdit;D:\jakarta-tomcat-5.0.28\webapps\cst\WEB-INF\classes;D:\EPS\EB_CST_v3.7.2\dev\src\cst;%PATH%
Classpath setting as follows:
.;%third_pty%\xerces.jar;D:\EPS\EB_CST_v3.7.2\dev\src\cst;D:\jakarta-tomcat-5.0.28\webapps\cst;D:\jakarta-tomcat-5.0.28\common\lib\servlet-api.jar;D:\jakarta-tomcat-5.0.28\common\lib\jsp-api.jar;D:\jwsdp-1.1\jaxb-1.0\lib\jaxb-api.jar;D:\jwsdp-1.1\jaxb-1.0\lib\jaxb-ri.jar;%third_pty%\ant.jar;D:\jwsdp-1.1\jaxp-1.2.2\lib\endorsed\dom.jar;D:\jwsdp-1.1\jwsdp-shared\lib\jax-qname.jar;D:\jwsdp-1.1\jaxb-1.0\lib\jaxb-libs.jar;D:\jwsdp-1.1\jaxb-1.0\lib\jaxb-xjc.jar;D:\jwsdp-1.1\jaxp-1.2.2\lib\jaxp-api.jar;D:\jwsdp-1.1\jaxp-1.2.2\lib\endorsed\sax.jar;D:\jwsdp-1.1\jaxp-1.2.2\lib\endorsed\xercesImpl.jar;%third_pty%\activation.jar;%third_pty%\ant-optional.jar;%third_pty%\j2ee.jar;%third_pty%\jakarta-regexp.jar;%third_pty%\jaxp.jar;%third_pty%\jcert.jar;%third_pty%\jnet.jar;%third_pty%\jsse.jar;%third_pty%\xalan.jar;C:\MSJDBSLib\msbase.jar;C:\MSJDBSLib\mssqlserver.jar;C:\MSJDBSLib\msutil.jar;
Other IDE setting:
As per tomcat documentation.Need tips to solve this issue!!!
-
How to Over write an existing response?
Sep 22, 2010 3:15:25 PM org.apache.catalina.core.ApplicationContext log
INFO: Loading Spring root WebApplicationContext
Sep 22, 2010 3:17:55 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:610)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
at com.qwest.rx.brain.utils.CoreBrainUtils.write(CoreBrainUtils.java:152)
at com.qwest.rx.brain.interceptor.ContentWriterInterceptor.postprocess(ContentWriterInterceptor.java:31)
at com.qwest.rx.brain.interceptor.BaseInterceptor.intercept(BaseInterceptor.java:53)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
at com.qwest.rx.brain.interceptor.ExceptionInterceptor.intercept(ExceptionInterceptor.java:66)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:218)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:507)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:619)
i am getting this error when i do response.getWriter().
this is the method which i am calling
public static void write(String arg0, ActionContext ac) throws IOException{
HttpServletResponse response = (HttpServletResponse) ac.get(ServletActionContext.HTTP_RESPONSE);
PrintWriter writer = response.getWriter();
writer.print(arg0);
writer.flush();
}800662 wrote:
Sep 22, 2010 3:15:25 PM org.apache.catalina.core.ApplicationContext log
INFO: Loading Spring root WebApplicationContext
Sep 22, 2010 3:17:55 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
I am getting this error when i do response.getWriter().
this is the method which i am calling
public static void write(String arg0, ActionContext ac) throws IOException {
HttpServletResponse response = (HttpServletResponse) ac.get(ServletActionContext.HTTP_RESPONSE);
PrintWriter writer = response.getWriter();
writer.print(arg0);
writer.flush();
I assume the question that you forgot to ask is "how do you resolve this issue?"
[url http://download.oracle.com/javaee/1.4/api/javax/servlet/ServletResponse.html#getWriter%28%29]ServletResponse.getWriter()
[url http://download.oracle.com/javaee/1.4/api/javax/servlet/ServletResponse.html#getOutputStream%28%29]ServletResponse.getOutputStream()
Some other method has already invoked Response.getOutputStream().
You can make sure your method is invoked earlier than the other method
then the problems goes away in your method
[and the other method will get an exception when it invokes getOutputStream()]. -
We have a few Palm Pilot PQA apps on our webserver (Weblogic 4.5.1) that we
want people to be able to download.
In IE the downloads work fine. The user is presented with the "Save As"
window and so on. But in Netscape, the binary data of the PQA file just
starts streaming back to the browser.
Is this a MIME type issue? If so, how should I configure?
-MikeThanks for information.
Actually i have problem in downloading the file.
I get below exception on server side when i download file.
File is downloading without any problem in client browser.
But i get the following error on Server Console
java.lang.IllegalStateException: getOutputStream() has already been called for this response
Any suggestion /reasons for the problem. -
Hi
I'm having problems outputting a binary image from a tag handler more than once. This is apparently a known problem with JSP but I was wondering if anyone had found a workaround (other that writing a servlet).
The basic problem is that if you call ServletResponse.getOutputStream() more than once in a page or if you call it after ServletResponse.getWriter() has been called then you get:
java.lang.IllegalStateException: getOutputStream() has already been called for this response
The result is that Tag Libraries are a technology that doesn't allow you to output two binary things directly onto a page or to output any binary data if you've also output text or vice versa. That sounds extraordinarily bad to me.
I know there must be good reasons for the difficulty but surely there's a fix or a well known workaround.
Has anyone out there got over this problem or know whether any fixes are planned? Thanks.
MurrayYou can call either getOutputStream or getWriter, and you can it only once (it assumes you'll assign that to a variable and use the variable from then on). It's not a bug or problem, it's a reasonable restriction to prevent you from doing what I think you are trying to do....
So you can use the writer to write text-based output, or the output stream to write binary data.
But this is somewhat irrelevent. You can't output HTML and include binary data, like an image, in the HTML.
<div>here is some text, followed by an image</div>
<div>0a68df9834ce7932d....</div> <-- binary data...
The browser has no idea what to do with that. That's why you have image tags and object/embed tags in HTML. And the browser has to make a separate request to get the content for the image tag. So the servlet can output image data or other stuff, if the image tag is used to call a servlet to serve an image. But they are not doing with the same call the a servlet (and usually you have separate servlets for that stuff).
Ultimately, this is not a JSP/servlet issue. This is strictly and HTML, HTTP, browser issue: That's how it works and has worked since long before JSP and servlets came about. JSP/servlets do not change how HTML and browsers work in any way/shape/form. They only allow for dynamically generating content the browser gets. -
CR4Ev2 problem exporting to PDF containing Turkish characters
I know there are other threads with similar topics but I also know some people get irritated when people jump onto their threads with their own problems.
I am using CR4Ev2 and on my machine which I have installed Eclipse on I have no problems
exporting my reports to PDF, I have Turkish characters which display perfectly (they did not with
CR4Ev1 so thanks so much for that)
I have now exported my project as a WAR file and am trying to run it on another machine with the same
Tomcat and Java versions.
If I view the report via the CrystalReport Viewer the Turkish characters display with no hassel.
But if I try export the report to PDF all the Turksh characters now display as ?, (as they did in CR4Ev1)
Am I missing something, is there something that I am not including in my project that I need
when exporting the PDF.
I have installed Adobe Reader 9 on this new machine incase the Turkish langauge fonts were not in
my version 8, but still get funny ? characters, I even installed the Turksih version of Adobe 9 and still nothing. Is there some other files that I could have installed on my Eclipse machine that I have not installed
on the second machine.
I have tried both the following commands to export to PDF
CRJavaHelper.exportPDF(clientDoc, response, true);
and
CRJavaHelper.exportPDF(clientDoc, response, false);
both dont work.
I have also tried the following (which I used before with CR4Ev1)
ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream)clientDoc.getPrintOutputController().export(ReportExportFormat.PDF);
writeToFileSystem(byteArrayInputStream, EXPORT_OUTPUT); // EXPORT_OUTPUT = "c:\test.pdf"
private void writeToFileSystem(ByteArrayInputStream byteArrayInputStream, String exportFile) throws Exception {
//Use the Java I/O libraries to write the exported content to the file system.
byte byteArray[] = new byte[byteArrayInputStream.available()];
//Create a new file that will contain the exported result.
File file = new File(exportFile);
FileOutputStream fileOutputStream = new FileOutputStream(file);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(byteArrayInputStream.available());
int x = byteArrayInputStream.read(byteArray, 0, byteArrayInputStream.available());
byteArrayOutputStream.write(byteArray, 0, x);
byteArrayOutputStream.writeTo(fileOutputStream);
//Close streams.
byteArrayInputStream.close();
byteArrayOutputStream.close();
fileOutputStream.close();
But that also does not work.
Please can someone tell me what they think I am missing.
Oh, another note with the CRJavaHelper.exportPDF(clientDoc, response, false); command
It does work but I do get the following error in my console (both the Eclipse machine and the new one).
org.apache.jasper.JasperException: java.lang.IllegalStateException: getOutputStream() has already been called for this response
06-Feb-2009 15:06:52 org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:610)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:118)
at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:188)
at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:118)
at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:77)
at org.apache.jsp.Report_002dviewer_jsp._jspService(Report_002dviewer_jsp.java:263)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
But as I said it seems to work fine apart from the Turkish character issue on the new machine)
Is this part of the problem or a seperate issue??
Thanks all for looking at this.
DarrenTed,
I have double checked the Java version and infact reinstalled jdk6u7 (multilanguage version) just to be
100% sure, but that did not help.
ON my Eclipse machine the Fonts are as follows
Verdana(Embedded Subset)
Type: TrueType
Encoding: Built-In
but on the other machine it is different
Verdana
Type: TrueType
Encoding: Ansi
Actual Font: Verdana
Actual Font Type: TrueType
So that does appear to be the problem, but the question is what controls this?
As I said the project is exactly the same (same WAR file) so what I have done differently or what am I
missing in the new enviroment.
I set the "Text file encoding" for the whole project to UTF-8 before I exported the project (in Eclipse)
but that didnt help. I even set the properties of each report to UTF-8.
I am sure I am missing something simple.
The only other difference is Im running XP Pro on Eclipse machine but W2KSP4 on the other, but
surely that is not the issue.
Cheers
Darren -
Problem in drawing image on the fly using jsp
I have been searching the forum and web for the problem but in vain. I have wrote a jsp which creates an image on the fly from the data selected from the database. But after the image is drawn, it throws an IllegalStateException. The offending code is at the time of releasePageContext() method of the compiled jsp. I am using the following code in jsp to display the image.
BufferedImage bi = obj.getBufferedImage();
javax.imageio.ImageIO.write(bi,"png",response.getOutputStream());
I even tried to do the same with servlet, but the problem is that when I am using forward action in jsp I am getting the image but the control is in the servlet and if I am including the servlet, I am getting junk characters instead of image. I have set the content type in servlet and also in jsp.
Thank you in advance.Hi all,
I've developed a web application using glassfish server... my database is postgresql.... i try to generate a report using Jasper Reports.... i've succesfully developed the report template..... My problem when ever i try to generate a report it gets the data from the back end.... and throws the following error.....
StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.coyote.tomcat5.CoyoteResponse.getWriter(CoyoteResponse.java:652)
at org.apache.coyote.tomcat5.CoyoteResponseFacade.getWriter(CoyoteResponseFacade.java:196)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:149)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:142)
at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:216)
at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:134)
at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:89)
at org.apache.jsp.GenerateBirthCertificate_jsp._jspService(GenerateBirthCertificate_jsp.java:149)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:353)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:409)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:317)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:278)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)
at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)
at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
i've written my code in jsp.... My code is....
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page language="java" import="java.io.*, net.sf.jasperreports.engine.*, java.sql.*, java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>CDAC Portal</title>
</head>
<body>
<%
try {
Connection con=null;
String query="";
String regNo="";
regNo=request.getParameter("regNo");
regNo = regNo.toUpperCase();
out.println("Registration No :"+regNo);
Class.forName("org.postgresql.Driver");
con = DriverManager.getConnection("jdbc:postgresql://192.168.31.79:5432/Municipality","postgres","");
System.out.println("connected succefully");
ServletContext context = this.getServletConfig().getServletContext();
File reportFile = new File(context.getRealPath("/reports/birth_cert.jasper"));
query="select * from birth_details where regn_unit='"+regNo+"'";
Map parameters = new HashMap();
parameters.put("regNo",""+regNo);
parameters.put("query",""+query);
byte[] bytes = null;
try {
bytes = JasperRunManager.runReportToPdf(reportFile.getPath(), parameters, con);
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();
} catch (JRException e) {
System.out.println("Error : "+e);
con.close();
} catch(Exception exc) {
System.out.println("Connection pool error :"+exc.toString());
%>
</body>
</html>
can anyone help me hw to solve this problem....
Thanks in advance
R Vijay,
Project Engineer,
CDAC, Chennai.
India
[email protected]
[email protected] -
Image Retrevial From Database throws error
Can anyone point out what i'm doing wrong with the code below please..
It all works perfectly and returns the image. The probelm is that it causes
java.lang.IllegalStateException: getOutputStream() has already been called for this response
to be thrown in the site's logfile.
It all works perfectly by causes the log file to fill up as visitors access the image.
<%@ page import="java.io.*" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.DriverManager" %>
<%
Connection connectiongalleryimage = null;
Statement statementgalleryimage = null;
InputStream sImage = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
connectiongalleryimage = DriverManager.getConnection("jdbc:mysql://cluster_01:3306/site_db", "xxxxxx", "xxxxxxx");
statementgalleryimage = connectiongalleryimage.createStatement();
ResultSet rs = statementgalleryimage.executeQuery("select main_image from galleryobj where galobj_id=5 and rec_status='ACTIVE'");
rs.first();
byte[] bytearray = new byte[4096];
int size=0;
sImage = rs.getBinaryStream(1);
response.reset();
response.setContentType("image/jpeg");
response.addHeader("Content-Disposition","filename=getimage.jpeg");
OutputStream outputStream = response.getOutputStream();
while((size=sImage.read(bytearray))!=-1) {outputStream.write(bytearray,0,size);}
} catch (Exception e) {
out.println("<!-- Error getting requested image: "+e+"-->");
} finally {
response.flushBuffer();
sImage.close();
statementgalleryimage.close();
connectiongalleryimage.close();
%>Google has lot of examples: http://www.google.com/search?q=imageservlet+code+example
At least here is one: http://balusc.blogspot.com/2007/04/imageservlet.html -
Path and file name problem when I want to download files from html
Hi all,
I want to write a small program to allow users download files from jsp file
but the following files don't work .
<%@ page language="java" import="java.net.*,java.io.*"%>
<%@ page import ="java.util.*"%>
<%
try
String SContent = request.getParameter("click");
String SDocName = "temp.doc"; // out put file File Name
ServletOutputStream stream= response.getOutputStream(); // Getting ServletOutputStream
response.setContentType("application/msword"); // Setting content type
response.setHeader("Content-disposition","attachment;filename=\"" +SDocName+"\""); // To pop dialog box
BufferedInputStream in = new BufferedInputStream(new FileInputStream(SContent));
int c;
while ((c = in.read()) != -1){
stream.write(c);
in.close();
stream.flush();
catch(final IOException e)
System.out.println ( "IOException." );
catch(Exception e1)
System.out.println ( "Exception." );
%>I am so confuse, what is the path and file name I sould give ? for example my click should equal to http://******/Test/display.jsp?click=00-1Hi all,
I got error at
java.lang.IllegalStateException: getOutputStream() has already been called for this response
org.apache.coyote.tomcat5.CoyoteResponse.getWriter(CoyoteResponse.java:599)
if I want ot download file from html file.
String SContent = request.getParameter("click");
if I hard code like follow it work fine.
String SContent ="C:/Project Coding.doc";
what mistake I make.
Thank you! -
Getting error message when trying to display error messages on a ProfilePage
Hi All,
I'm getting following error message when trying to display error on a Profile page.
On page i'm seeing this:
org.apache.jasper.JasperException: java.lang.IllegalStateException: getOutputStream() has already been called for this response
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:515)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:405)
In condole, i'm seeing this:
18:23:00,206 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:621)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
Please let me know what could be the reason.
Thanks,
VishnuHI David And Nitin,
Here is the code using which i'm trying to display the error messages on registration page, but this code fragment is outside registration form will that cause any problem?
<dsp:droplet name="Switch">
<dsp:param name="value" bean="ProfileFormHandler.formError"/>
<dsp:oparam name="true">
<table>
<dsp:droplet name="ProfileErrorMessageForEach">
<dsp:param name="exceptions" bean="ProfileFormHandler.formExceptions"/>
<dsp:oparam name="output">
<tr style="color: red">
<td><dsp:valueof param="message"></dsp:valueof></td>
</tr>
</dsp:oparam>
</dsp:droplet>
</table>
</dsp:oparam>
</dsp:droplet>
Thanks,
Vishnu
Maybe you are looking for
-
How can i convert an object to stream of chars or bytes?
how can i convert an object to stream of chars or bytes?
-
Help with Scrolling Text Item.
Hi , need help with making a text item scrollable. i.e. A field is 30 characters and i can only display 10 characters, now what I would like is a scroll bar under the text item. Is this possible. I am using Forms 5. Thanx for any help. Pankaj Patel.
-
What Size External Drive?
Have 5 Macs and am getting 3 new ones (retiring two of the old PPCs to the kids - can't run Leopard). Will update the 3 Intels with Leopard, and the new ones will come with it installed. I have external backups for the existing computers (my rule of
-
How to track the CqPage using stats.jsp
Hi, I have added the stats.jsp in the head of the template <cq:include script="/libs/foundation/components/page/stats.jsp" /> but how can i track the page viewed ? Thanks in advance Sumit
-
In properties I have link color white, visited blank, rollover blank and active blank. When viewed in chrome, IE or firefox a white rectangle appears when you hover over each link. What is the procedure for removing this?