PostgreSQL Exception too ...many clients already bei DB-Abfrage

edfred

Mitglied
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="jdbc:postgresql://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:

mla.rue

Bekanntes Mitglied
Auch wenn man die Verbindungen schließen sollte, kümmert sich PSQL selbst drum, jede für ein paar Sekundne inaktive Verbindung wird geschlossen udn gut ist.

Schaue ersteinmal ob Zugriffe via TCP/IP (pg_hba.conf) erlaubt sind.
Schaue dann in postgresql.conf, oberes drittel "max_connection = x", kenne mich mit dem Apache Zeug nicht aus und obs irgendwelche Einstellungen überschreibt, wenn aber nein und da eine 0 steht, kanns ja nicht gehen.
Deine Verbindung definierst du mit org.postgresql.ds.PGPoolingDataSource
 

edfred

Mitglied
Hi, danke für deine Hinweise.
Wenn ich nun deine Verbindung nehme:
[XML]
<bean id="dataSource" destroy-method="close" class="org.postgresql.ds.PGPoolingDataSource">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbc:postgresql://localhost:5432/zeitfenster"/>
<property name="username" value="postgres"/>
<property name="password" value="Zeitfenster001"/>
<!--<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="maxOpenPreparedStatements" value="50"/>-->
<!--<property name="poolPreparedStatements" value="false"/>-->
</bean>
[/XML]

Dann bekomme ich beim Starten der Apllikation diese Exception.

Code:
javax.faces.el.EvaluationException: javax.el.ELException: /application/login.xhtml at line 29 and column 48 action="#{loginBean.loginAction}": org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [conf/beans.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'driverClassName' of bean class [org.postgresql.ds.PGPoolingDataSource]: Bean property 'driverClassName' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
	at javax.faces.component._MethodExpressionToMethodBinding.invoke(_MethodExpressionToMethodBinding.java:96)
	at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:100)
	at javax.faces.component.UICommand.broadcast(UICommand.java:120)
	at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:937)
	at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:271)
	at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1249)
	at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:675)
	at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:34)
	at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171)
	at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
	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: javax.el.ELException: /application/login.xhtml at line 29 and column 48 action="#{loginBean.loginAction}": org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [conf/beans.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'driverClassName' of bean class [org.postgresql.ds.PGPoolingDataSource]: Bean property 'driverClassName' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
	at org.apache.myfaces.view.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:95)
	at javax.faces.component._MethodExpressionToMethodBinding.invoke(_MethodExpressionToMethodBinding.java:88)
	... 26 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [conf/beans.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'driverClassName' of bean class [org.postgresql.ds.PGPoolingDataSource]: Bean property 'driverClassName' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1278)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1011)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:475)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:412)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:383)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:276)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:273)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:175)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:485)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:716)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:377)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
	at de.als.zeitfenster.application.login.LoginBean.loginAction(LoginBean.java:45)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.apache.el.parser.AstValue.invoke(AstValue.java:264)
	at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
	at org.apache.myfaces.view.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:83)
	... 27 more
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'driverClassName' of bean class [org.postgresql.ds.PGPoolingDataSource]: Bean property 'driverClassName' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:787)
	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:643)
	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1275)

Ich finde leider auch keine Beispielkonfiguration für postgreSQL ...

Findest du vielleicht eine?

Viele Grüße

Edfeed
 

mla.rue

Bekanntes Mitglied
also das: org.postgresql.ds.PGPoolingDataSource
ist die Treiberklasse die du nutzt, wenn Pooling verwenden möchtest, sollte also wohl unter
[xml]
<property name="driverClassName" value=
[/xml]
stehen.

was du unter bean id stehen haben musst kA, kenne mich wie gesagt mit Apache oder was auch immer du da benutzt nicht aus. Da könnte aber PGPoolingDataSource oder Jdbc3PoolingDataSource stehen, wäre das einzige, was man im Quellcode reinschreiben muss, wenn man Pooling verwenden möchte.

Der Rest sind die üblichen Properties.

