Remove h2 dependency when using a non-embedded database

XMLWordPrintable

    • Type: Suggestion
    • Resolution: Unresolved
    • None
    • Component/s: Other
    • None
    • 1
    • 5

      Problem

      The embedded H2 database is only used for testing purposes. For production environments, it's mandatory to use a non-embedded database such as Oracle, MySQL, and PostgreSQL.

      The JDBC drivers for Confluence are available by default at <installation-directory>\confluence\WEB-INF\lib, except for Oracle and MySQL due to licensing constraints.

      However, when using a non-embedded database, it's not possible to delete the h2-x.x.x.jar from this directory, otherwise, Confluence startup will fail.

      How to Reproduce

      1. Stop Confluence
      2. Delete the h2-x.x.x.jar
        rm <installation-directory>\confluence\WEB-INF\lib\h2-x.x.x.jar 
        
      1. Start Confluence
      2. The startup will fail with the following log message on catalina.out:
        2022-04-13 22:28:33,317 ERROR [Catalina-utility-1] [atlassian.confluence.setup.ConfluenceConfigurationListener] contextInitialized An error was encountered while bootstrapping Confluence (see below):
        Error creating bean with name 'healthCheckRegistrar' defined in URL [jar:file:/opt/atlassian/confluence/atlassian-confluence-7.13.3/confluence/WEB-INF/lib/confluence-7.13.3.jar!/bootstrapHealthCheckContext.xml]: Cannot create inner bean 'com.atlassian.confluence.impl.health.checks.HttpThreadsVsDbConnectionsHealthCheck#747cb0bd' of type [com.atlassian.confluence.impl.health.checks.HttpThreadsVsDbConnectionsHealthCheck] while setting constructor argument with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.atlassian.confluence.impl.health.checks.HttpThreadsVsDbConnectionsHealthCheck#747cb0bd' defined in URL [jar:file:/opt/atlassian/confluence/atlassian-confluence-7.13.3/confluence/WEB-INF/lib/confluence-7.13.3.jar!/bootstrapHealthCheckContext.xml]: Cannot resolve reference to bean 'dbConnectionPoolRule' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dbConnectionPoolRule' defined in URL [jar:file:/opt/atlassian/confluence/atlassian-confluence-7.13.3/confluence/WEB-INF/lib/confluence-7.13.3.jar!/bootstrapHealthCheckContext.xml]: Cannot resolve reference to bean 'databaseConfigHelper' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'databaseConfigHelper' defined in URL [jar:file:/opt/atlassian/confluence/atlassian-confluence-7.13.3/confluence/WEB-INF/lib/confluence-7.13.3.jar!/bootstrapHealthCheckContext.xml]: Cannot resolve reference to bean 'hibernateConfig' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateConfig' defined in URL [jar:file:/opt/atlassian/confluence/atlassian-confluence-7.13.3/confluence/WEB-INF/lib/confluence-7.13.3.jar!/bootstrapContext.xml]: Cannot create inner bean 'com.atlassian.h2.DatabaseCreatingServerLifecycle#47838d22' of type [com.atlassian.h2.DatabaseCreatingServerLifecycle] while setting bean property 'h2ServerLifecycle'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.atlassian.h2.DatabaseCreatingServerLifecycle#47838d22' defined in URL [jar:file:/opt/atlassian/confluence/atlassian-confluence-7.13.3/confluence/WEB-INF/lib/confluence-7.13.3.jar!/bootstrapContext.xml]: Cannot create inner bean 'com.atlassian.h2.OpenServerConfig#7084e0c8' of type [com.atlassian.h2.OpenServerConfig] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.atlassian.h2.OpenServerConfig#7084e0c8': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.atlassian.h2.AbstractServerConfig] from ClassLoader
        ...
        Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.atlassian.h2.OpenServerConfig#7084e0c8': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.atlassian.h2.AbstractServerConfig] from ClassLoader [ParallelWebappClassLoader
        Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.atlassian.h2.AbstractServerConfig] from ClassLoader [ParallelWebappClassLoader
        Caused by: java.lang.NoClassDefFoundError: org/h2/tools/Server
        Caused by: java.lang.ClassNotFoundException: org.h2.tools.Server
        

      Suggested Solution

      Remove h2 dependency when not using the embedded H2 database.

      Why This Is Important

      Old JDBC driver versions might represent security risks. Customers will likely not use the H2 database in their environments and this is an additional and unnecessary concern for them.

      Workaround

      Currently, there is no workaround for that. It's mandatory to have the <installation-directory>\confluence\WEB-INF\lib\h2-x.x.x.jar for Confluence startup.

            Assignee:
            Unassigned
            Reporter:
            Cristian Milani (Inactive)
            Votes:
            10 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: