# MySQL/Tomcat mit java.net.SocketException "Broken Pipe&



## Marsman (14. Nov 2007)

Hallo Ihr!

Ich habe ein kleines Gästebuch mittels JSP Taglibs, MySQL und Tomcat JConnector programmiert. Es funktioniert auch soweit ganz gut. Allerdings habe ich beim Aufruf im Browser in unregelmäßigen Abständen die Exception "java.net.SocketException Broken Pipe". Leider habe ich dafür keine Erklärung und wäre froh, wenn mir da mal jemand einen Tipp geben könnte.

Das ganze läuft auf meinem VServer mit Debian Linux, Tomcat 5.5.25, JDK 5.0, MySQL Connector 5.0.7 und Java JSTL.

Hier der StackTrace:


```
org.apache.jasper.JasperException: javax.servlet.jsp.JspException: 
		      select * from usr_web1_1.mt_comment where comment_visible = 1 order by comment_created_on desc
		    : Communications link failure due to underlying exception: 

** BEGIN NESTED EXCEPTION ** 

java.net.SocketException
MESSAGE: Broken pipe

STACKTRACE:

java.net.SocketException: Broken pipe
	at java.net.SocketOutputStream.socketWrite0(Native Method)
	at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
	at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
	at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
	at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
	at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2744)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1612)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
	at com.mysql.jdbc.Connection.execSQL(Connection.java:3256)
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1313)
	at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1448)
	at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
	at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doEndTag(QueryTagSupport.java:215)
	at org.apache.jsp.index_jsp._jspx_meth_sql_005fquery_005f0(index_jsp.java:223)
	at org.apache.jsp.index_jsp._jspService(index_jsp.java:142)
	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.valves.AccessLogValve.invoke(AccessLogValve.java:544)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
	at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
	at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
	at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:773)
	at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
	at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:895)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
	at java.lang.Thread.run(Thread.java:595)
** END NESTED EXCEPTION **

Last packet sent to the server was 35 ms ago.
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
```


Und hier meine Tomcat-Konfiguration:



```
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="guestbook" path="/guestbook">
	<Resource name="jdbc/GuestbookDB" auth="Container"
		type="javax.sql.DataSource" maxActive="10" maxIdle="5" username="..."
		password="..." driverClassName="com.mysql.jdbc.Driver"
		url="jdbc:mysql://localhost:3306/usr_web1_1" />
</Context>
```


Und noch der Deployment-Descriptor:


```
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
	xmlns="http://java.sun.com/xml/ns/j2ee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	<display-name>Guestbook</display-name>
	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
		<welcome-file>index.htm</welcome-file>
		<welcome-file>index.jsp</welcome-file>
		<welcome-file>default.html</welcome-file>
		<welcome-file>default.htm</welcome-file>
		<welcome-file>default.jsp</welcome-file>
	</welcome-file-list>
	<resource-ref>
	    <description>DB Connection</description>
	    <res-ref-name>jdbc/GuestbookDB</res-ref-name>
	    <res-type>javax.sql.DataSource</res-type>
	    <res-auth>Container</res-auth>
	</resource-ref>
	<jsp-config>
		<taglib>
			<taglib-uri>http://www.mydomain.de/guestbook/</taglib-uri>
			<taglib-location>/WEB-INF/tld/guestbook.tld</taglib-location>
		</taglib>
	</jsp-config>
</web-app>
```


Titus


----------



## happy_robot (17. Apr 2008)

die exception kommt wenn mysql die verbindung schliesst.

diese werte (in sec) werden über die parameter

- interactive_timeout
- wait_timeout

gesetzt. schau mal im admin nach.


----------