postgres ist der superuser von psql, solltest du nicht wirklich benutzen. Lege dir dazu einen regulären Nutzer an, einen der alles kann, nur halt kein SU ist.
 

edfred

Mitglied
Also "org.postgresql.ds.PGPoolingDataSource" ist sicherlich nicht die Treiberklasse. Der Name sagt ja schon alles. Dies muss die Klasse sein, die die DataSource mappt. Ich benutze Spring JDBCTemplates und die DataSource wird via DI injiziiert.
Die Exception sagt ja auch nur, dass die property "driverClassName" nicht bekannt ist. Leider habe ich keine Ahnung wie die Property heißt und im Netz finde ich leider auch keine Beispiel DataSource.

postgres ist der superuser von psql, solltest du nicht wirklich benutzen. Lege dir dazu einen regulären Nutzer an, einen der alles kann, nur halt kein SU ist.

Ja, ich weiß Sicherheitsrisiko und so. Ich benutz den nur für die Entwicklung.:D
 

edfred

Mitglied
Ich habe jetzt gerade noch etwas ausprobiert und zwar c3p0
Das ist die Config-XML
[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="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="org.postgresql.Driver"/>
<property name="jdbcUrl" value="jdbc:postgresql://localhost:5432/zeitfenster"/>
<property name="user" value="postgres"/>
<property name="password" value="Zeitfenster001"/>
<property name="initialPoolSize" value="1" />
<property name="minPoolSize" value="1" />
<property name="maxPoolSize" value="5" />
<!-- seconds to wait after a large spike in connections to cull pool back down to min size -->
<property name="maxIdleTimeExcessConnections" value="599" />
<!-- ms to wait for a connection when the pool is exhausted -->
<property name="checkoutTimeout" value="60000" />
<!-- attempts to acquire a new db connection before giving up -->
<property name="acquireRetryAttempts" value="6" />
<!-- test idle connections every n seconds -->
<property name="idleConnectionTestPeriod" value="600" />
<property name="preferredTestQuery" value="select 1" />
</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>
[/XML]

Die Exception, die ich dann leider bekomme, ist die folgende:
Code:
javax.faces.FacesException: Could not get property disabled of component j_id1127192655_57ce788c:j_id1127192655_57ce7bc1
	at javax.faces.component._ComponentAttributesMap.getComponentProperty(_ComponentAttributesMap.java:407)
	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.renderCommandLinkStart(HtmlLinkRendererBase.java:230)
	at org.apache.myfaces.shared_impl.renderkit.html.HtmlLinkRendererBase.encodeBegin(HtmlLinkRendererBase.java:133)
	at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:442)
	at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChild(RendererUtils.java:534)
	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)
	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.GeneratedMethodAccessor64.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)
	... 34 more
Caused by: javax.el.ELException: /customerarea/customer_area.xhtml at line 177 and column 63 disabled="#{dateBookingBean.isBooked('wednesday')}": org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!
	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 java.sql.SQLException: Connections could not be acquired from the underlying database!
	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:77)
	at de.als.zeitfenster.customerarea.DateBookingBean.isBooked(DateBookingBean.java:129)
	at sun.reflect.GeneratedMethodAccessor144.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: java.sql.SQLException: Connections could not be acquired from the underlying database!
	at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:641)
	at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
	... 57 more
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
	at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1406)
	at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:594)
	at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:514)
	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:707)
	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:634)
	... 60 more

Sep 10, 2012 9:44:00 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.GeneratedMethodAccessor64.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.renderCommandLinkStart(HtmlLinkRendererBase.java:230)
	at org.apache.myfaces.shared_impl.renderkit.html.HtmlLinkRendererBase.encodeBegin(HtmlLinkRendererBase.java:133)
	at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:442)
	at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChild(RendererUtils.java:534)
	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 177 and column 63 disabled="#{dateBookingBean.isBooked('wednesday')}": org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!
	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 java.sql.SQLException: Connections could not be acquired from the underlying database!
	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:77)
	at de.als.zeitfenster.customerarea.DateBookingBean.isBooked(DateBookingBean.java:129)
	at sun.reflect.GeneratedMethodAccessor144.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: java.sql.SQLException: Connections could not be acquired from the underlying database!
	at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:641)
	at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
	... 57 more
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
	at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1406)
	at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:594)
	at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:514)
	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:707)
	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:634)
	... 60 more

