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

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

症状

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)
...

原因

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

ソリューション

  •  

  •  

  • 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>%';
    
    

    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

    IDCONFIGNAME説明FIELDIDCUSTOMFIELD
    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
    10140名前
  • 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>%';
  • 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.
最終更新日 2016 年 8 月 8 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.