Installation with Docker-Compose failed
Asked by heiko h?fele:

Hi Community

I'm trying to install confluence via docker file. Unfortunately the installation aborts with the following error message:

HTTP Status 500 -- Internal Server Error {#toc-hId--1359169422}
---------------------------------------------------------------

*** ** * ** ***

**Type** Exception Report

**Message** com.atlassian.util.concurrent.LazyReference$InitializationException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantedTransactionManager' defined in class path resource \[databaseSubsystemContext.xml\]: Invocation of init method failed; nested exception is com.atlassian.util.concurrent.LazyReference$InitializationException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantedLocalSessionFactoryBean5' defined in class path resource \[productionDatabaseContext.xml\]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: premature SessionFactory initialisation, Hibernate properties have not yet been persisted in confluence.cfg.xml

**Beschreibung** The server encountered an unexpected condition that prevented it from fulfilling the request.

**Exception**

```
java.util.concurrent.CompletionException: com.atlassian.util.concurrent.LazyReference$InitializationException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantedTransactionManager' defined in class path resource 

...
```

**Root Cause**

```
com.atlassian.util.concurrent.LazyReference$InitializationException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantedTransactionManager' defined in class path resource [databaseSubsystemContext.xml]: Invocation of init method failed; nested exception is com.atlassian.util.concurrent.LazyReference$InitializationException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantedLocalSessionFactoryBean5' defined in class path resource [productionDatabaseContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: premature SessionFactory initialisation, Hibernate properties have not yet been persisted in confluence.cfg.xml	com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:149)	com.atlassian.util.concurrent.LazyReference.get(LazyReference.java:112)	com.atlassian.confluence.tenant.TenantGate.getDelegate(TenantGate.java:166)	com.atlassian.confluence.tenant.TenantGate$3.getTarget(TenantGate.java:210)	...	
```

**Root Cause**

```
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantedTransactionManager' defined in class path resource [databaseSubsystemContext.xml]: Invocation of init method failed; nested exception is com.atlassian.util.concurrent.LazyReference$InitializationException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantedLocalSessionFactoryBean5' defined in class path resource [productionDatabaseContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: premature SessionFactory initialisation, Hibernate properties have not yet been persisted in confluence.cfg.xml	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778)	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)	org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)	org.springframework.beans.factory.support.CglibSubclassingInstantiationStrategy$LookupOverrideMethodInterceptor.intercept(CglibSubclassingInstantiationStrategy.java:290)	com.atlassian.confluence.tenant.TenantGate$$EnhancerBySpringCGLIB$$9b6ca63a.createTenantedDelegate(<generated>)	com.atlassian.confluence.tenant.TenantGate$2.create(TenantGate.java:71)	com.atlassian.util.concurrent.LazyReference$Sync.run(LazyReference.java:325)	com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:143)	com.atlassian.util.concurrent.LazyReference.get(LazyReference.java:112)	com.atlassian.confluence.tenant.TenantGate.getDelegate(TenantGate.java:166)	com.atlassian.confluence.tenant.TenantGate$3.getTarget(TenantGate.java:210)	org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192)	com.sun.proxy.$Proxy216.getTransaction(Unknown Source)	org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:475)			
```

**Root Cause**

```
com.atlassian.util.concurrent.LazyReference$InitializationException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantedLocalSessionFactoryBean5' defined in class path resource [productionDatabaseContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: premature SessionFactory initialisation, Hibernate properties have not yet been persisted in confluence.cfg.xml	com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:149)	com.atlassian.util.concurrent.LazyReference.get(LazyReference.java:112)	com.atlassian.confluence.tenant.TenantGate.getDelegate(TenantGate.java:166)	com.atlassian.confluence.tenant.TenantGate$3.getTarget(TenantGate.java:210)	org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192)	com.sun.proxy.$Proxy214.getProperties(Unknown Source)	com.atlassian.hibernate.adapter.bridge.factory.SessionFactoryBridgeAssociations.associate(SessionFactoryBridgeAssociations.java:78)	com.atlassian.hibernate.adapter.bridge.factory.SessionFactoryBridge.lambda$new$1(SessionFactoryBridge.java:43)	com.atlassian.hibernate.adapter.util.Lazy.get(Lazy.java:23)	com.atlassian.hibernate.adapter.bridge.factory.SessionFactoryV2orV5BridgeProxy.getSessionFactoryV5(SessionFactoryV2orV5BridgeProxy.java:66)	com.atlassian.hibernate.adapter.adapters.session.SessionFactoryV2Adapter.getConnectionProvider(SessionFactoryV2Adapter.java:327)	com.atlassian.hibernate.adapter.bridge.factory.SessionFactoryV2orV5BridgeProxy.getConnectionProvider(SessionFactoryV2orV5BridgeProxy.java:262)	org.springframework.orm.hibernate.SessionFactoryUtils.getDataSource(SessionFactoryUtils.java:116)	org.springframework.orm.hibernate.HibernateTransactionManager.afterPropertiesSet(HibernateTransactionManager.java:352)	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837)	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774)	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean
```

**Root Cause**

```
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantedLocalSessionFactoryBean5' defined in class path resource [productionDatabaseContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: premature SessionFactory initialisation, Hibernate properties have not yet been persisted in confluence.cfg.xml	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778)	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)	org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)	org.springframework.beans.factory.support.CglibSubclassingInstantiationStrategy$LookupOverrideMethodInterceptor.intercept(CglibSubclassingInstantiationStrategy.java:290)	com.atlassian.confluence.tenant.TenantGate$$EnhancerBySpringCGLIB$$c402d44d.createTenantedDelegate(<generated>)	com.atlassian.confluence.tenant.TenantGate$2.create(TenantGate.java:71)	com.atlassian.util.concurrent.LazyReference$Sync.run(LazyReference.java:325)	com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:143)	com.atlassian.util.concurrent.LazyReference.get(LazyReference.java:112)	com.atlassian.confluence.tenant.TenantGate.getDelegate(TenantGate.java:166)	com.atlassian.confluence.tenant.TenantGate$3.getTarget(TenantGate.java:210)	org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192)	com.sun.proxy.$Proxy214.getProperties(Unknown Source)	com.atlassian.hibernate.adapter.bridge.factory.SessionFactoryBridgeAssociations.associate(SessionFactoryBridgeAssociations.java:78)	com.atlassian.hibernate.adapter.bridge.factory.SessionFactoryBridge.lambda$new$1(SessionFactoryBridge.java:43)	com.atlassian.hibernate.adapter.util.Lazy.get(Lazy.java:23)	com.atlassian.hibernate.adapter.bridge.factory.SessionFactoryV2orV5BridgeProxy.getSessionFactoryV5(SessionFactoryV2orV5BridgeProxy.java:66)

....


```

**Hinweis** Der komplette Stacktrace der Ursache ist in den Server logs zu finden

*** ** * ** ***

### Apache Tomcat/9.0.27 {#toc-hId--668607948}

------------------------------------

My system is an ubuntu server 18.04.

The Docker container runs behind an nginx-proxy with LETSENCRYPT

My Docker-compose File:

version: '3'  
services:  
dbc:  
image: postgres:10  
environment:  
POSTGRES_PASSWORD: xxx  
POSTGRES_USER: confluence  
POSTGRES_DB: confluence  
volumes:  
- ./data:/docker-entrypoint-initdb.d  
- ./pgdata:/var/lib/postgresql/data  
restart: always

confluence:  
image: atlassian/confluence-server  
environment:  
ATL_PROXY_NAME: xxx  
ATL_PROXY_PORT: 443  
ATL_TOMCAT_SCHEME: https  
ATL_JDBC_USER: confluence  
ATL_JDBC_PASSWORD: xxxxx  
ATL_DB_TYPE: postgresql  
VIRTUAL_PORT: 8090  
VIRTUAL_HOST: xxx  
LETSENCRYPT_HOST: xxx  
LETSENCRYPT_EMAIL: xxx  
depends_on:  
- dbc  
restart: always

networks:  
default:  
external:  
name: nginx-proxy

i have tried everything possible, but i always get the same error message, can someone please help me?


Answers:
author: James Ponting
body: Hey Heiko,

The error you're seeing is generally caused by Confluence being unable to contact the database. We can see from the error that Confluence hasn't written the database configuration to confluence.cfg.xml yet as it hasn't been able to obtain a connection.

I can see from the above that the database is being configured in the compose file with

```
ATL_JDBC_USER: confluence
ATL_JDBC_PASSWORD: xxxxx
ATL_DB_TYPE: postgresql
```

What's missing here is the database URL. From the [Docker Repository](https://hub.docker.com/r/atlassian/confluence-server/) we have
> It is optionally possible to configure the database from the environment, avoiding the need to do so through the web startup screen.
>
> The following variables are all must all be supplied if using this feature:
>
> * `ATL_JDBC_URL`
>
>   The database URL; this is database-specific.
> * `ATL_JDBC_USER`
>
>   The database user to connect as.
> * `ATL_JDBC_PASSWORD`
>
>   The password for the database user.
> * `ATL_DB_TYPE`
>
>   The type of database; valid supported values are:
>   * `mssql`
>   * `mysql`
>   * `oracle12c`
>   * `postgresql`

I suspect all we need to do is add the ATL_JDBC_URL value to the configuration. There may be other issues to resolve, but we need to get this one fixed first.

Please let us know how you get on :)

Thanks,  
James Ponting  
Premier Support Engineer

comments: author: James Ponting
body: Hi All,

I just saw this question is almost a year old, but hopefully this can help anyone else coming across similar issues.

I'm going to mark this question as accepted as it will resolve the issue in question. There may be additional issues to address, but I think they would be better answered in additional questions.

Also, I hope Heiko was able to get his issue resolved!

Thanks,  
James Ponting  
Premier Support Engineer


Tags: confluence-server

server