Ich konnte mich aber schon einloggen, d.h. ich habe eine Anfrage an die DB schicken können...
Bei den nächsten Anfragen gab es dann die Exception...
 

mla.rue

Bekanntes Mitglied
Java:
Connection conn = null;

Class.forName("org.postgresql.ds.PGPoolingDataSource");
PGPoolingDataSource source = new PGPoolingDataSource();
source.setDataSourceName("Datenquelle");
source.setServerName("127.0.0.1:5432");
source.setDatabaseName("dbname");
source.setUser("posql");
source.setPassword("");
source.setInitialConnections(5);
source.setMaxConnections(10);

conn = source.getConnection();

und das postgresql-9.1-902.jdbc4.jar eingebunden und es läuft
 

edfred

Mitglied
Ok, ich hab es jetzt so, dass es klappt... Einloggen kann ich mich jetzt schon :)

Allerdings habe ich immer noch diese Exception wenn andere Abfragen auf der DB geschehen:
Code:
Sep 11, 2012 8:23:32 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 146 and column 60 disabled="#{dateBookingBean.isBooked('friday')}": org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.postgresql.util.PSQLException: 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.postgresql.util.PSQLException: 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:77)
	at de.als.zeitfenster.customerarea.DateBookingBean.isBooked(DateBookingBean.java:137)
	at sun.reflect.GeneratedMethodAccessor66.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.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 java.sql.DriverManager.getConnection(DriverManager.java:579)
	at java.sql.DriverManager.getConnection(DriverManager.java:221)
	at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:90)
	at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:73)
	at org.postgresql.ds.jdbc23.AbstractJdbc23ConnectionPoolDataSource.getPooledConnection(AbstractJdbc23ConnectionPoolDataSource.java:58)
	at org.postgresql.ds.jdbc23.AbstractJdbc23PoolingDataSource.initialize(AbstractJdbc23PoolingDataSource.java:297)
	at org.postgresql.ds.jdbc23.AbstractJdbc23PoolingDataSource.getConnection(AbstractJdbc23PoolingDataSource.java:352)
	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
	... 57 more

Meine Config sieht nun 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.postgresql.ds.PGPoolingDataSource">
<!--<property name="driverClassName" value="org.postgresql.Driver"/>-->
<property name="serverName" value="localhost:5432"/>
<property name="databaseName" value="zeitfenster"/>
<property name="user" value="XxxxxxxX"/>
<property name="password" value="x"/>
<property name="initialConnections" value="5"/>
<property name="maxConnections" value="10"/>
</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]
Meine Driver lib: postgresql-9.1-902.jdbc4.jar

Ich bin ratlos ...
 
M

maki

Gast
Wieviele Connections nimmt der Server denn nun an? (max_connections in postgre.conf)

Wäre interessant zu wissen wann & wieviele Connections geöffnet/geschlossen werden.
Ändert sich denn was ohne Connection Pooling?
Möglicherweise steckt ja der Fehler im Java Code und nicht in der Config.
 

edfred

Mitglied
Hallo maki,

danke für deine Hilfe.
max_connections steht in meiner postgresql.conf auf 100.
Wie kann ich denn kontrollieren wann und wieviele Connections geschlossen werden? Benutze übrigens Postgres auf einen macBook mit OS X - das nur so nebenbei...(falls das einen Unterschied ausmacht).
Ohne Connection Pooling habe ich dasselbe Problem. Deswegen bin ich auf die Idee des Poolings gekommen....was mir auch nichts bringt, so wie es ausschaut. ???:L

Ja, das kann gut möglich sein, dass es am Code liegt aber da ich Spring JDBC Templates benutze, ist das etwas schwierig nachzuvollziehen, da Spring das schließen der Connections, Statemennts, usw. übernimmt. Ein Grund warum ich Spring genommen habe.

