Native application from servlet (java.net.SocketException: Connection reset by peer: socket write error)
Hi all, We have a servlet based application which open a native application and read some output from them. Sometimes we get an error in tomcat logfile but application work fine. Here is error. Any ideas what is possible problem? 2004-02-09 10:02:26 StandardWrapperValve[default]: Servlet.service() for servlet default threw exception java.net.SocketException: Connection reset by peer: socket write error at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92) at java.net.SocketOutputStream.write(SocketOutputStream.java:136) at org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.d oWrite(InternalOutputBuffer.java:668) at org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(IdentityOu tputFilter.java:160) at org.apache.coyote.http11.InternalOutputBuffer.doWrite(InternalOutputBuff er.java:523) at org.apache.coyote.Response.doWrite(Response.java:524) at org.apache.coyote.tomcat4.OutputBuffer.realWriteBytes(OutputBuffer.java: 384) at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:439) at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:359) at org.apache.coyote.tomcat4.OutputBuffer.writeBytes(OutputBuffer.java:411) at org.apache.coyote.tomcat4.OutputBuffer.write(OutputBuffer.java:398) at org.apache.coyote.tomcat4.CoyoteOutputStream.write(CoyoteOutputStream.ja va:110) at org.apache.catalina.servlets.DefaultServlet.copyRange(DefaultServlet.jav a:1996) at org.apache.catalina.servlets.DefaultServlet.copy(DefaultServlet.java:174 5) at org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet .java:1073) at org.apache.catalina.servlets.DefaultServlet.doGet(DefaultServlet.java:50 6) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica tionFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt erChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv e.java:256) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv e.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticator Base.java:494) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:241 5) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java :180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherVa lve.java:171) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java :172) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve. java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:59 4) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processC onnection(Http11Protocol.java:392) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:56 5) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool .java:619) at java.lang.Thread.run(Thread.java:536) Veso
Open native console application from servlet (java.net.SocketException: Connection reset by peer: socket write error)
Hi all, We have a servlet based application which open a native console application and read samo output from them. Sometimes we get an error in tomcat logfile but application work ok. What is happen? Here is error. What is mean? 2004-02-09 10:02:26 StandardWrapperValve[default]: Servlet.service() for servlet default threw exception java.net.SocketException: Connection reset by peer: socket write error at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92) at java.net.SocketOutputStream.write(SocketOutputStream.java:136) at org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.d oWrite(InternalOutputBuffer.java:668) at org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(IdentityOu tputFilter.java:160) at org.apache.coyote.http11.InternalOutputBuffer.doWrite(InternalOutputBuff er.java:523) at org.apache.coyote.Response.doWrite(Response.java:524) at org.apache.coyote.tomcat4.OutputBuffer.realWriteBytes(OutputBuffer.java: 384) at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:439) at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:359) at org.apache.coyote.tomcat4.OutputBuffer.writeBytes(OutputBuffer.java:411) at org.apache.coyote.tomcat4.OutputBuffer.write(OutputBuffer.java:398) at org.apache.coyote.tomcat4.CoyoteOutputStream.write(CoyoteOutputStream.ja va:110) at org.apache.catalina.servlets.DefaultServlet.copyRange(DefaultServlet.jav a:1996) at org.apache.catalina.servlets.DefaultServlet.copy(DefaultServlet.java:174 5) at org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet .java:1073) at org.apache.catalina.servlets.DefaultServlet.doGet(DefaultServlet.java:50 6) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica tionFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt erChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv e.java:256) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv e.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticator Base.java:494) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:241 5) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java :180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherVa lve.java:171) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java :172) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve. java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:59 4) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processC onnection(Http11Protocol.java:392) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:56 5) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool .java:619) at java.lang.Thread.run(Thread.java:536)
RE: Problem with ConnectionPool on Linux
You think DBCP 1.1? I try to install Tomcat 4.1.29 but I get some error with connection pool. Is there some changes in server.xml settings? -Original Message- From: Kwok Peng Tuck [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 12, 2003 9:13 AM To: Tomcat Users List Subject: Re: Problem with ConnectionPool on Linux The new version of DBCP should be able to cope with this as well. I tested it with MaxDB and it works ok. Veselin Kovacevic wrote: >Now, everything working fine. :) > >Thanks Jon. > > > > >-Original Message- >From: Jon Wingfield [mailto:[EMAIL PROTECTED] >Sent: Tuesday, November 11, 2003 4:50 PM >To: Tomcat Users List >Subject: Re: Problem with ConnectionPool on Linux > > >MySql times out idle connections. If your pool implementation doesn't >take care of weeding out dead connections you need to add >autoReconnect=true to your connection string. > >HTH, > >Jon > >Veselin Kovacevic wrote: > > > >>Hi, >> >>I have o problem with Tomcat 4.1.24 on SuseLinux7.3. Our application >>has Controller servlet (below) where using connection objects from >>connection pool. When tomcat started, application working fine and >>everything OK that day. But next day when we try to start application >>we get error message in isUser method (PortalUserDB class). It's first >> >> > > > >>place where we use connection object in application. Method isUser is >>very simple method for authenticate user (below). We get this >>exception: SQL Exception:java.sql.SQLException: No operations allowed >>after connection closed >> >>Connection object is not null in this case, and this message for me is >> >> > > > >>not correct. Next, if I restart tomcat, everything working ok... (for >>next day). >> >>On windows (we using windows for development platform) we have not >>this problem. >> >>What is problem? >>Is configuration server.xml or similar configuration files on Linux >>different rather on windows? >> >>Note: >>On both platform we using Tomcat 4.1.24 and j2sdk1.4.1_03. >> >> >>public class Controller extends HttpServlet { >> >> private DataSource ds; >> >> public void init(ServletConfig config) throws ServletException { >> super.init(config); >> try { >> InitialContext initCtx = new InitialContext(); >> Context envCtx = >>(Context)initCtx.lookup("java:comp/env"); >> ds = >>(DataSource)envCtx.lookup("jdbc/MySQLPool"); >> } catch (Exception e){ >> throw new UnavailableException(e.getMessage()); >> } >> } >> >> public void doGet(HttpServletRequest request, >> >> >HttpServletResponse > > >>response) >>throws IOException, >>ServletException { >> >> request.setCharacterEncoding("iso-8859-2"); >> >> >> >> >> if (ds != null) { >> Connection conn = ds.getConnection(); >> if (conn != null) { >> boolean isUserExists = >>PortalUserDB.isUser(conn, userName, userPass); >> >> >> conn.close(); >> } >> >> >> >> } >>} >> >>public static boolean isUser(Connection conn, String userName, String >>userPass) >> throws SQLException, IOException { >> >> String query = "SELECT user_name FROM admin_user " + >> "WHERE user_name = ? " + >> "AND user_pass = ?"; >> >> boolean isUserExists = false; >> >> try { >> PreparedStatement pstmt = conn.prepareStatement(query); >> pstmt.setString(1, userName); >> pstmt.setString(2, userPass); >> >> ResultSet rs = pstmt.executeQuery(); >> >> isUserE
RE: Problem with ConnectionPool on Linux
We using MySQL for some features in application (login, roles, look and feel...) not for data. Before we use Oracle for all, but now we try to seperate "features" data from real data for better performance. It's corporate application, so nobody use them at night and we have not any job or activity on DB several hours. Anyway, we added autoReconnect in server.xml for connecting pool and everything working fine. Thanks Steph. -Original Message- From: Steph Richardson [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 11, 2003 4:56 PM To: Tomcat Users List Subject: RE: Problem with ConnectionPool on Linux My guess is you have some kind of job that runs at night that kicks or restarts your dB server ?? See if restarting your MySQL server in the middle of the day produces the same results. Anyway to make DBCP tolerant of the database dissapearing, try adding autoReconnect=true to your jdbc url. As in : jdbc:mysql://127.0.0.1:3306/mydb?autoReconnect=true > -Original Message----- > From: Veselin Kovacevic [mailto:[EMAIL PROTECTED] > Sent: Tuesday, November 11, 2003 4:57 AM > To: [EMAIL PROTECTED] > Subject: Problem with ConnectionPool on Linux > > > Hi, > > I have o problem with Tomcat 4.1.24 on SuseLinux7.3. Our application > has Controller servlet (below) where using connection objects from > connection pool. When tomcat started, application working fine and > everything OK that day. But next day when we try to start application > we get error message in isUser method (PortalUserDB class). It's first > place where we use connection object in application. Method isUser is > very simple method for authenticate user (below). We get this > exception: SQL Exception:java.sql.SQLException: No operations allowed > after connection closed > > Connection object is not null in this case, and this message for me is > not correct. Next, if I restart tomcat, everything working ok... (for > next day). > > On windows (we using windows for development platform) we have not > this problem. > > What is problem? > Is configuration server.xml or similar configuration files on Linux > different rather on windows? > > Note: > On both platform we using Tomcat 4.1.24 and j2sdk1.4.1_03. > > > public class Controller extends HttpServlet { > > private DataSource ds; > > public void init(ServletConfig config) throws ServletException { > super.init(config); > try { > InitialContext initCtx = new InitialContext(); > Context envCtx = > (Context)initCtx.lookup("java:comp/env"); > ds = > (DataSource)envCtx.lookup("jdbc/MySQLPool"); > } catch (Exception e){ > throw new UnavailableException(e.getMessage()); > } > } > > public void doGet(HttpServletRequest request, HttpServletResponse > response) > throws IOException, > ServletException { > > request.setCharacterEncoding("iso-8859-2"); > > > > > if (ds != null) { > Connection conn = ds.getConnection(); > if (conn != null) { > boolean isUserExists = > PortalUserDB.isUser(conn, userName, userPass); > > > conn.close(); > } > > > > } > } > > public static boolean isUser(Connection conn, String userName, String > userPass) > throws SQLException, IOException { > > String query = "SELECT user_name FROM admin_user " + > "WHERE user_name = ? " + > "AND user_pass = ?"; > > boolean isUserExists = false; > > try { > PreparedStatement pstmt = conn.prepareStatement(query); > pstmt.setString(1, userName); > pstmt.setString(2, userPass); > > ResultSet rs = pstmt.executeQuery(); > > isUserExists = rs.next(); > > rs.close(); > rs = null; > pstmt.close(); > pstmt = null; > &g
RE: Problem with ConnectionPool on Linux
Now, everything working fine. :) Thanks Jon. -Original Message- From: Jon Wingfield [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 11, 2003 4:50 PM To: Tomcat Users List Subject: Re: Problem with ConnectionPool on Linux MySql times out idle connections. If your pool implementation doesn't take care of weeding out dead connections you need to add autoReconnect=true to your connection string. HTH, Jon Veselin Kovacevic wrote: > Hi, > > I have o problem with Tomcat 4.1.24 on SuseLinux7.3. Our application > has Controller servlet (below) where using connection objects from > connection pool. When tomcat started, application working fine and > everything OK that day. But next day when we try to start application > we get error message in isUser method (PortalUserDB class). It's first > place where we use connection object in application. Method isUser is > very simple method for authenticate user (below). We get this > exception: SQL Exception:java.sql.SQLException: No operations allowed > after connection closed > > Connection object is not null in this case, and this message for me is > not correct. Next, if I restart tomcat, everything working ok... (for > next day). > > On windows (we using windows for development platform) we have not > this problem. > > What is problem? > Is configuration server.xml or similar configuration files on Linux > different rather on windows? > > Note: > On both platform we using Tomcat 4.1.24 and j2sdk1.4.1_03. > > > public class Controller extends HttpServlet { > > private DataSource ds; > > public void init(ServletConfig config) throws ServletException { > super.init(config); > try { > InitialContext initCtx = new InitialContext(); > Context envCtx = > (Context)initCtx.lookup("java:comp/env"); > ds = > (DataSource)envCtx.lookup("jdbc/MySQLPool"); > } catch (Exception e){ > throw new UnavailableException(e.getMessage()); > } > } > > public void doGet(HttpServletRequest request, HttpServletResponse > response) > throws IOException, > ServletException { > > request.setCharacterEncoding("iso-8859-2"); > > > > > if (ds != null) { > Connection conn = ds.getConnection(); > if (conn != null) { > boolean isUserExists = > PortalUserDB.isUser(conn, userName, userPass); > > > conn.close(); > } > > > > } > } > > public static boolean isUser(Connection conn, String userName, String > userPass) > throws SQLException, IOException { > > String query = "SELECT user_name FROM admin_user " + > "WHERE user_name = ? " + > "AND user_pass = ?"; > > boolean isUserExists = false; > > try { > PreparedStatement pstmt = conn.prepareStatement(query); > pstmt.setString(1, userName); > pstmt.setString(2, userPass); > > ResultSet rs = pstmt.executeQuery(); > > isUserExists = rs.next(); > > rs.close(); > rs = null; > pstmt.close(); > pstmt = null; > > } catch (SQLException sqle) { > PortalLog.addLogLine("Class: PortalUserDB, Method: > isUser. SQL Exception:" + sqle, userName); > } > > return isUserExists; > } > > Thanks, > Veso > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem with ConnectionPool on Linux
Hi, I have o problem with Tomcat 4.1.24 on SuseLinux7.3. Our application has Controller servlet (below) where using connection objects from connection pool. When tomcat started, application working fine and everything OK that day. But next day when we try to start application we get error message in isUser method (PortalUserDB class). It's first place where we use connection object in application. Method isUser is very simple method for authenticate user (below). We get this exception: SQL Exception:java.sql.SQLException: No operations allowed after connection closed Connection object is not null in this case, and this message for me is not correct. Next, if I restart tomcat, everything working ok... (for next day). On windows (we using windows for development platform) we have not this problem. What is problem? Is configuration server.xml or similar configuration files on Linux different rather on windows? Note: On both platform we using Tomcat 4.1.24 and j2sdk1.4.1_03. public class Controller extends HttpServlet { private DataSource ds; public void init(ServletConfig config) throws ServletException { super.init(config); try { InitialContext initCtx = new InitialContext(); Context envCtx = (Context)initCtx.lookup("java:comp/env"); ds = (DataSource)envCtx.lookup("jdbc/MySQLPool"); } catch (Exception e){ throw new UnavailableException(e.getMessage()); } } public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { request.setCharacterEncoding("iso-8859-2"); if (ds != null) { Connection conn = ds.getConnection(); if (conn != null) { boolean isUserExists = PortalUserDB.isUser(conn, userName, userPass); conn.close(); } } } public static boolean isUser(Connection conn, String userName, String userPass) throws SQLException, IOException { String query = "SELECT user_name FROM admin_user " + "WHERE user_name = ? " + "AND user_pass = ?"; boolean isUserExists = false; try { PreparedStatement pstmt = conn.prepareStatement(query); pstmt.setString(1, userName); pstmt.setString(2, userPass); ResultSet rs = pstmt.executeQuery(); isUserExists = rs.next(); rs.close(); rs = null; pstmt.close(); pstmt = null; } catch (SQLException sqle) { PortalLog.addLogLine("Class: PortalUserDB, Method: isUser. SQL Exception:" + sqle, userName); } return isUserExists; } Thanks, Veso - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How I can share sessions between applications?
How I can share sessions between applications on same server? Veso