Ok, I got a weird one here. I have a application set up that is using hibernate configured for multi tenancy and C3P0 for connection pooling.
Everthing works fine except that in my logs an exception is thrown and i cannct get to the cause of it... The weird thing is that this exception is in no way bothering my Application it is just working fine even with the exception being thrown (always 4 times and even if I do nothing but start the server and wait. After some seconds they pop up in the log and that is it)
Here is the exception and some basic config that might be useful:
2013-05-28 09:06:02 WARN BasicResourcePool:1841 - com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1d926e41 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'dbuser'. ClientConnectionId:07fa33fd-9de8-4235-b991-ac7e9e1ad437
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:254)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:84)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2908)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2234)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2220)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1326)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
sessionFactory:
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="annotatedClasses">
<list>
...
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.multiTenancy=SCHEMA
hibernate.tenant_identifier_resolver=xxx.xxx.hibernate.CurrentTenantIdentifierResolverImpl
hibernate.multi_tenant_connection_provider=xxx.xxx.hibernate.MultiTenantConnectionProviderImpl
hibernate.dialect=${hibernate.dialect}
hibernate.use_sql_comments=${hibernate.debug}
hibernate.show_sql=${hibernate.debug}
hibernate.format_sql=${hibernate.debug}
</value>
</property>
</bean>
The c3p0-config.xml:
<c3p0-config>
<named-config name="c3p0name">
<property name="acquireIncrement">3</property>
<!--property name="automaticTestTable">con_test</property-->
<property name="checkoutTimeout">30</property>
<property name="idleConnectionTestPeriod">30</property>
<property name="initialPoolSize">2</property>
<property name="maxIdleTime">18000</property>
<property name="maxPoolSize">30</property>
<property name="minPoolSize">2</property>
<property name="maxStatements">50</property>
<property name="testConnectionOnCheckin">true</property>
</named-config>
</c3p0-config>
Here is the implementation that instantiates the ConnectionPool:
public class MultiTenantConnectionProviderImpl implements MultiTenantConnectionProvider {
private static final long serialVersionUID = 8074002161278796379L;
ComboPooledDataSource cpds;
public MultiTenantConnectionProviderImpl() throws PropertyVetoException {
cpds = new ComboPooledDataSource("c3p0name");
cpds.setDriverClass("jdbc.driver"));
cpds.setJdbcUrl("jdbc.url"));
cpds.setUser("dbuser");
cpds.setPassword("dbuserpassword"));
}
@Override
public Connection getAnyConnection() throws SQLException {
return cpds.getConnection();
}
@Override
public Connection getConnection(String dbuser) throws SQLException {
return cpds.getConnection(dbuser, PropertyUtil.getCredential(dbuser));
}
Even if there is no direct answer available I am happy with any remark or direction that might help my investigation, so just post anything you got. Thank you in advance
Edit:
I found the error at hand for the failing initial connections it was just a misconfiguration of the dbuserpassword for the passwordproperty of the DBConnectionPool....
This solves part of the question and leaves ony the duplicate initaly which if following the discussion below the answer from @Steve Waldman is most likely just a log4j misconfiguration.