Ich weiß gar nicht welche Stelle vom Quellcode ich euch soll bzw. welche Quellcodestelle hilfreich wäre....

Vielleicht diese hier...ich meine der Fehler passiert genau hier:
Java:
public class AppointmentDAO implements Serializable {
//...
private static final String SELECT_BOOKED_DATE = 
			"SELECT count(*) FROM " + ZEITFENSTER_TABLE_NAME + " z where z." + TERMIN_TERMIN_VON 
			+ " = ? AND z." + TERMIN_GEBUCHT + "= TRUE";

/**
	 * Überprüft, ob der Termin gebucht wurde oder nicht.
	 * 
	 * @param date - Anfangszeit des zu überprüfenden Termins.
	 * @return true, wenn der Termin gebucht wurde, ansonsten false.
	 */
	public boolean bookedDate(String date) {
		final SimpleDateFormat formatter = new SimpleDateFormat(DATE_PATTERN);
		Date dateToCheck;
		int count = 0;
		try {
			dateToCheck = formatter.parse(date);
			count = jdbcTemplate.queryForInt(SELECT_BOOKED_DATE, new Object[] {dateToCheck});
		} catch (ParseException e) {
			e.printStackTrace();
		}
		
		if ( count > 0 ) {
			return true;
		} 
		
		return false;
	}
//....
}

Und das ist die DateBookingBean Klasse. Hier wird die obige Methode aufgerufen
Java:
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

import javax.faces.component.UIComponent;
import javax.faces.component.html.HtmlCommandLink;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseId;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import de.als.zeitfenster.application.SessionAttributes;
import de.als.zeitfenster.user.User;

/**
 * Klasse, die das Buchen eines Zeitfensters realisiert.
 * 
 * @author
 *
 */
public class DateBookingBean {

	private static final String APPOINTMENT_DAO = "appointmentDAO";
	private static final String CONF = "conf/beans.xml";
	private static final String DATE_PATTERN = "yyyy-MM-dd HH:mm";
	private static final String DATE_CONFIRMED = "dateConfirmed";
	private static final String OUTCOME_CONFIRM = "confirmation";
	private String bookedDate;
	private String bookedTime;
	private String comment;
	private boolean booked;

