Upgrade Renders Bad SQL Grammar Nested Exception Invalid Object Name 'cwd_application'
After upgrading Confluence from 3.4.x or an older version to 3.5.x or 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 login, a similar error can occur but this time pointing to the
CWD_* tables weren't created properly in the upgrade process.
In 3.5.x, a 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:
- 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.
- The build number (<confluence-home>/confluence.cfg.xml) from the current version of Confluence is incorrect and this won't trigger the upgrade steps.
- 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
- Shutdown Confluence
- Roll back Confluence to the previous version before the upgrade attempt. (Restore the database backup and home_folder backup)
Proceed with the upgrade steps exactly as in the upgrade documentation.
Resolution for cause 2
- Rollback your database to a point pre-upgrade.
- Run this query to remove the rows of the extra buildnumbers:
Note: Where ? is the CONFVERSIONIDof all extra buildnumbers.
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.
- Try to proceed the upgrade again.
Resolution for cause 3
- Shutdown Confluence
Roll back Confluence to the previous version before the upgrade attempt. (Restore the database backup and home_folder backup)
- Create an XML backup and import into a new Confluence instance with the same version.
- Proceed with the upgrade steps exactly as in the upgrade documentation.