我有这个错误
严重:SEVERE: Servlet.service() for servlet [jsp] in context with path [/firstjsp] threw exception [ClientAbortException: java.net.SocketException: Software caused connection abort: socket write error] with root cause
当我有时运行我的应用程序时。
错误消息是
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.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:216)
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:460)
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:368)
at org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWrite(InternalOutputBuffer.java:241)
at org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java:119)
at org.apache.coyote.http11.AbstractOutputBuffer.doWrite(AbstractOutputBuffer.java:192)
at org.apache.coyote.Response.doWrite(Response.java:533)
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:373)
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:373)
at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:403)
at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:391)
at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:91)
at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:84)
at ChartDirector.GetSessionImage.a(SourceFile:90)
at ChartDirector.WebChartViewer.streamChart(SourceFile:301)
at org.apache.jsp.AutomaticAlarm_jsp._jspService(AutomaticAlarm_jsp.java:157)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
我的java代码是:
public Connection getConnection() {
String connectionUrl = "jdbc:sqlserver://localhost:49184;databaseName=Alarm;user=sa;password=Controls@#$%";
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(connectionUrl);
} catch (Exception e) {
System.out.println(" \nException in getConnection() " + e);
}
return con;
}
public void closeConnection(Statement stmt, ResultSet rs, Connection con) {
try {
if (stmt != null) {
stmt.close();
}
if (rs != null) {
rs.close();
}
if (con != null) {
con.close();
}
} catch (Exception e) {
System.out.println("\nexception in closeConnection( Statement stmt, ResultSet rs, Connection con) " + e);
}
}
public int get_Count1()
{
{
try {
con = getConnection();
stmt = con.createStatement();
String sql = " SELECT system_name, COUNT(distinct arrival_time) AS c FROM i2alarmlog WHERE Ack_status = 0 AND Direction='CAME' AND arrival_time between '2014-01-22 17:56:41.000' and '2014-01-24 17:56:41.000' and system_name in('I2-tciu database','i2-vcs logging','Indus1 Vacuum','Indus2 TCIU','Indus2 Vacuum','Septum_SIP2','TL3 Vacuum') GROUP BY system_name UNION ALL select 'TotalSum' as TotalSum,sum(s.c) as TotalValue from (SELECT system_name, COUNT(distinct arrival_time) AS c FROM i2alarmlog WHERE Ack_status = 0 AND Direction='CAME' and arrival_time between '2014-01-22 17:56:41.000' and '2014-01-24 17:56:41.000' AND system_name in('I2-tciu database','i2-vcs logging','Indus1 Vacuum','Indus2 TCIU','Indus2 Vacuum','Septum_SIP2','TL3 Vacuum') GROUP BY system_name ) s";
stmt.executeQuery(sql);
rs = stmt.getResultSet();
while (rs.next()) {
t1 = (rs.getInt(2));
}
} catch (Exception e) {
System.out.println("\nException " + e);
} finally {
closeConnection(stmt, rs, con);
}
}
System.out.println(t1);
return t1;
}
如何解决它。 我使用Jsp进行显示。我使用chartdirector将图表显示为: -
<% @page import = "ChartDirector.*" %>
<%
// The data for the line chart
double[] data1 = ab.total();
// The labels for the line chart
String[] labels = {
"VACUUM", "RSS", "MPS", "RF", "BLFE", "ORBIT", "LCW", "TCS", "INTERLOCK", "BDS", "MSIS", "MICROTON", "POWER CONDITIONER", "DATABASE"
};
XYChart c = new XYChart(1000, 650);
c.setPlotArea(90, 60, 750, 430);
c.xAxis().setLabels(labels);
c.xAxis().setTitle("System_Name", "Arial Bold", 12);
c.xAxis().setLabelStyle("Arial Bold", 10).setFontAngle(45);
c.addBarLayer3(data1).setBorderColor(Chart.Transparent, Chart.softLighting(Chart.Left));
BarLayer layer = c.addBarLayer2(Chart.Stack, 10);
layer.setAggregateLabelStyle();
layer.addDataSet(data1, 10, "Arial Bold Italic");
layer.setBorderColor(Chart.Transparent, Chart.softLighting(Chart.Top));
c.xAxis().setColors(Chart.Transparent);
c.yAxis().setColors(Chart.Transparent);
c.yAxis().setTitle("Alarm_Count", "Arial Bold", 12);
c.yAxis().setLabelStyle("Arial Bold", 10);
c.yAxis().setLinearScale(0.0, ab.max_Count());
c.yAxis().setLabelStep(2);
c.yAxis().setMargin(7);
c.xAxis().setWidth(2);
c.yAxis().setWidth(2);
try {
// stream the chart to the browser and terminate immediately
out.clear();
if (WebChartViewer.streamChart(response, c.makeChart2(Chart.PNG)))
return;
} catch (IllegalStateException e) {
// Some very old servers may not support streaming. So we are forced to redirect
// to the browser to use the traditional method.
response.sendRedirect(response.encodeRedirectURL("getchart.jsp?" +
c.makeSession(request, "chart")));
return;
}
%>
此外,图表会随机更新。