	/**
	 * Bereitet das Appointment-Objekt zur Speicherung in der DB vor.
	 * 
	 * @return outcome - confirm fühert zu der Buchungsbestätigungsseite
	 */
	public String executeBooking() {

		if ( !StringUtils.isBlank(bookedDate) && 
				!StringUtils.isBlank(bookedTime) ) {
			final FacesContext context = FacesContext.getCurrentInstance();
			try {
				final SimpleDateFormat sdfToDate = new SimpleDateFormat(
						DATE_PATTERN);
				final String fullDate = formatDateToSqlDate(bookedTime, bookedDate);
				final Date date = sdfToDate.parse(fullDate);
				final DateTime terminVon = new DateTime(date);
				final DateTime terminBis = terminVon.plusHours(1);
				final User currentUser = (User) context.getExternalContext()
						.getSessionMap().get(SessionAttributes.CURRENT_USER);
				final Appointment unconfirmedDate = new Appointment(terminVon, terminBis,
						false, "", currentUser);
				context.getExternalContext()
						.getSessionMap()
						.put(SessionAttributes.UNCONFIRMED_DATE,
								unconfirmedDate);
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}
		return OUTCOME_CONFIRM;
	}
	
	/**
	 * Diese Methode überprüft den Termin und speichert ihn in der DB.
	 * @return outcome - dateConfirmed führt in den Kunden in den 
	 * 	   Kundenbereich zurück.
	 */
	public String confirmDate() {
		
		final FacesContext facesCtx = FacesContext.getCurrentInstance();
		final Appointment unconfirmedDate = (Appointment) 
				facesCtx.getExternalContext().getSessionMap().get(SessionAttributes.UNCONFIRMED_DATE);
		
		if ( unconfirmedDate != null ) {
			unconfirmedDate.setBooked(true);
			unconfirmedDate.setComment(comment);
			final HttpServletRequest request = (HttpServletRequest)facesCtx.getExternalContext().getRequest();  
			final HttpSession httpSession = request.getSession(false); 
			final ApplicationContext context = new ClassPathXmlApplicationContext(
					CONF);
			final AppointmentDAO appointmentDAO = (AppointmentDAO) context
					.getBean(APPOINTMENT_DAO);
			appointmentDAO.insertTermin(unconfirmedDate);
			httpSession.removeAttribute(SessionAttributes.UNCONFIRMED_DATE);
		}
		
		return DATE_CONFIRMED;
	}
	
	/**
	 * Überprüft alle Termine in der Tabelle, ob diese schon gebucht sind und
	 * disabled den Link ggf.
	 * 
	 * @param day - Welcher Tag soll überprüft werden, die Zeit wird aus dem Link entnommen
	 * @return boolean - true Der Link wird disabled, false der Link wird enabled
	 */
	public boolean isBooked(String day) {
	    boolean dateBooked = false;
	    final FacesContext fCxt = FacesContext.getCurrentInstance();
    	    if ( fCxt.getCurrentPhaseId().equals(PhaseId.RENDER_RESPONSE)) {
        	    final HtmlCommandLink link = (HtmlCommandLink)UIComponent.getCurrentComponent(fCxt);
        	    final String time = link.getValue().toString();
        	    final ApplicationContext context = new ClassPathXmlApplicationContext(
        			CONF);
        	    final AppointmentDAO appointmentDAO = (AppointmentDAO) context
        			.getBean(APPOINTMENT_DAO);
        	   final  Map<String,Object> sessionMap = fCxt.getExternalContext().getSessionMap();
        	    if ( StringUtils.equals(day, "monday") ) {
        		final String monday = (String)sessionMap.get(SessionAttributes.DATE_MONDAY);
        		final String fullDate = formatDateToSqlDate(time, monday);
        		dateBooked = appointmentDAO.bookedDate(fullDate + " - " + time);
        	     } else if (StringUtils.equals(day, "tuesday") ) {
        		 final String tuesday = (String)sessionMap.get(SessionAttributes.DATE_TUESDAY);
        		 final String fullDate = formatDateToSqlDate(time, tuesday);
        		 dateBooked = appointmentDAO.bookedDate(fullDate);
        	     } else if (StringUtils.equals(day, "wednesday") ) {
        		 final String wednesday = (String)sessionMap.get(SessionAttributes.DATE_WEDNESDAY);
        		 final String fullDate = formatDateToSqlDate(time, wednesday);
        		 dateBooked = appointmentDAO.bookedDate(fullDate);
        	     }else if (StringUtils.equals(day, "thursday") ) {
        		 final String thursday = (String)sessionMap.get(SessionAttributes.DATE_THURSDAY);
        		 final String fullDate = formatDateToSqlDate(time, thursday);
        		 dateBooked = appointmentDAO.bookedDate(fullDate);
        	     }else if (StringUtils.equals(day, "friday") ) {
        		 final String friday = (String)sessionMap.get(SessionAttributes.DATE_FRIDAY);
        		 final String fullDate = formatDateToSqlDate(time, friday);
        		 dateBooked = appointmentDAO.bookedDate(fullDate);
        	     }
	    }
	    
	    return dateBooked;
	}

	private String formatDateToSqlDate(String time, String date) {
	    final String[] dateContent =  StringUtils.split(date, '.');
	    final String fullDate = dateContent[2] +"-"+ dateContent[1] +"-"+ dateContent[0] +  " " + time +":00";
	    return fullDate;
	}
// Getter und Setter
//....

Ich kann mir vorstellen, dass die Methode den Fehler hervorruft, weil sie sehr oft hintereinander aufgerufen wird ( ca. 40 mal hintereinander )
um die die verschiedenen Termine zu überprüfen.


Viele Grüße

Edfred
 
M

maki

Gast
Hi,

jedesmal, wenn du [c]new ClassPathXmlApplicationContext(..);[/c] aufrufst, instanttierst du einen komplett neuen ApplicationContext und damit alle SpringBeans(!!!) erneut.
Ein einziges mal pro Anwendung muss reichen, ein Singleton eben.
Spring hatte mal diesen ContextLoaderListener für WebApps, k.A. ob der noch aktuell ist.
 

edfred

Mitglied
Hallo maki,

ich habe jetzt den Zugriff über Singleton umgesetzt (glaube ich zumindest).
Mien Singleton sieht nun so aus:

Java:
package de.als.zeitfenster.application;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public enum SingleApplicationContext {
    INSTANCE;
    
    private static final String CONF = "conf/beans.xml";

    SingleApplicationContext() {
	
    }
    
    public ApplicationContext getContext() {
	 final ApplicationContext context = 
		 new ClassPathXmlApplicationContext(CONF);
	 return context;
    }
    
}

Ich habe alle Vorkommnissse im Code, die so aussahen:
Java:
ApplicationContext context = 
		 new ClassPathXmlApplicationContext(CONF);

gelöscht. Jetzt steht da so was hier:

Java:
final AppointmentDAO appointmentDAO = (AppointmentDAO) SingleApplicationContext.INSTANCE
        		    .getContext().getBean(APPOINTMENT_DAO);

Dann habe ich das ganze ausprobiert....und ich bekam wieder dieselbe Exception:
Code:
Schwerwiegend: Error Rendering View[/customerarea/customer_area.xhtml]
javax.faces.FacesException: Could not get property disabled of component j_id1127192655_57ce788c:j_id1127192655_57ce7b3d
	at javax.faces.component._ComponentAttributesMap.getComponentProperty(_ComponentAttributesMap.java:407)
	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)
	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)
	... 34 more
