Cannot connect to database

What happened?

A database error occurred, probably because your database connection is misconfigured. You will have to fix this problem and then restart or redeploy Roller before you can proceed. Here's what happened when Roller tried to establish a connection:

  • SUCCESS: Got parameters. Using configuration type JNDI_NAME
  • -- Using JNDI datasource name: java:comp/env/jdbc/rollerdb
  • SUCCESS: located JNDI DataSource [java:comp/env/jdbc/rollerdb]
  • ERROR: unable to obtain database connection. Likely problem: bad connection parameters or database unavailable.

Why did that happen?

In case the clues above are not enough to help you figure out what is going wrong, here are some more details. The root cause of the problem is an exception of type [java.sql.SQLException]

To help you debug the problem, here is the stack trace for that exception:

    [java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.
	at com.sun.gjc.spi.base.AbstractDataSource.getConnection(AbstractDataSource.java:121)
	at org.apache.roller.weblogger.business.DatabaseProvider.getConnection(DatabaseProvider.java:179)
	at org.apache.roller.weblogger.business.DatabaseProvider.<init>(DatabaseProvider.java:141)
	at org.apache.roller.weblogger.business.startup.WebloggerStartup.prepare(WebloggerStartup.java:171)
	at org.apache.roller.weblogger.ui.core.RollerContext.contextInitialized(RollerContext.java:138)
	at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:5362)
	at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:743)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:5898)
	at com.sun.enterprise.web.WebModule.start(WebModule.java:691)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
	at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2278)
	at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1924)
	at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139)
	at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
	at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
	at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352)
	at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:497)
	at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:407)
	at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:243)
	at org.jvnet.hk2.internal.ClazzCreator.postConstructMe(ClazzCreator.java:281)
	at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:328)
	at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:448)
	at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:163)
	at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2204)
	at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:93)
	at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.oneJob(CurrentTaskFuture.java:673)
	at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.run(CurrentTaskFuture.java:660)
	at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$UpOneJob.run(CurrentTaskFuture.java:490)
	at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$UpAllTheWay.go(CurrentTaskFuture.java:362)
	at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$UpAllTheWay.access$100(CurrentTaskFuture.java:279)
	at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture.go(CurrentTaskFuture.java:113)
	at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.proceedTo(AsyncRunLevelContext.java:296)
	at org.glassfish.hk2.runlevel.internal.RunLevelControllerImpl.proceedTo(RunLevelControllerImpl.java:66)
	at com.sun.enterprise.v3.server.AppServerStartup.proceedTo(AppServerStartup.java:532)
	at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:329)
	at com.sun.enterprise.v3.server.AppServerStartup.doStart(AppServerStartup.java:226)
	at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:217)
	at com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.start(GlassFishImpl.java:79)
	at com.sun.enterprise.glassfish.bootstrap.GlassFishDecorator.start(GlassFishDecorator.java:63)
	at com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishImpl.start(EmbeddedOSGiGlassFishImpl.java:75)
	at com.sun.enterprise.glassfish.bootstrap.GlassFishDecorator.start(GlassFishDecorator.java:63)
	at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishImpl.start(OSGiGlassFishImpl.java:71)
	at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:117)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
	at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:54)
Caused by: javax.resource.spi.ResourceAllocationException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.
	at com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:319)
	at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:242)
	at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:171)
	at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:166)
	at com.sun.gjc.spi.base.AbstractDataSource.getConnection(AbstractDataSource.java:114)
	... 50 more
Caused by: com.sun.appserv.connectors.internal.api.PoolingException: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.
	at com.sun.enterprise.resource.pool.datastructure.RWLockDataStructure.addResource(RWLockDataStructure.java:103)
	at com.sun.enterprise.resource.pool.ConnectionPool.addResource(ConnectionPool.java:282)
	at com.sun.enterprise.resource.pool.ConnectionPool.createResourceAndAddToPool(ConnectionPool.java:1512)
	at com.sun.enterprise.resource.pool.ConnectionPool.createResources(ConnectionPool.java:944)
	at com.sun.enterprise.resource.pool.ConnectionPool.initPool(ConnectionPool.java:230)
	at com.sun.enterprise.resource.pool.ConnectionPool.internalGetResource(ConnectionPool.java:511)
	at com.sun.enterprise.resource.pool.ConnectionPool.getResource(ConnectionPool.java:381)
	at com.sun.enterprise.resource.pool.PoolManagerImpl.getResourceFromPool(PoolManagerImpl.java:245)
	at com.sun.enterprise.resource.pool.PoolManagerImpl.getResource(PoolManagerImpl.java:170)
	at com.sun.enterprise.connectors.ConnectionManagerImpl.getResource(ConnectionManagerImpl.java:360)
	at com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:307)
	... 54 more
Caused by: com.sun.appserv.connectors.internal.api.PoolingException: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.
	at com.sun.enterprise.resource.pool.ConnectionPool.createSingleResource(ConnectionPool.java:924)
	at com.sun.enterprise.resource.pool.ConnectionPool.createResource(ConnectionPool.java:1189)
	at com.sun.enterprise.resource.pool.datastructure.RWLockDataStructure.addResource(RWLockDataStructure.java:98)
	... 64 more
Caused by: com.sun.appserv.connectors.internal.api.PoolingException: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.
	at com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator.createResource(LocalTxConnectorAllocator.java:110)
	at com.sun.enterprise.resource.pool.ConnectionPool.createSingleResource(ConnectionPool.java:907)
	... 66 more
Caused by: javax.resource.spi.ResourceAllocationException: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.
	at com.sun.gjc.spi.DSManagedConnectionFactory.createManagedConnection(DSManagedConnectionFactory.java:129)
	at com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator.createResource(LocalTxConnectorAllocator.java:87)
	... 67 more
Caused by: java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.
	at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
	at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
	at org.apache.derby.jdbc.ClientDataSource.getConnection(Unknown Source)
	at com.sun.gjc.spi.DSManagedConnectionFactory.createManagedConnection(DSManagedConnectionFactory.java:115)
	... 68 more
Caused by: org.apache.derby.client.am.DisconnectException: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.
	at org.apache.derby.client.net.NetAgent.<init>(Unknown Source)
	at org.apache.derby.client.net.NetConnection.newAgent_(Unknown Source)
	at org.apache.derby.client.am.Connection.initConnection(Unknown Source)
	at org.apache.derby.client.am.Connection.<init>(Unknown Source)
	at org.apache.derby.client.net.NetConnection.<init>(Unknown Source)
	at org.apache.derby.client.net.NetConnection40.<init>(Unknown Source)
	at org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40.newNetConnection(Unknown Source)
	at org.apache.derby.jdbc.ClientDataSource.getConnectionX(Unknown Source)
	... 70 more
Caused by: java.net.ConnectException: Connection refused
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at java.net.Socket.connect(Socket.java:538)
	at java.net.Socket.<init>(Socket.java:434)
	at java.net.Socket.<init>(Socket.java:211)
	at javax.net.DefaultSocketFactory.createSocket(SocketFactory.java:271)
	at org.apache.derby.client.net.OpenSocketAction.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	... 78 more]