jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Belrose <kafe...@gmail.com>
Subject Potential bug: failure to connect to MySQL database when JackRabbit starts a session leaves a .lock file in the repository. Subsequent sessions cannot be created.
Date Thu, 20 Jan 2011 15:22:08 GMT
Hi all,

I am currently investigating the robustness of JackRabbit in the face
of unexpected database errors, such as the database being unavailable.
In my particular case, I am attempting to start a JackRabbit session
while the database is not yet running. This correctly fails. However,
if I attempt to create another session within the same thread after a
short while, an exception occurs saying that the repository has
already been locked. I would expect the repository folder not to be
locked. Maybe the code meant to remove the .lock file was not
triggered because of an unexpected exception.

The exception stack trace is as follows:
2011-01-20 15:23:13,140 INFO  [main] [com.quantel.jcr.DBBug] -
Creating a transient repository....
2011-01-20 15:23:13,156 INFO  [main] [com.quantel.jcr.DBBug] - Attempt
0 at creating a session.
2011-01-20 15:23:13,156 INFO  [main]
[org.apache.jackrabbit.core.config.RepositoryConfig] - Creating
repository directory repository
2011-01-20 15:23:13,281 INFO  [main]
[org.apache.jackrabbit.core.RepositoryImpl] - Starting repository...
2011-01-20 15:23:14,390 ERROR [main]
[org.apache.jackrabbit.core.fs.db.DatabaseFileSystem] - failed to
initialize file system
org.apache.commons.dbcp.SQLNestedException: Cannot create
PoolableConnectionFactory (Communications link failure

The last packet sent successfully to the server was 0 milliseconds
ago. The driver has not received any packets from the server.)
	at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
~[commons-dbcp-1.2.2.jar:1.2.2]
	at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
~[commons-dbcp-1.2.2.jar:1.2.2]
	at org.apache.jackrabbit.core.util.db.ConnectionHelper.getExtraNameCharacters(ConnectionHelper.java:163)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.util.db.ConnectionHelper.prepareDbIdentifier(ConnectionHelper.java:118)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.fs.db.DatabaseFileSystem.init(DatabaseFileSystem.java:193)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.config.RepositoryConfigurationParser$6.getFileSystem(RepositoryConfigurationParser.java:1057)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.config.RepositoryConfig.getFileSystem(RepositoryConfig.java:892)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:284)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:602)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.TransientRepository$2.getRepository(TransientRepository.java:231)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.TransientRepository.startRepository(TransientRepository.java:279)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.TransientRepository.login(TransientRepository.java:375)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.commons.AbstractRepository.login(AbstractRepository.java:123)
[jackrabbit-jcr-commons-2.2.0.jar:na]
	at com.quantel.jcr.DBBug.main(DBBug.java:19) [classes/:na]
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
Communications link failure

The last packet sent successfully to the server was 0 milliseconds
ago. The driver has not received any packets from the server.
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method) ~[na:1.6.0_21]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
~[na:1.6.0_21]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
~[na:1.6.0_21]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
~[na:1.6.0_21]
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:343)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2334)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2371)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2163)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
~[mysql-connector-java-5.1.14.jar:na]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method) ~[na:1.6.0_21]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
~[na:1.6.0_21]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
~[na:1.6.0_21]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
~[na:1.6.0_21]
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:378)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
~[mysql-connector-java-5.1.14.jar:na]
	at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
~[commons-dbcp-1.2.2.jar:1.2.2]
	at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)
~[commons-dbcp-1.2.2.jar:1.2.2]
	at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247)
~[commons-dbcp-1.2.2.jar:1.2.2]
	at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1221)
~[commons-dbcp-1.2.2.jar:1.2.2]
	... 13 common frames omitted
Caused by: java.net.ConnectException: Connection refused: connect
	at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.6.0_21]
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) ~[na:1.6.0_21]
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
~[na:1.6.0_21]
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) ~[na:1.6.0_21]
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) ~[na:1.6.0_21]
	at java.net.Socket.connect(Socket.java:529) ~[na:1.6.0_21]
	at java.net.Socket.connect(Socket.java:478) ~[na:1.6.0_21]
	at java.net.Socket.<init>(Socket.java:375) ~[na:1.6.0_21]
	at java.net.Socket.<init>(Socket.java:218) ~[na:1.6.0_21]
	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:254)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:292)
~[mysql-connector-java-5.1.14.jar:na]
	... 29 common frames omitted
2011-01-20 15:23:14,390 ERROR [main]
[org.apache.jackrabbit.core.RepositoryImpl] - failed to start
Repository: File system initialization failure.
javax.jcr.RepositoryException: File system initialization failure.
	at org.apache.jackrabbit.core.config.RepositoryConfigurationParser$6.getFileSystem(RepositoryConfigurationParser.java:1060)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.config.RepositoryConfig.getFileSystem(RepositoryConfig.java:892)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:284)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:602)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.TransientRepository$2.getRepository(TransientRepository.java:231)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.TransientRepository.startRepository(TransientRepository.java:279)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.TransientRepository.login(TransientRepository.java:375)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.commons.AbstractRepository.login(AbstractRepository.java:123)
[jackrabbit-jcr-commons-2.2.0.jar:na]
	at com.quantel.jcr.DBBug.main(DBBug.java:19) [classes/:na]
Caused by: org.apache.jackrabbit.core.fs.FileSystemException: failed
to initialize file system
	at org.apache.jackrabbit.core.fs.db.DatabaseFileSystem.init(DatabaseFileSystem.java:210)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.config.RepositoryConfigurationParser$6.getFileSystem(RepositoryConfigurationParser.java:1057)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	... 8 common frames omitted
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create
PoolableConnectionFactory (Communications link failure

The last packet sent successfully to the server was 0 milliseconds
ago. The driver has not received any packets from the server.)
	at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
~[commons-dbcp-1.2.2.jar:1.2.2]
	at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
~[commons-dbcp-1.2.2.jar:1.2.2]
	at org.apache.jackrabbit.core.util.db.ConnectionHelper.getExtraNameCharacters(ConnectionHelper.java:163)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.util.db.ConnectionHelper.prepareDbIdentifier(ConnectionHelper.java:118)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.fs.db.DatabaseFileSystem.init(DatabaseFileSystem.java:193)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	... 9 common frames omitted
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
Communications link failure

The last packet sent successfully to the server was 0 milliseconds
ago. The driver has not received any packets from the server.
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method) ~[na:1.6.0_21]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
~[na:1.6.0_21]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
~[na:1.6.0_21]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
~[na:1.6.0_21]
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:343)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2334)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2371)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2163)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
~[mysql-connector-java-5.1.14.jar:na]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method) ~[na:1.6.0_21]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
~[na:1.6.0_21]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
~[na:1.6.0_21]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
~[na:1.6.0_21]
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:378)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
~[mysql-connector-java-5.1.14.jar:na]
	at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
~[commons-dbcp-1.2.2.jar:1.2.2]
	at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)
~[commons-dbcp-1.2.2.jar:1.2.2]
	at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247)
~[commons-dbcp-1.2.2.jar:1.2.2]
	at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1221)
~[commons-dbcp-1.2.2.jar:1.2.2]
	... 13 common frames omitted
Caused by: java.net.ConnectException: Connection refused: connect
	at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.6.0_21]
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) ~[na:1.6.0_21]
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
~[na:1.6.0_21]
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) ~[na:1.6.0_21]
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) ~[na:1.6.0_21]
	at java.net.Socket.connect(Socket.java:529) ~[na:1.6.0_21]
	at java.net.Socket.connect(Socket.java:478) ~[na:1.6.0_21]
	at java.net.Socket.<init>(Socket.java:375) ~[na:1.6.0_21]
	at java.net.Socket.<init>(Socket.java:218) ~[na:1.6.0_21]
	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:254)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:292)
~[mysql-connector-java-5.1.14.jar:na]
	... 29 common frames omitted
2011-01-20 15:23:14,390 INFO  [main]
[org.apache.jackrabbit.core.RepositoryImpl] - Shutting down
repository...
2011-01-20 15:23:14,390 ERROR [main]
[org.apache.jackrabbit.core.RepositoryImpl] - Error while closing
Version Manager.
java.lang.NullPointerException: null
	at org.apache.jackrabbit.core.RepositoryImpl.doShutdown(RepositoryImpl.java:1117)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.RepositoryImpl.shutdown(RepositoryImpl.java:1063)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:388)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:602)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.TransientRepository$2.getRepository(TransientRepository.java:231)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.TransientRepository.startRepository(TransientRepository.java:279)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.TransientRepository.login(TransientRepository.java:375)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.commons.AbstractRepository.login(AbstractRepository.java:123)
[jackrabbit-jcr-commons-2.2.0.jar:na]
	at com.quantel.jcr.DBBug.main(DBBug.java:19) [classes/:na]
2011-01-20 15:23:14,390 ERROR [main]
[org.apache.jackrabbit.core.RepositoryImpl] - In addition to startup
fail, another unexpected problem occurred while shutting down the
repository again.
java.lang.NullPointerException: null
	at org.apache.jackrabbit.core.RepositoryImpl.doShutdown(RepositoryImpl.java:1136)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.RepositoryImpl.shutdown(RepositoryImpl.java:1063)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:388)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:602)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.TransientRepository$2.getRepository(TransientRepository.java:231)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.TransientRepository.startRepository(TransientRepository.java:279)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.TransientRepository.login(TransientRepository.java:375)
[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.commons.AbstractRepository.login(AbstractRepository.java:123)
[jackrabbit-jcr-commons-2.2.0.jar:na]
	at com.quantel.jcr.DBBug.main(DBBug.java:19) [classes/:na]
2011-01-20 15:23:14,390 ERROR [main] [com.quantel.jcr.DBBug] -
Exception when creating a session
javax.jcr.RepositoryException: File system initialization failure.
	at org.apache.jackrabbit.core.config.RepositoryConfigurationParser$6.getFileSystem(RepositoryConfigurationParser.java:1060)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.config.RepositoryConfig.getFileSystem(RepositoryConfig.java:892)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:284)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:602)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.TransientRepository$2.getRepository(TransientRepository.java:231)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.TransientRepository.startRepository(TransientRepository.java:279)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.TransientRepository.login(TransientRepository.java:375)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.commons.AbstractRepository.login(AbstractRepository.java:123)
~[jackrabbit-jcr-commons-2.2.0.jar:na]
	at com.quantel.jcr.DBBug.main(DBBug.java:19) ~[classes/:na]
Caused by: org.apache.jackrabbit.core.fs.FileSystemException: failed
to initialize file system
	at org.apache.jackrabbit.core.fs.db.DatabaseFileSystem.init(DatabaseFileSystem.java:210)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.config.RepositoryConfigurationParser$6.getFileSystem(RepositoryConfigurationParser.java:1057)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	... 8 common frames omitted
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create
PoolableConnectionFactory (Communications link failure

The last packet sent successfully to the server was 0 milliseconds
ago. The driver has not received any packets from the server.)
	at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
~[commons-dbcp-1.2.2.jar:1.2.2]
	at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
~[commons-dbcp-1.2.2.jar:1.2.2]
	at org.apache.jackrabbit.core.util.db.ConnectionHelper.getExtraNameCharacters(ConnectionHelper.java:163)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.util.db.ConnectionHelper.prepareDbIdentifier(ConnectionHelper.java:118)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.fs.db.DatabaseFileSystem.init(DatabaseFileSystem.java:193)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	... 9 common frames omitted
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
Communications link failure

The last packet sent successfully to the server was 0 milliseconds
ago. The driver has not received any packets from the server.
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method) ~[na:1.6.0_21]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
~[na:1.6.0_21]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
~[na:1.6.0_21]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
~[na:1.6.0_21]
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:343)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2334)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2371)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2163)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
~[mysql-connector-java-5.1.14.jar:na]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method) ~[na:1.6.0_21]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
~[na:1.6.0_21]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
~[na:1.6.0_21]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
~[na:1.6.0_21]
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:378)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
~[mysql-connector-java-5.1.14.jar:na]
	at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
~[commons-dbcp-1.2.2.jar:1.2.2]
	at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)
~[commons-dbcp-1.2.2.jar:1.2.2]
	at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247)
~[commons-dbcp-1.2.2.jar:1.2.2]
	at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1221)
~[commons-dbcp-1.2.2.jar:1.2.2]
	... 13 common frames omitted
Caused by: java.net.ConnectException: Connection refused: connect
	at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.6.0_21]
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) ~[na:1.6.0_21]
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
~[na:1.6.0_21]
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) ~[na:1.6.0_21]
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) ~[na:1.6.0_21]
	at java.net.Socket.connect(Socket.java:529) ~[na:1.6.0_21]
	at java.net.Socket.connect(Socket.java:478) ~[na:1.6.0_21]
	at java.net.Socket.<init>(Socket.java:375) ~[na:1.6.0_21]
	at java.net.Socket.<init>(Socket.java:218) ~[na:1.6.0_21]
	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:254)
~[mysql-connector-java-5.1.14.jar:na]
	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:292)
~[mysql-connector-java-5.1.14.jar:na]
	... 29 common frames omitted
2011-01-20 15:23:16,390 INFO  [main] [com.quantel.jcr.DBBug] - Attempt
1 at creating a session.
2011-01-20 15:23:16,406 WARN  [main]
[org.apache.jackrabbit.core.util.RepositoryLock] - Existing lock file
C:\Guillaume\Work\Projects\EclipseWorkspace\java-scratch\repository\.lock
detected. Repository was not shut down properly.
2011-01-20 15:23:16,406 ERROR [main] [com.quantel.jcr.DBBug] -
Exception when creating a session
javax.jcr.RepositoryException: The repository home
C:\Guillaume\Work\Projects\EclipseWorkspace\java-scratch\repository
appears to be in use since the file named .lock is already locked by
the current process.
	at org.apache.jackrabbit.core.util.RepositoryLock.tryLock(RepositoryLock.java:159)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.util.RepositoryLock.acquire(RepositoryLock.java:138)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:275)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:602)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.TransientRepository$2.getRepository(TransientRepository.java:231)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.TransientRepository.startRepository(TransientRepository.java:279)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.core.TransientRepository.login(TransientRepository.java:375)
~[jackrabbit-core-2.2.0.jar:2.2.0]
	at org.apache.jackrabbit.commons.AbstractRepository.login(AbstractRepository.java:123)
~[jackrabbit-jcr-commons-2.2.0.jar:na]
	at com.quantel.jcr.DBBug.main(DBBug.java:19) ~[classes/:na]


The simple code that I am running is:
package com.quantel.jcr;

import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import org.apache.jackrabbit.core.TransientRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DBBug {
	static final Logger logger = LoggerFactory.getLogger(DBBug.class);
	public static void main(String[] args) throws InterruptedException {
		logger.info("Creating a transient repository....");
		Repository repository = new TransientRepository();
		for ( int i = 0 ; i < 2 ; i ++){
			try{
				logger.info("Attempt {} at creating a session.",i);
				SimpleCredentials credentials = new SimpleCredentials("foo",
"foo".toCharArray());
				Session session = repository.login(credentials);
				session.logout();
			}catch (Exception e){
				logger.error("Exception when creating a session ",e);
			}
			Thread.sleep(2000);
		}
	}
}

My repo config looks like:

<?xml version="1.0"?>
	<!--
		Licensed to the Apache Software Foundation (ASF) under one or more
		contributor license agreements. See the NOTICE file distributed with
		this work for additional information regarding copyright ownership.
		The ASF licenses this file to You under the Apache License, Version
		2.0 (the "License"); you may not use this file except in compliance
		with the License. You may obtain a copy of the License at

		http://www.apache.org/licenses/LICENSE-2.0 Unless required by
		applicable law or agreed to in writing, software distributed under the
		License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
		CONDITIONS OF ANY KIND, either express or implied. See the License for
		the specific language governing permissions and limitations under the
		License.
	-->