Caused by: javax.el.ELException: /customerarea/customer_area.xhtml at line 146 and column 60 disabled="#{dateBookingBean.isBooked('friday')}": org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.postgresql.util.PSQLException: 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.postgresql.util.PSQLException: 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:77)
	at de.als.zeitfenster.customerarea.DateBookingBean.isBooked(DateBookingBean.java:131)
	at sun.reflect.GeneratedMethodAccessor66.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.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 java.sql.DriverManager.getConnection(DriverManager.java:579)
	at java.sql.DriverManager.getConnection(DriverManager.java:221)
	at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:90)
	at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:73)
	at org.postgresql.ds.jdbc23.AbstractJdbc23ConnectionPoolDataSource.getPooledConnection(AbstractJdbc23ConnectionPoolDataSource.java:58)
	at org.postgresql.ds.jdbc23.AbstractJdbc23PoolingDataSource.initialize(AbstractJdbc23PoolingDataSource.java:297)
	at org.postgresql.ds.jdbc23.AbstractJdbc23PoolingDataSource.getConnection(AbstractJdbc23PoolingDataSource.java:352)
	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
	... 57 more

Sep 13, 2012 8:26:05 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 146 and column 60 disabled="#{dateBookingBean.isBooked('friday')}": org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.postgresql.util.PSQLException: 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.postgresql.util.PSQLException: 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:77)
	at de.als.zeitfenster.customerarea.DateBookingBean.isBooked(DateBookingBean.java:131)
	at sun.reflect.GeneratedMethodAccessor66.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.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 java.sql.DriverManager.getConnection(DriverManager.java:579)
	at java.sql.DriverManager.getConnection(DriverManager.java:221)
	at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:90)
	at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:73)
	at org.postgresql.ds.jdbc23.AbstractJdbc23ConnectionPoolDataSource.getPooledConnection(AbstractJdbc23ConnectionPoolDataSource.java:58)
	at org.postgresql.ds.jdbc23.AbstractJdbc23PoolingDataSource.initialize(AbstractJdbc23PoolingDataSource.java:297)
	at org.postgresql.ds.jdbc23.AbstractJdbc23PoolingDataSource.getConnection(AbstractJdbc23PoolingDataSource.java:352)
	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
	... 57 more

