Getting error messages SQLServerException: Invalid object name in Jira
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the server and data center platforms.
Problem
The following exception is logged while working with Jira in the atlassian-jira.log file.
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name "productlicense".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:256)
Environment
Microsoft SQL Server is used as database
Diagnosis
Check what is a default schema assigned to the database user used by Jira. Execute this SQL command on behalf of that user:
SELECT schema_name();
Cause
Database user used by Jira has a default schema as "dbo" or some other schema, and not Jira database schema. When this happens, and the server receives SQL commands that are not fully qualified tables names, the database server does not know in which schema to look up the tables, and will error out with "Invalid object name" message.
Resolution
Remap a correct default schema to the database user used by Jira (the schema name can be obtained via dbconfig.xml):
ALTER USER <jira_user> WITH DEFAULT_SCHEMA = jiraschema;