|
Home > Archive > PostgreSQL JDBC > December 2005 > org.postgresql.util.PSQLException: An I/O error has occured while flushing the output
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
org.postgresql.util.PSQLException: An I/O error has occured while flushing the output
|
|
| Kishore Kolli 2005-12-08, 8:25 pm |
| Hi,
I have a web application running on Tomcat4.1, using postgresql
7.5database. Hibernate
2.1.x is being used along with jdbc driver pg74.1jdbc3.jar for mapping
database.
The application dumps the following error in the following cases:
1. The postgres process is restarted.
2. The network connection between the machine running postgres and tomcat
has been reset.
Hibernate data source property ( hibernate.connection.datasource) is being
used for identifying the database.
Any idea how to make tomcat reconnect to the database with out any problems
?
Any help is appreciated.
Thanks
Kishore Kolli
Software Engineer
Siemens
15:38:01,666 ERROR & #91;JDBCTransaction]
Begin failed
org.postgresql.util.PSQLException: An I/O error has occured while flushing
the output - Exception: java.net.SocketException: Connection reset by peer:
socket write error
Stack Trace:
java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream. socketWrite(SocketOu
tputStream.java:92)
at java.net.SocketOutputStream. write(SocketOutputSt
ream.java:136)
at java.io. BufferedOutputStream
. flushBuffer(Buffered
OutputStream.java:65)
at java.io. BufferedOutputStream
. flush(BufferedOutput
Stream.java:123)
at org.postgresql.core.PGStream.flush(PGStream.java:412)
at org.postgresql.core.QueryExecutor. sendQueryV3(QueryExe
cutor.java:339)
at org.postgresql.core.QueryExecutor. executeV3(QueryExecu
tor.java:122)
at org.postgresql.core.QueryExecutor. execute(QueryExecuto
r.java:101)
at org.postgresql.core.QueryExecutor. execute(QueryExecuto
r.java:43)
at org.postgresql.jdbc1. AbstractJdbc1Connect
ion.execSQL(
AbstractJdbc1Connect
ion.java:867)
at org.postgresql.jdbc1. AbstractJdbc1Connect
ion.setAutoCommit(
AbstractJdbc1Connect
ion.java:1258)
at org.apache.commons.dbcp. DelegatingConnection
.setAutoCommit(
DelegatingConnection
.java:266)
at
org.apache.commons.dbcp. PoolingDataSource$Po
olGuardConnectionWra
pper.setAutoCommit
(PoolingDataSource.java:338)
at net.sf.hibernate.transaction.JDBCTransaction. begin(JDBCTransactio
n.java
:44)
at net.sf.hibernate.transaction. JDBCTransactionFacto
ry.beginTransaction(
JDBCTransactionFacto
ry.java:19)
at net.sf.hibernate.impl.SessionImpl. beginTransaction(Ses
sionImpl.java
:2158)
at com.siemens.sn.phoenix.db.DbSession. beginDbTransaction(D
bSession.java
:291)
at com.siemens.sn.phoenix.db.DbSession. beginTransaction(DbS
ession.java:282)
at com.siemens.sn.phoenix.bl.ObjectMgr. getDomainObjects(Obj
ectMgr.java:49)
at com.siemens.sn.phoenix.ui.NpmBasePage. getObjectList(NpmBas
ePage.java
:1657)
at com.siemens.sn.phoenix.ui.NpmBasePage. getObjectList(NpmBas
ePage.java
:1579)
at org.apache.jsp.base_jsp. _jspService(base_jsp
.java:253)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(
JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet. serviceJspFile(JspSe
rvlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core. ApplicationFilterCha
in.internalDoFilter(
ApplicationFilterCha
in.java:247)
at org.apache.catalina.core. ApplicationFilterCha
in.doFilter(
ApplicationFilterCha
in.java:193)
at org.apache.catalina.core. StandardWrapperValve
.invoke(
StandardWrapperValve
.java:256)
at
org.apache.catalina.core. StandardPipeline$Sta
ndardPipelineValveCo
ntext.invokeNext
(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline. invoke(StandardPipel
ine.java
:480)
at org.apache.catalina.core.ContainerBase. invoke(ContainerBase
.java:995)
at org.apache.catalina.core. StandardContextValve
.invoke(
StandardContextValve
.java:191)
at
org.apache.catalina.core. StandardPipeline$Sta
ndardPipelineValveCo
ntext.invokeNext
(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline. invoke(StandardPipel
ine.java
:480)
at org.apache.catalina.core.ContainerBase. invoke(ContainerBase
.java:995)
at org.apache.catalina.core.StandardContext. invoke(StandardConte
xt.java
:2417)
at org.apache.catalina.core.StandardHostValve. invoke(StandardHostV
alve.java
:180)
at
org.apache.catalina.core. StandardPipeline$Sta
ndardPipelineValveCo
ntext.invokeNext
(StandardPipeline.java:643)
at org.apache.catalina.valves. ErrorDispatcherValve
.invoke(
ErrorDispatcherValve
.java:171)
at
org.apache.catalina.core. StandardPipeline$Sta
ndardPipelineValveCo
ntext.invokeNext
(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve. invoke(ErrorReportVa
lve.java
:172)
at
org.apache.catalina.core. StandardPipeline$Sta
ndardPipelineValveCo
ntext.invokeNext
(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline. invoke(StandardPipel
ine.java
:480)
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$Sta
ndardPipelineValveCo
ntext.invokeNext
(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline. invoke(StandardPipel
ine.java
:480)
at org.apache.catalina.core.ContainerBase. invoke(ContainerBase
.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter. service(CoyoteAdapte
r.java:193)
at org.apache.coyote.http11.Http11Processor. process(Http11Proces
sor.java
:781)
at
org.apache.coyote.http11. Http11Protocol$Http1
1ConnectionHandler.processConnection
(Http11Protocol.java:549)
at org.apache.tomcat.util.net.TcpWorkerThread. runIt(PoolTcpEndpoin
t.java
:589)
at org.apache.tomcat.util.threads. ThreadPool$ControlRu
nnable.run(
ThreadPool.java:666)
at java.lang.Thread.run(Thread.java:595)
End of Stack Trace
at org.postgresql.core.PGStream.flush(PGStream.java:416)
at org.postgresql.core.QueryExecutor. sendQueryV3(QueryExe
cutor.java:339)
at org.postgresql.core.QueryExecutor. executeV3(QueryExecu
tor.java:122)
at org.postgresql.core.QueryExecutor. execute(QueryExecuto
r.java:101)
at org.postgresql.core.QueryExecutor. execute(QueryExecuto
r.java:43)
at org.postgresql.jdbc1. AbstractJdbc1Connect
ion.execSQL(
AbstractJdbc1Connect
ion.java:867)
at org.postgresql.jdbc1. AbstractJdbc1Connect
ion.setAutoCommit(
AbstractJdbc1Connect
ion.java:1258)
at org.apache.commons.dbcp. DelegatingConnection
.setAutoCommit(
DelegatingConnection
.java:266)
at
org.apache.commons.dbcp. PoolingDataSource$Po
olGuardConnectionWra
pper.setAutoCommit
(PoolingDataSource.java:338)
at net.sf.hibernate.transaction.JDBCTransaction. begin(JDBCTransactio
n.java
:44)
at net.sf.hibernate.transaction. JDBCTransactionFacto
ry.beginTransaction(
JDBCTransactionFacto
ry.java:19)
at net.sf.hibernate.impl.SessionImpl. beginTransaction(Ses
sionImpl.java
:2158)
at com.siemens.sn.phoenix.db.DbSession. beginDbTransaction(D
bSession.java
:291)
at com.siemens.sn.phoenix.db.DbSession. beginTransaction(DbS
ession.java:282)
at com.siemens.sn.phoenix.bl.ObjectMgr. getDomainObjects(Obj
ectMgr.java:49)
at com.siemens.sn.phoenix.ui.NpmBasePage. getObjectList(NpmBas
ePage.java
:1657)
at com.siemens.sn.phoenix.ui.NpmBasePage. getObjectList(NpmBas
ePage.java
:1579)
at org.apache.jsp.base_jsp. _jspService(base_jsp
.java:253)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(
JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet. serviceJspFile(JspSe
rvlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core. ApplicationFilterCha
in.internalDoFilter(
ApplicationFilterCha
in.java:247)
at org.apache.catalina.core. ApplicationFilterCha
in.doFilter(
ApplicationFilterCha
in.java:193)
at org.apache.catalina.core. StandardWrapperValve
.invoke(
StandardWrapperValve
.java:256)
at
org.apache.catalina.core. StandardPipeline$Sta
ndardPipelineValveCo
ntext.invokeNext
(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline. invoke(StandardPipel
ine.java
:480)
at org.apache.catalina.core.ContainerBase. invoke(ContainerBase
.java:995)
at org.apache.catalina.core. StandardContextValve
.invoke(
StandardContextValve
.java:191)
at
org.apache.catalina.core. StandardPipeline$Sta
ndardPipelineValveCo
ntext.invokeNext
(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline. invoke(StandardPipel
ine.java
:480)
at org.apache.catalina.core.ContainerBase. invoke(ContainerBase
.java:995)
at org.apache.catalina.core.StandardContext. invoke(StandardConte
xt.java
:2417)
at org.apache.catalina.core.StandardHostValve. invoke(StandardHostV
alve.java
:180)
at
org.apache.catalina.core. StandardPipeline$Sta
ndardPipelineValveCo
ntext.invokeNext
(StandardPipeline.java:643)
at org.apache.catalina.valves. ErrorDispatcherValve
.invoke(
ErrorDispatcherValve
.java:171)
at
org.apache.catalina.core. StandardPipeline$Sta
ndardPipelineValveCo
ntext.invokeNext
(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve. invoke(ErrorReportVa
lve.java
:172)
at
org.apache.catalina.core. StandardPipeline$Sta
ndardPipelineValveCo
ntext.invokeNext
(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline. invoke(StandardPipel
ine.java
:480)
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$Sta
ndardPipelineValveCo
ntext.invokeNext
(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline. invoke(StandardPipel
ine.java
:480)
at org.apache.catalina.core.ContainerBase. invoke(ContainerBase
.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter. service(CoyoteAdapte
r.java:193)
at org.apache.coyote.http11.Http11Processor. process(Http11Proces
sor.java
:781)
at
org.apache.coyote.http11. Http11Protocol$Http1
1ConnectionHandler.processConnection
(Http11Protocol.java:549)
at org.apache.tomcat.util.net.TcpWorkerThread. runIt(PoolTcpEndpoin
t.java
:589)
at org.apache.tomcat.util.threads. ThreadPool$ControlRu
nnable.run(
ThreadPool.java:666)
at java.lang.Thread.run(Thread.java:595)
| |
| Jonathan Fuerth 2005-12-09, 8:25 pm |
| On Dec 8, 2005, at 4:58 PM, Kishore Kolli wrote:
> _The application dumps the following error in the following cases:
> __ 1. The postgres process is restarted.
> __ 2. The network connection between the machine running postgres and
> tomcat has been reset.
> [...]_
> Any idea how to make tomcat reconnect to the database with out any
> problems ?
> _
It's not a Postgres specific answer, but here's an answer nonetheless:
It appears from the stack trace that you are using the Jakarta Commons
DBCP package. If you set a validationQuery on your connection pool,
the pool manager will automatically test your database connections
before giving them to Hibernate. If you have had a network outage or
server restart, the pooled connections will fail that test, and the
DBCP will dump those broken connections and open new ones before
returning them to Hibernate.
For your validation, pick a simple query that is guaranteed to return
at least one row, but will not be expensive to execute (because it will
be executed frequently!). For example, you could use "SELECT now()",
which doesn't even require disk access.
See http://jakarta.apache.org/commons/d...figuration.html for
details on DBCP configuration.
-Jonathan
| |
| Kishore Kolli 2005-12-12, 1:24 pm |
| Thanks a bunch.. That worked.
-kishore
On 12/9/05, Jonathan Fuerth <fuerth@sqlpower.ca> wrote:
>
> On Dec 8, 2005, at 4:58 PM, Kishore Kolli wrote:
>
>
> It's not a Postgres specific answer, but here's an answer nonetheless:
>
> It appears from the stack trace that you are using the Jakarta Commons
> DBCP package. If you set a validationQuery on your connection pool,
> the pool manager will automatically test your database connections
> before giving them to Hibernate. If you have had a network outage or
> server restart, the pooled connections will fail that test, and the
> DBCP will dump those broken connections and open new ones before
> returning them to Hibernate.
>
> For your validation, pick a simple query that is guaranteed to return
> at least one row, but will not be expensive to execute (because it will
> be executed frequently!). For example, you could use "SELECT now()",
> which doesn't even require disk access.
>
> See http://jakarta.apache.org/commons/d...figuration.html for
> details on DBCP configuration.
>
> -Jonathan
>
|
|
|
|
|