Habe ich das Singleton falsch Umgesetzt? Habe ich dich falsch verstanden? Oder war die Idee mit dem Singleton leider doch nicht die Lösung????:L

Viele Grüße

Edfred
 
M

maki

Gast
Hi,

dein Singleton ist keines, es erzeugt trotzdem immer noch jedesmal einen neuen ApplicationContext.

Aber das ist egal, denn du sollst nicht versuchen ein GoF Singleton schreiben <-- wichtig

Spring bietet bereits fertige Lösungen dafür, darf ich fragen welche Doku/Buch und welche Spring Version du nutzt?
 
Zuletzt bearbeitet von einem Moderator:

edfred

Mitglied
Ich habe das Buch Spring im Einsatz und benutze die Version 3.x und JSF 2.0
Aha, fertige Lösungen hört sich gut an, muss ich weniger schreiben. Ok, das wusste ich nicht. Ich google mal oder suche im Buch. Danke für den Tipp.
 

edfred

Mitglied
Hi,

also das einzige, dass ich im Buch gefunden habe, dass mit Singleton zu tun hat ist folgendes:

[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.postgresql.ds.PGPoolingDataSource" scope="singleton">
<!--<property name="driverClassName" value="org.postgresql.Driver"/>-->
<property name="serverName" value="localhost:5432"/>
<property name="databaseName" value="zeitfenster"/>
<property name="user" value="postgres"/>
<property name="password" value="Zeitfenster001"/>
<property name="initialConnections" value="5"/>
<property name="maxConnections" value="10"/>
</bean>

<bean id="userDAO" class="de.als.zeitfenster.user.UserDAO" scope="singleton">
<property name="dataSource" ref="dataSource"/>
</bean>

<bean id="loginDAO" class="de.als.zeitfenster.application.login.LoginDAO" scope="singleton">
<property name="dataSource" ref="dataSource"/>
</bean>

<bean id="appointmentDAO" class="de.als.zeitfenster.customerarea.AppointmentDAO" scope="singleton">
<property name="dataSource" ref="dataSource"/>
</bean>
</beans>
[/XML]

Ich glaube aber, dass das auch nicht das ist was dir vorschwebte, oder?
Die Konfiguration habe ich auch ausprobiert und ...es klappt auch nicht.
Die Exception ist dieselbe....

Was habe ich diesmal falsch verstanden oder falsch umgesetzt? :)

Viele Grüße

Edfred
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
KOKASS Exception bei Datenbankconnect Datenbankprogrammierung 9
Kirby.exe SQL-Exception: Column not found Datenbankprogrammierung 6
S MySQL hibernate exception: illegal state exception : entityManagerFactory is closed Datenbankprogrammierung 5
G MySQL Java Problem: Nullpointer Exception obwohl Daten vorhanden sind? Datenbankprogrammierung 2
G PostgreSQL Nach Monaten auf einmal ClassNotFound-Exception Datenbankprogrammierung 3
K JPA Projekt Exception Datenbankprogrammierung 7
C jpa, exception Predeployment of PersistenceUnit failed Datenbankprogrammierung 1
M CommunicationLinkError - NullPointer Exception Datenbankprogrammierung 11
T MongoDB: Morphia REST 505 Exception Tomcat Datenbankprogrammierung 2
M SQL-Exception trotz funktionierendem SELECT Datenbankprogrammierung 4
N JDBC: rollback() bei Exception geht nicht!? Datenbankprogrammierung 1
M SQL Exception Datenbankprogrammierung 6
L Probleme mit DriverManager.getConnection(..) - Endlosschleife, Java Absturz, Keine Exception Datenbankprogrammierung 4
D Hibernate SaveOrUpdate Exception Datenbankprogrammierung 2
E MySQL Hibernate mit JaxWS führt zu LazyInitialization Exception Datenbankprogrammierung 8
T java sql exception getDate() Datenbankprogrammierung 2
O Viele Verbindungen-Exception bei insert Daten zur MySQL-Datenbank Datenbankprogrammierung 2
E Sql Exception Datenbankprogrammierung 14
M NestedTransaction- Exception in Hibernate Datenbankprogrammierung 15
F Derby/JavaDB SQL-Exception...Aber wieso!? :/ Datenbankprogrammierung 2
T Exception ResultSet Datenbankprogrammierung 7
Paristick MSSQL - JDBC Exception beim Registrieren Datenbankprogrammierung 5
S Null Pointer exception statement Datenbankprogrammierung 8
G JDBC Exception Datenbankprogrammierung 3
S ResultSet einer Datenbankabfrage - Nullpointer Exception Datenbankprogrammierung 13
F Derby/JavaDB Exception - Cannot accept Null Value (help) Datenbankprogrammierung 10
G Stored Procedure Exception Handling Datenbankprogrammierung 3
C SQL Exception auf Unique überprüfen Datenbankprogrammierung 5
B Hibernate+JPA Exception in persistence.xml Datenbankprogrammierung 5
L SQL Exception Problem Datenbankprogrammierung 7
M hilfe zur einer Exception Datenbankprogrammierung 2
J Nullpointer Exception bei Zugriff auf Datenbank Datenbankprogrammierung 13
A MySQL Anbindung - Exception Handling Datenbankprogrammierung 2
R SQL Exception: Cursor position not valid Datenbankprogrammierung 7
O Oracle 11g wirft bei 90 % der installation eine Exception ? Datenbankprogrammierung 5
R Warum kommt eine Exception bei instanceof ? Datenbankprogrammierung 4
B SQL Exception Datenbankprogrammierung 9
E Datenbankverbindung Java MySQL Exception Datenbankprogrammierung 10
N Class not found Exception Datenbankprogrammierung 2
A Exception in thread "AWT-EventQueue-0" java.lang.N Datenbankprogrammierung 4
M SQL Exception bei LIMIT Datenbankprogrammierung 11
megachucky Problem mit: SQL Exception Before start of result set Datenbankprogrammierung 2
W updateRow() schmeißt eine Exception, weil schreibgeschützt Datenbankprogrammierung 6
M Sql Anfrage wirft Exception Datenbankprogrammierung 5
6 Communications link failure due to underlying exception Datenbankprogrammierung 10
R SQL Exception "Weiterleiten der Egebnissmenge" Datenbankprogrammierung 15
märliprinz Exception in thread "main" java.lang.OutOfMemoryEr Datenbankprogrammierung 9
S Java SQL-Exception bei Zugriff auf MSAccess Datenbankprogrammierung 2
K Exception bei Verbindungsaufbau Oracle Datenbank Datenbankprogrammierung 13
L "desc tablename" liefert SQL Exception mit execute Datenbankprogrammierung 6
M SQL Exception Datenbankprogrammierung 3
M Problem mit dem ActionListener und SQL Exception Datenbankprogrammierung 6
D Exception bei ResultSet.moveToInsertRow Datenbankprogrammierung 6
EagleEye problem mit exception Datenbankprogrammierung 2
L UPDATE löst Exception aus Datenbankprogrammierung 6
V Exception beim Speichern von eingegebenen Daten in Tabelle Datenbankprogrammierung 2
G ich bekomm immer die exception grrrr Datenbankprogrammierung 3
D Unklare SQL Exception Datenbankprogrammierung 3
Z MySQL "Too many connections" auch nach schliessen der Connections. Datenbankprogrammierung 10
OnDemand One to Many bekomm es nicht hin Datenbankprogrammierung 7
D MySQL Many to Many Tabellen in Java abbilden? Datenbankprogrammierung 4
G MongoDB - klassisches one to many Datenbankprogrammierung 2
P Many to Many mit JoinTable Datenbankprogrammierung 2
M Hibernate liefert mir bei many-to-one leeres Feld Datenbankprogrammierung 5
G Many to Many Datenbankprogrammierung 2
foobar ISAM error: too many files open Datenbankprogrammierung 5
rambozola mysql to many connections Datenbankprogrammierung 27

Ähnliche Java Themen


Oben