Getting error "Cannot unwrap to requested type" after upgrading Confluence Data Center

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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

Summary

Confluence fails to start due to missing parameters in the confluence.cfg.xml file.

Environment

Confluence 7.14.x and above

Diagnosis

To confirm if you are running into this situation, the following entries can be found in the atlassian-confuence.log file:

2024-01-10 19:59:13,079 ERROR [Catalina-utility-1] [atlassian.confluence.plugin.BandanaPluginStateStore] load Exception when loading plugins state from the database. Falling back to in memory state.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantedTransactionManager' defined in class path resource [productionDatabaseContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804)
...
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.service.UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]
	at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.unwrap(DriverManagerConnectionProviderImpl.java:252)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
...
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
...
...

Cause

As part of Atlassian's effort to resolve some performance issues, we have changed the default connection pool provider from c3p0 to Hikari after Confluence 7.14.

An upgrade task will make the required changes during the upgrade. Ocasionally, there can be issues while adding the required Hikari parameters to the confluence.cfg.xml  file. In that scenario, Confluence will fail to start after the upgrade.

Solution

The required Hikari parameters can be added manually by following below steps: 

  1. Stop Confluence. 
  2. Back up your confluence.cfg.xml file.
  3. Edit your confluence.cfg.xml file and add the following parameters:

    ...
    ...
        <property name="hibernate.connection.provider_class">com.atlassian.confluence.impl.hibernate.DelegatingHikariConnectionProvider</property>
        <property name="hibernate.hikari.idleTimeout">30000</property>
        <property name="hibernate.hikari.maximumPoolSize">60</property>
        <property name="hibernate.hikari.minimumIdle">20</property>
        <property name="hibernate.hikari.registerMbeans">true</property>
        <property name="spring.datasource.hikari.registerMbeans">true</property>
    ...
    ...
  4. Start Confluence again. 


Last modified on Aug 12, 2024

Was this helpful?

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