Cannot create new issue after upgrade due to java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

Fail to create an issue (no error in the UI) and the following appears in the atlassian-jira.log:

2012-11-07 12:01:53,289 http-8080-2 ERROR [500ErrorPage.jsp] Exception caught in 500 page java.lang.String cannot be cast to java.lang.Long
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long
at com.atlassian.jira.issue.customfields.impl.MultiSelectCFType.getDefaultValue(MultiSelectCFType.java:166)
at com.atlassian.jira.issue.customfields.impl.MultiSelectCFType.getDefaultValue(MultiSelectCFType.java:71)
at com.atlassian.jira.issue.fields.CustomFieldImpl.populateDefaults(CustomFieldImpl.java:580)
...

Cause

The default value of the Multiselect or Select Custom Field is not migrated to a correct format in the database

Resolution

  •  

  •  

  • Search for the invalid default value by running this query (select the one the corresponds to your database type. For HSQL, you can use the MySQL syntax):

    For MySQL

    SELECT * FROM genericconfiguration where DATAKEY IN (SELECT b.id FROM customfield a, fieldconfiguration b where b.FIELDID=INSERT('customfield_',13,5,a.id) AND CUSTOMFIELDTYPEKEY like '%select%') AND xmlvalue like'%<string>%';
    

    For PSQL

    SELECT * FROM genericconfiguration where datakey IN (SELECT CAST (b.id AS CHAR (10))  FROM customfield a, fieldconfiguration b where b.FIELDID=CONCAT('customfield_',a.id) AND CUSTOMFIELDTYPEKEY like '%select%') AND xmlvalue like'%<string>%';
    
    

    For Oracle

     SELECT * FROM genericconfiguration where DATAKEY IN(SELECT b.id FROM customfield a, fieldconfiguration b where b.FIELDID='customfield_'|| a.id AND CUSTOMFIELDTYPEKEY like '%select%') AND xmlvalue like'%<string>%';

    For MSSQL

    SELECT * FROM genericconfiguration
    WHERE DATAKEY IN
    (
        SELECT b.id FROM
        customfield a, fieldconfiguration b
        where b.FIELDID = ('customfield_' + cast(a.id as varchar))
        AND a.CUSTOMFIELDTYPEKEY LIKE '%select%'
    )
    AND xmlvalue LIKE '%<string>%';

    This will result on the following

    IDDATATYPEDATAKEYXMLVALUE
    10080DefaultValue10150<list> <string>Functionality</string></list>
  • Take note of the value in the DATAKEY column of the result set. This is theaffectedcustomfield ID. In our example, this ID is 10150.
  • Run the query below replacing the example ID in the WHERE clause with the customfield ID that you just discovered.

    SELECT * FROM FIELDCONFIGURATION WHERE ID=10150

    This willresultonthefollowing

    IDCONFIGNAMEDESCRIPTIONFIELDIDCUSTOMFIELD
    10150Default Configuration for Test GroupDefault configuration generated by JIRAcustomfield_10140 
  • Take note of the value in the FIELDID column.  In our example, this value is customfield_10140
  • Run the query below replacing the ID in the WHERE clause with the numerical value from the FIELDID you just discovered. (for example, customfield_10140 = 10140)

     

    SELECT id, cfname FROM CUSTOMFIELD WHERE ID=10140

    This willresultonthefollowing:

    IDCFNAME
    10140Name
  • Take note of the value in the CFNAME column. This is the custom field's name. You will need this to find the field in JIRA's admin section later on.

  • Delete the affected default value by running the following query. There is no need to replace anything in this query.

    DELETE FROM genericconfiguration where DATAKEY IN (SELECT b.id FROM customfield a, fieldconfiguration b where b.FIELDID=INSERT('customfield_',13,5,a.id) AND CUSTOMFIELDTYPEKEY like '%select%');

    For MSSQL

    DELETE FROM genericconfiguration
    WHERE DATAKEY IN
    (
        SELECT b.id FROM
        customfield a, fieldconfiguration b
        where b.FIELDID = ('customfield_' + cast(a.id as varchar))
        AND a.CUSTOMFIELDTYPEKEY LIKE '%select%'
    )
    AND xmlvalue LIKE '%<string>%';
  • Restart JIRA
  • Log into JIRA as an Admin. Navigate to Administration > Customfield, locate the custom field in question (you got the name earlier) and set the default value for the affected custom field manually.
Last modified on Aug 8, 2016

Was this helpful?

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