Upgrading Confluence from 3.4.x to 3.5.x or never will throw an error - Bad SQL Grammar Nested Exception Invalid Object Name 'cwd_application'

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

After upgrading Confluence from 3.4.x or an older version to 3.5.x or a newer version, the following error appears.

org.springframework.jdbc.BadSqlGrammarException: Hibernate operation: 
Unable to perform find; bad SQL grammar []; nested exception is 
java.sql.SQLException: Invalid object name 'cwd_application'.
    at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:107) 
caused by: java.sql.SQLException: Invalid object name 'cwd_application'.
    at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368) 

Additionally, if a user tries to log in, a similar error can occur but this time pointing to the CWD_USER table

Cause

The CWD_* tables weren't created properly in the upgrade process.

In 3.5.x, new user management was introduced using Crowd architecture to manage users in Confluence and implementing user directories in order to facilitate user management and integration between applications.

There are some known causes for that:

  1. The database from an older version was imported directly into 3.5.x or newer Confluence version database and thus, the upgrade automated steps didn't run as expected.
  2. The build number (<confluence-home>/confluence.cfg.xml) from the current version of Confluence is incorrect and this won't trigger the upgrade steps.
  3. The primary keys on the database do not exist. Can occur more often in SQL server but could also happen in other databases.

Resolution for cause 1

  1. Shutdown Confluence
  2. Rollback Confluence to the previous version before the upgrade attempt. (Restore the database backup and home_folder backup)
  3. Proceed with the upgrade steps exactly as in the upgrade documentation.

Resolution for cause 2

  1. Rollback your database to a point pre-upgrade.
  2. Run this query to remove the rows of the extra buildnumbers:
    Note: Where ? is the CONFVERSIONIDof all extra buildnumbers.

    Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.


    DELETE FROM CONFVERSION WHERE CONFVERSIONID IN (?,?,...);
  3. Be sure that the correct buildnumber of your current Confluence version is set into your confluence.cfg.xml file, which is located at Confluence home.

  4. Try to proceed with the upgrade again.

Resolution for cause 3

  1. Shutdown Confluence
  2. Rollback Confluence to the previous version before the upgrade attempt. (Restore the database backup and home_folder backup)

  3. Create an XML backup and import it into a new Confluence instance with the same version.
  4. Proceed with the upgrade steps exactly as in the upgrade documentation.



Last modified on Aug 24, 2021

Was this helpful?

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