Hallo zusammen,
ich benutze eine PostgreSQL DB und SPring JDBCTemplate um meine DB-Operationen durchzuführen.
Bei einer DB-Operation bekam ich dann diese Exception hier:
org.postgresql.util.PSQLException: FATAL: sorry, too many clients already
Die Exception deutet darauf hin, dass ich meine Verbindungen nicht ordentlich schließe und zu viele Verbindungen nach der Transaktion bestehen bleiben. Allerdings dachte ich, dass Spring dies für mich erledigt... deswegen hab ich mich ja dafür entschieden. Damit ich den ganzen boiler plate code los werde.
Meine Config sieht so aus:
[XML]
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbcostgresql://localhost:5432/zeitfenster"/>
<property name="username" value="xxxx"/>
<property name="password" value="xxxxx"/>
<property name="initialSize" value="1"/>
<property name="maxActive" value="20"/>
<property name="maxIdle" value="10"/>
<property name="minIdle" value="5"/>
<property name="maxWait" value="-1"/>
<property name="minEvictableIdleTimeMillis" value="600000"/>
<property name="poolPreparedStatements" value="false"/>
</bean>
<bean id="userDAO" class="de.als.zeitfenster.user.UserDAO">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="loginDAO" class="de.als.zeitfenster.application.login.LoginDAO">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="appointmentDAO" class="de.als.zeitfenster.customerarea.AppointmentDAO">
<property name="dataSource" ref="dataSource"/>
</bean>
</beans>
[/XML]
Komplette Stacktrace:
Ich weiß nicht aus welchem Grund die Exception geworfen wird und bin auch kein großer Datenbank-Konfigurations-Experte ... deshalb weiß ich auch nicht weiter und bitte um Hilfe.
Falls noch Informationen fehlen, sagt mir bitte Bescheid.
Weiß jemand von euch vielleicht Rat?
Vorab schon einmal vielen Dank und einen schönen Abend noch
Edfred
ich benutze eine PostgreSQL DB und SPring JDBCTemplate um meine DB-Operationen durchzuführen.
Bei einer DB-Operation bekam ich dann diese Exception hier:
org.postgresql.util.PSQLException: FATAL: sorry, too many clients already
Die Exception deutet darauf hin, dass ich meine Verbindungen nicht ordentlich schließe und zu viele Verbindungen nach der Transaktion bestehen bleiben. Allerdings dachte ich, dass Spring dies für mich erledigt... deswegen hab ich mich ja dafür entschieden. Damit ich den ganzen boiler plate code los werde.
Meine Config sieht so aus:
[XML]
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbcostgresql://localhost:5432/zeitfenster"/>
<property name="username" value="xxxx"/>
<property name="password" value="xxxxx"/>
<property name="initialSize" value="1"/>
<property name="maxActive" value="20"/>
<property name="maxIdle" value="10"/>
<property name="minIdle" value="5"/>
<property name="maxWait" value="-1"/>
<property name="minEvictableIdleTimeMillis" value="600000"/>
<property name="poolPreparedStatements" value="false"/>
</bean>
<bean id="userDAO" class="de.als.zeitfenster.user.UserDAO">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="loginDAO" class="de.als.zeitfenster.application.login.LoginDAO">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="appointmentDAO" class="de.als.zeitfenster.customerarea.AppointmentDAO">
<property name="dataSource" ref="dataSource"/>
</bean>
</beans>
[/XML]
Komplette Stacktrace:
Code:
Sep 09, 2012 8:09:58 PM org.apache.myfaces.renderkit.ErrorPageWriter handleThrowable
Schwerwiegend: An exception occurred
javax.faces.FacesException: java.lang.reflect.InvocationTargetException
at org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.wrap(ExceptionHandlerImpl.java:241)
at org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:156)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:258)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191)
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:225)
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:927)
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:999)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor52.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at javax.faces.component._ComponentAttributesMap.getComponentProperty(_ComponentAttributesMap.java:402)
at javax.faces.component._ComponentAttributesMap.get(_ComponentAttributesMap.java:234)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.isDisabled(HtmlRendererUtils.java:199)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlLinkRendererBase.renderCommandLinkEnd(HtmlLinkRendererBase.java:952)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlLinkRendererBase.encodeEnd(HtmlLinkRendererBase.java:193)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:519)
at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChild(RendererUtils.java:543)
at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChildren(RendererUtils.java:520)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlGroupRendererBase.encodeEnd(HtmlGroupRendererBase.java:92)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:519)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:618)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:614)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:614)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:614)
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1159)
at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:263)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:85)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239)
... 17 more
Caused by: javax.el.ELException: /customerarea/customer_area.xhtml at line 74 and column 63 disabled="#{dateBookingBean.isBooked('wednesday')}": org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (FATAL: sorry, too many clients already)
at org.apache.myfaces.view.facelets.el.TagValueExpression.getValue(TagValueExpression.java:93)
at javax.faces.component._DeltaStateHelper.eval(_DeltaStateHelper.java:260)
at javax.faces.component.html.HtmlCommandLink.isDisabled(HtmlCommandLink.java:88)
... 38 more
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (FATAL: sorry, too many clients already)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:82)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:572)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:636)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:665)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:673)
at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:716)
at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:727)
at org.springframework.jdbc.core.JdbcTemplate.queryForInt(JdbcTemplate.java:754)
at de.als.zeitfenster.customerarea.AppointmentDAO.bookedDate(AppointmentDAO.java:64)
at de.als.zeitfenster.customerarea.DateBookingBean.isBooked(DateBookingBean.java:118)
at sun.reflect.GeneratedMethodAccessor61.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at javax.el.BeanELResolver.invoke(BeanELResolver.java:484)
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:161)
at org.apache.el.parser.AstValue.getValue(AstValue.java:159)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
at org.apache.myfaces.view.facelets.el.TagValueExpression.getValue(TagValueExpression.java:85)
... 40 more
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (FATAL: sorry, too many clients already)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
... 57 more
Caused by: org.postgresql.util.PSQLException: FATAL: sorry, too many clients already
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:291)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:106)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:64)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:123)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:28)
at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:20)
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:30)
at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:22)
at org.postgresql.Driver.makeConnection(Driver.java:391)
at org.postgresql.Driver.connect(Driver.java:265)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)
at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1221)
... 60 more
Ich weiß nicht aus welchem Grund die Exception geworfen wird und bin auch kein großer Datenbank-Konfigurations-Experte ... deshalb weiß ich auch nicht weiter und bitte um Hilfe.
Falls noch Informationen fehlen, sagt mir bitte Bescheid.
Weiß jemand von euch vielleicht Rat?
Vorab schon einmal vielen Dank und einen schönen Abend noch
Edfred
Zuletzt bearbeitet: