org.postgresql.util.PSQLException: Something unusual has occurred to cause the driver to fail

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem

Connecting to PostgreSQL fails, with the following message shown in the UI:

The configuration entered is not valid. A database connection could not be established. Please check your configuration and try again.

 

The following appears in the atlassian-bitbucket.log:

2016-08-02 09:00:00,000 WARN  [http-nio-7990-exec-6] @1Q6XGAEx556x41x0 bitbucket 0:0:0:0:0:0:0:1 "POST /setup HTTP/1.1" c.a.s.i.db.DefaultDatabaseManager A connection could not be opened with the DataSource
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.postgresql.util.PSQLException: Something unusual has occurred to cause the driver to fail. Please report this exception.
	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80) ~[spring-jdbc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at com.atlassian.stash.internal.db.DefaultDatabaseValidator.validate(DefaultDatabaseValidator.java:44) ~[bitbucket-dao-impl-4.8.3.jar:na]
	at com.atlassian.stash.internal.db.DefaultDatabaseManager.validateConfiguration(DefaultDatabaseManager.java:227) ~[bitbucket-service-impl-4.8.3.jar:na]
	at com.atlassian.stash.internal.migration.DefaultMigrationService.validateConfiguration(DefaultMigrationService.java:85) [bitbucket-service-impl-4.8.3.jar:na]
	at com.atlassian.stash.internal.web.setup.SetupController.lambda$performTestDatabaseConnection$0(SetupController.java:291) [classes/:na]
	at com.atlassian.stash.internal.user.DefaultEscalatedSecurityContext.call(DefaultEscalatedSecurityContext.java:51) ~[bitbucket-service-impl-4.8.3.jar:na]
	at com.atlassian.stash.internal.web.setup.SetupController.performTestDatabaseConnection(SetupController.java:290) [classes/:na]
	at com.atlassian.stash.internal.web.setup.SetupController.configureDatabase(SetupController.java:267) [classes/:na]
	at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24) ~[na:na]
	at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24) ~[na:na]
	at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24) ~[na:na]
	at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24) ~[na:na]
	at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24) ~[na:na]
	at com.atlassian.stash.internal.spring.security.StashAuthenticationFilter.doFilter(StashAuthenticationFilter.java:113) ~[classes/:na]
	at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doInsideSpringSecurityChain(BeforeLoginPluginAuthenticationFilter.java:109) ~[classes/:na]
	at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doFilter(BeforeLoginPluginAuthenticationFilter.java:75) ~[classes/:na]
	at com.atlassian.security.auth.trustedapps.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:94) ~[atlassian-trusted-apps-core-4.2.0.jar:na]
	at com.atlassian.oauth.serviceprovider.internal.servlet.OAuthFilter.doFilter(OAuthFilter.java:67) ~[na:na]
	at com.atlassian.security.auth.trustedapps.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:94) ~[atlassian-trusted-apps-core-4.2.0.jar:na]
	at com.atlassian.oauth.serviceprovider.internal.servlet.OAuthFilter.doFilter(OAuthFilter.java:67) ~[na:na]
	at com.atlassian.core.filters.ServletContextThreadLocalFilter.doFilter(ServletContextThreadLocalFilter.java:21) ~[atlassian-core-4.6.19.jar:na]
	at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:31) ~[atlassian-core-4.6.19.jar:na]
	at com.atlassian.plugin.connect.plugin.auth.user.ThreeLeggedAuthFilter.doFilter(ThreeLeggedAuthFilter.java:95) ~[na:na]
	at com.atlassian.jwt.internal.servlet.JwtAuthFilter.doFilter(JwtAuthFilter.java:32) ~[na:na]
	at com.atlassian.analytics.client.filter.DefaultAnalyticsFilter.doFilter(DefaultAnalyticsFilter.java:38) ~[na:na]
	at com.atlassian.analytics.client.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:39) ~[na:na]
	at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doBeforeBeforeLoginFilters(BeforeLoginPluginAuthenticationFilter.java:87) ~[classes/:na]
	at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doFilter(BeforeLoginPluginAuthenticationFilter.java:73) ~[classes/:na]
	at com.atlassian.stash.internal.request.DefaultRequestManager.doAsRequest(DefaultRequestManager.java:86) ~[bitbucket-service-impl-4.8.3.jar:na]
	at com.atlassian.stash.internal.hazelcast.ConfigurableWebFilter.doFilter(ConfigurableWebFilter.java:38) ~[classes/:na]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[na:1.8.0_74]
	at java.lang.Thread.run(Unknown Source) ~[na:1.8.0_74]
	... 278 frames trimmed
Caused by: org.postgresql.util.PSQLException: Something unusual has occurred to cause the driver to fail. Please report this exception.
	at org.postgresql.Driver$ConnectThread.getResult(Driver.java:368) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.Driver.connect(Driver.java:288) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at java.sql.DriverManager.getConnection(Unknown Source) ~[na:1.8.0_74]
	at java.sql.DriverManager.getConnection(Unknown Source) ~[na:1.8.0_74]
	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:153) ~[spring-jdbc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:144) ~[spring-jdbc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:155) ~[spring-jdbc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.jdbc.datasource.SingleConnectionDataSource.initConnection(SingleConnectionDataSource.java:224) ~[spring-jdbc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.jdbc.datasource.SingleConnectionDataSource.getConnection(SingleConnectionDataSource.java:164) ~[spring-jdbc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) ~[spring-jdbc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77) ~[spring-jdbc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	... 32 common frames omitted
java.lang.NoClassDefFoundError: com/sun/jna/platform/win32/Win32Exception
	at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:552) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:203) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:65) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:146) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:35) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:47) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.jdbc42.AbstractJdbc42Connection.<init>(AbstractJdbc42Connection.java:21) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.jdbc42.Jdbc42Connection.<init>(Jdbc42Connection.java:28) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.Driver.makeConnection(Driver.java:415) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.Driver.access$100(Driver.java:47) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.Driver$ConnectThread.run(Driver.java:325) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at java.lang.Thread.run(Unknown Source) ~[na:1.8.0_74]
java.lang.ClassNotFoundException: com.sun.jna.platform.win32.Win32Exception
	at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.8.0_74]
	at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:552) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:203) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:65) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:146) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:35) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:47) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.jdbc42.AbstractJdbc42Connection.<init>(AbstractJdbc42Connection.java:21) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.jdbc42.Jdbc42Connection.<init>(Jdbc42Connection.java:28) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.Driver.makeConnection(Driver.java:415) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.Driver.access$100(Driver.java:47) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at org.postgresql.Driver$ConnectThread.run(Driver.java:325) ~[postgresql-9.4-1202-jdbc42.jar:9.4]
	at java.lang.Thread.run(Unknown Source) ~[na:1.8.0_74]
	... 2 frames trimmed

Diagnosis

Environment

  • Windows Server
  • Integrated authentication for authenticating to PostgreSQL.

Diagnostic Steps

  • Try connecting to PostgreSQL from Bitbucket Server with the user used for the integrated authentication.

Cause

Bitbucket Server requires a dedicated user local to PostgreSQL for the connection.

Resolution

  1. In PostgreSQL, created a dedicated user as instructed at Connect Bitbucket to PostgreSQL, and a database owned by this user.
  2. Re-try the connection from Bitbucket Server using this new user.

 

Last modified on Nov 28, 2016

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.