<!DOCTYPE Repository
          PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 2.0//EN"
          "http://jackrabbit.apache.org/dtd/repository-2.0.dtd">

	<!--
		Example Repository Configuration File Used by -
		org.apache.jackrabbit.core.config.RepositoryConfigTest.java -
	-->
<Repository>
	<DataSources>
        <DataSource name="datasource">
			<param name="driver" value="com.mysql.jdbc.Driver" />
			<param name="url" value="jdbc:mysql://localhost:3308/jcr" />
			<param name="user" value="quantel" />
			<param name="password" value="......" />
			<param name="databaseType" value="mysql"/>
            <param name="validationQuery" value="select 1"/>
        </DataSource>
    </DataSources>


	<!--
		virtual file system where the repository stores global state (e.g.
		registered namespaces, custom node types, etc.)
	-->
	<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
		<param name="dataSourceName" value="datasource" />
		<param name="schemaObjectPrefix" value="fs_" />
	</FileSystem>

	<!--
        security configuration
    -->
	<Security appName="Jackrabbit">
		<!--
			security manager: class: FQN of class implementing the
			JackrabbitSecurityManager interface
		-->
		<SecurityManager
			class="org.apache.jackrabbit.core.security.simple.SimpleSecurityManager"
			workspaceName="security">
			<!--
				workspace access: class: FQN of class implementing the
				WorkspaceAccessManager interface
			-->
			<!-- <WorkspaceAccessManager class="..."/> -->
			<!-- <param name="config" value="${rep.home}/security.xml"/> -->
		</SecurityManager>

		<!--
			access manager: class: FQN of class implementing the AccessManager
			interface
		-->
		<AccessManager
			class="org.apache.jackrabbit.core.security.simple.SimpleAccessManager">
			<!-- <param name="config" value="${rep.home}/access.xml"/> -->
		</AccessManager>

		<LoginModule
			class="org.apache.jackrabbit.core.security.simple.SimpleLoginModule">
			<!--
				anonymous user name ('anonymous' is the default value)
			-->
			<param name="anonymousId" value="anonymous" />
			<!--
				administrator user id (default value if param is missing is 'admin')
			-->
			<param name="adminId" value="admin" />
		</LoginModule>
	</Security>

	<!--
		location of workspaces root directory and name of default workspace
	-->
	<Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="security" />

	<!--
		workspace configuration template: used to create the initial workspace
		if there's no workspace yet
	-->
	<Workspace name="${wsp.name}">
		<!--
			virtual file system of the workspace: class: FQN of class
			implementing the FileSystem interface
		-->
		<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
			<param name="dataSourceName" value="datasource" />
			<param name="schemaObjectPrefix" value="fs_${wsp.name}_" />
		</FileSystem>

		<!--
			persistence manager of the workspace: class: FQN of class
			implementing the PersistenceManager interface
		-->
		<PersistenceManager
			class="org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager">
			<param name="dataSourceName" value="datasource" />
			<param name="schemaObjectPrefix" value="pm_${wsp.name}_" />
			<param name="externalBLOBs" value="false" />
		</PersistenceManager>
		<!--
			Search index and the file system it uses. class: FQN of class
			implementing the QueryHandler interface
		-->
		<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
			<param name="path" value="${wsp.home}/index" />
		</SearchIndex>
	</Workspace>

	<!--
        Configures the versioning
    -->
	<Versioning rootPath="${rep.home}/version">
		<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
			<param name="dataSourceName" value="datasource" />
			<param name="schemaObjectPrefix" value="fs_version_" />
		</FileSystem>

		<PersistenceManager
			class="org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager">
			<param name="dataSourceName" value="datasource" />
			<param name="schemaObjectPrefix" value="pm_version_" />
			<param name="externalBLOBs" value="false" />
		</PersistenceManager>
	</Versioning>
	<!--
		Search index for content that is shared repository wide (/jcr:system
		tree, contains mainly versions)
	-->
	<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
		<param name="path" value="${rep.home}/repository/index" />
	</SearchIndex>
</Repository>

Mime
View raw message