I have J2EE application running on OC4J application server. Where the database connection is dropping / resetting after some idle time. The idle time varies from 20 mins to 90 mins. The persistence layer is created using Spring and iBatis with Struts as controller.
I am not able to find that why the code / oracle database is trying to close the connection before it makes new one.
Here is the exception log:
[05 Oct 2009 11:55:38] DEBUG [SQLErrorCodesFactory] Looking up default SQLErrorCodes for DataSource [org.springframework.jdbc.
datasource
.Transacti
onAwareDat
aSourcePro
xy@13478c8
]
[05 Oct 2009 11:55:38] DEBUG [DataSourceUtils] Fetching JDBC Connection from DataSource
[05 Oct 2009 11:55:38] DEBUG [DataSourceUtils] Fetching JDBC Connection from DataSource
[05 Oct 2009 11:55:38] DEBUG [DataSourceUtils] Returning JDBC Connection to DataSource
[05 Oct 2009 11:55:38] DEBUG [DataSourceUtils] Returning JDBC Connection to DataSource
[05 Oct 2009 11:55:38] DEBUG [SQLErrorCodesFactory] Database product name cached for DataSource [org.springframework.jdbc.
datasource
.Transacti
onAwareDat
aSourcePro
xy@13478c8
]: name is 'Oracle'
[05 Oct 2009 11:55:38] DEBUG [SQLErrorCodesFactory] SQL error codes for 'Oracle' found
[05 Oct 2009 11:55:38] DEBUG [SQLErrorCodeSQLExceptionT
ranslator]
Translating SQLException with SQL state '08006', error code '17002', message [
--- The error occurred in org/nexweb/qol/gcc/ibatis/
dao/xml/Us
er.xml.
--- The error occurred while applying a parameter map.
--- Check the getUserByUserNameAndRealmN
ame-Inline
ParameterM
ap.
--- Check the statement (query failed).
--- Cause: java.sql.SQLException: Io exception: Connection reset by peer: socket write error]; SQL was [] for task [SqlMapClient operation]
[05 Oct 2009 11:55:38] DEBUG [DataSourceUtils] Returning JDBC Connection to DataSource
[05 Oct 2009 11:55:38] DEBUG [UserSqlMapDAO] Could not close JDBC Connection
java.sql.SQLException: Already closed.
at org.apache.commons.dbcp.Po
olableConn
ection.clo
se(Poolabl
eConnectio
n.java:84)
at org.apache.commons.dbcp.Po
olingDataS
ource$Pool
GuardConne
ctionWrapp
er.close(P
oolingData
Source.jav
a:181)
at org.springframework.jdbc.d
atasource.
DataSource
Utils.doRe
leaseConne
ction(Data
SourceUtil
s.java:313
)
at org.springframework.jdbc.d
atasource.
Transactio
nAwareData
SourceProx
y$Transact
ionAwareIn
vocationHa
ndler.invo
ke(Transac
tionAwareD
ataSourceP
roxy.java:
166)
at $Proxy0.close(Unknown Source)
at org.springframework.orm.ib
atis.SqlMa
pClientTem
plate.exec
ute(SqlMap
ClientTemp
late.java:
218)
at org.springframework.orm.ib
atis.SqlMa
pClientTem
plate.quer
yForObject
(SqlMapCli
entTemplat
e.java:271
)
at org.nexweb.qol.gcc.ibatis.
dao.sqlmap
s.UserSqlM
apDAO.getU
serByUserN
ameAndReal
mName(User
SqlMapDAO.
java:26)
at org.nexweb.qol.gcc.ibatis.
services.U
serService
.getUserBy
UserNameAn
dRealmName
(UserServi
ce.java:30
)
at org.nexweb.qol.gcc.actions
.WelcomeAc
tion.execu
te(Welcome
Action.jav
a:71)
at org.apache.struts.chain.co
mmands.ser
vlet.Execu
teAction.e
xecute(Exe
cuteAction
.java:58)
at org.apache.struts.chain.co
mmands.Abs
tractExecu
teAction.e
xecute(Abs
tractExecu
teAction.j
ava:67)
at org.apache.struts.chain.co
mmands.Act
ionCommand
Base.execu
te(ActionC
ommandBase
.java:51)
at org.apache.commons.chain.i
mpl.ChainB
ase.execut
e(ChainBas
e.java:190
)
at org.apache.commons.chain.g
eneric.Loo
kupCommand
.execute(L
ookupComma
nd.java:30
4)
at org.apache.commons.chain.i
mpl.ChainB
ase.execut
e(ChainBas
e.java:190
)
at org.apache.struts.chain.Co
mposableRe
questProce
ssor.proce
ss(Composa
bleRequest
Processor.
java:283)
at org.apache.struts.action.A
ctionServl
et.process
(ActionSer
vlet.java:
1913)
at org.apache.struts.action.A
ctionServl
et.doGet(A
ctionServl
et.java:44
9)
at javax.servlet.http.HttpSer
vlet.servi
ce(HttpSer
vlet.java:
743)
at javax.servlet.http.HttpSer
vlet.servi
ce(HttpSer
vlet.java:
856)
at com.evermind.server.http.S
ervletRequ
estDispatc
her.invoke
(ServletRe
questDispa
tcher.java
:713)
at com.evermind.server.http.S
ervletRequ
estDispatc
her.forwar
dInternal(
ServletReq
uestDispat
cher.java:
370)
at com.evermind.server.http.S
ervletRequ
estDispatc
her.unpriv
ileged_for
ward(Servl
etRequestD
ispatcher.
java:259)
at com.evermind.server.http.S
ervletRequ
estDispatc
her.access
$100(Servl
etRequestD
ispatcher.
java:51)
at com.evermind.server.http.S
ervletRequ
estDispatc
her$2.oc4j
Run(Servle
tRequestDi
spatcher.j
ava:193)
at oracle.oc4j.security.OC4JS
ecurity.do
Privileged
(OC4JSecur
ity.java:2
83)
at com.evermind.server.http.S
ervletRequ
estDispatc
her.forwar
d(ServletR
equestDisp
atcher.jav
a:198)
at com.evermind.server.http.E
vermindPag
eContext.f
orward(Eve
rmindPageC
ontext.jav
a:392)
at _jsp._forward._jspService(
_forward.j
ava:48)
at com.orionserver.http.Orion
HttpJspPag
e.service(
OrionHttpJ
spPage.jav
a:59)
at oracle.jsp.runtimev2.JspPa
geTable.se
rvice(JspP
ageTable.j
ava:462)
at oracle.jsp.runtimev2.JspSe
rvlet.inte
rnalServic
e(JspServl
et.java:59
4)
at oracle.jsp.runtimev2.JspSe
rvlet.serv
ice(JspSer
vlet.java:
518)
at javax.servlet.http.HttpSer
vlet.servi
ce(HttpSer
vlet.java:
856)
at com.evermind.server.http.S
ervletRequ
estDispatc
her.invoke
(ServletRe
questDispa
tcher.java
:713)
at com.evermind.server.http.S
ervletRequ
estDispatc
her.forwar
dInternal(
ServletReq
uestDispat
cher.java:
370)
at com.evermind.server.http.H
ttpRequest
Handler.do
ProcessReq
uest(HttpR
equestHand
ler.java:8
71)
at com.evermind.server.http.H
ttpRequest
Handler.pr
ocessReque
st(HttpReq
uestHandle
r.java:453
)
at com.evermind.server.http.H
ttpRequest
Handler.se
rveOneRequ
est(HttpRe
questHandl
er.java:22
1)
at com.evermind.server.http.H
ttpRequest
Handler.ru
n(HttpRequ
estHandler
.java:122)
at com.evermind.server.http.H
ttpRequest
Handler.ru
n(HttpRequ
estHandler
.java:111)
at oracle.oc4j.network.Server
SocketRead
Handler$Sa
feRunnable
.run(Serve
rSocketRea
dHandler.j
ava:260)
at com.evermind.util.Releasab
leResource
PooledExec
utor$MyWor
ker.run(Re
leasableRe
sourcePool
edExecutor
.java:303)
at java.lang.Thread.run(Threa
d.java:595
)
Here is the Spring.xml code related to datasource