Script Runner error when upgrading JIRA

After we upgraded to JIRA 6.3.9 and installed script runner 3.0.6, we could not reindex JIRA and found the following error in the log:

2014-11-04 23:35:43,655 IssueIndexer:thread-1 ERROR administrator 1415x440x1 xwt3vo 0:0:0:0:0:0:0:1 /secure/admin/IndexReIndex.jspa [onresolve.scriptrunner.customfield.GroovyCustomField] Script field failed on issue: XXXX-10122, field: My Field Name

com.atlassian.jira.issue.index.SearchUnavailableException

 at com.atlassian.jira.issue.index.DefaultIndexManager.getIssueSearcher(DefaultIndexManager.java:832)

 at com.atlassian.util.profiling.object.ObjectProfiler.profiledInvoke(ObjectProfiler.java:83)

 at com.atlassian.jira.config.component.SwitchingInvocationHandler.invoke(SwitchingInvocationHandler.java:28)

 at com.sun.proxy.$Proxy14.getIssueSearcher(Unknown Source)

 at com.atlassian.jira.issue.search.SearchProviderFactoryImpl.getSearcher(SearchProviderFactoryImpl.java:27)

 at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.search(LuceneSearchProvider.java:415)

 at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.search(LuceneSearchProvider.java:93)

 at com.atlassian.jira.issue.search.providers.LuceneSearchProvider.search(LuceneSearchProvider.java:82)

 at com.atlassian.jira.bc.issue.search.DefaultSearchService.search(DefaultSearchService.java:116)

 at com.atlassian.jira.bc.issue.search.SearchService$search$0.call(Unknown Source)

 at Script6.run(Script6.groovy:47)

------------------------------

 

After that, we uninstall script runner and reindex JIRA in success. Would you like to look into this issue and give us suggestions please?

7 answers

1 vote

Somewhere between 6.3 and 6.3.7 jira has changed to throw this exception during stop-the-world reindexing. I don't know what the solution is, as it makes sense that you can't do a search during reindexing.

Please could you watch: https://jamieechlin.atlassian.net/browse/GRV-569

0 votes

It's your code failing, not mine. Look at the script code for the field "My Field Name". Admin -> Script Fields. 

Feel free to post the code.

But it sounds like you are doing a search from the field... which is relatively common, but is not going to work during a full reindex. Will need to have a think about that one.

Hi Jamie,

We believe we are having the same problem where there is a search in a scripted custom field is preventing a re-index. Here's the sequence of events:

1- Upgrade of Script Runner from an unknown previous version to 3.0.6

2- Upgrade of JIRA from 6.2.8 to 6.3.9

3- Unable to re-index- Log extract:

2014-11-11 17:40:59,278 IssueIndexer:thread-4 ERROR AZEMTCHI 1033x17124x1 16yuonn 10.10.6.70 /secure/admin/jira/IndexReIndex.jspa [onresolve.scriptrunner.customfield.GroovyCustomField] Script field failed on issue: INFOSYS-232, field: Deployment Procedure from AIS Project Issue
java.lang.NullPointerException: Cannot invoke method getDirectoryUser() on null object
at Script2.run(Script2.groovy:31)
2014-11-11 17:40:59,277 IssueIndexer:thread-6 ERROR AZEMTCHI 1033x17124x1 16yuonn 10.10.6.70 /secure/admin/jira/IndexReIndex.jspa [onresolve.scriptrunner.customfield.GroovyCustomField] *************************************************************************************
2014-11-11 17:40:59,279 IssueIndexer:thread-6 ERROR AZEMTCHI 1033x17124x1 16yuonn 10.10.6.70 /secure/admin/jira/IndexReIndex.jspa [onresolve.scriptrunner.customfield.GroovyCustomField] Script field failed on issue: INFOSYS-229, field: Deployment Linked Issues
java.lang.NullPointerException: Cannot invoke method getDirectoryUser() on null object
at Script19.run(Script19.groovy:33)
2014-11-11 17:40:59,263 IssueIndexer:thread-5 ERROR AZEMTCHI 1033x17124x1 16yuonn 10.10.6.70 /secure/admin/jira/IndexReIndex.jspa [onresolve.scriptrunner.customfield.GroovyCustomField] *************************************************************************************
2014-11-11 17:40:59,279 IssueIndexer:thread-5 ERROR AZEMTCHI 1033x17124x1 16yuonn 10.10.6.70 /secure/admin/jira/IndexReIndex.jspa [onresolve.scriptrunner.customfield.GroovyCustomField] Script field failed on issue: INFOSYS-231, field: Deployment Procedure from AIS Project Issue
java.lang.NullPointerException: Cannot invoke method getDirectoryUser() on null object
at Script2.run(Script2.groovy:31)
2014-11-11 17:40:59,262 IssueIndexer:thread-2 ERROR AZEMTCHI 1033x17124x1 16yuonn 10.10.6.70 /secure/admin/jira/IndexReIndex.jspa [onresolve.scriptrunner.customfield.GroovyCustomField] *************************************************************************************
2014-11-11 17:40:59,280 IssueIndexer:thread-2 ERROR AZEMTCHI 1033x17124x1 16yuonn 10.10.6.70 /secure/admin/jira/IndexReIndex.jspa [onresolve.scriptrunner.customfield.GroovyCustomField] Script field failed on issue: HELPDESK-126, field: Deployment Related Issues List
java.lang.NullPointerException: Cannot invoke method getDirectoryUser() on null object
at Script5.run(Script5.groovy:33)
2014-11-11 17:40:59,261 IssueIndexer:thread-10 ERROR AZEMTCHI 1033x17124x1 16yuonn 10.10.6.70 /secure/admin/jira/IndexReIndex.jspa [onresolve.scriptrunner.customfield.GroovyCustomField] *************************************************************************************
2014-11-11 17:40:59,280 IssueIndexer:thread-10 ERROR AZEMTCHI 1033x17124x1 16yuonn 10.10.6.70 /secure/admin/jira/IndexReIndex.jspa [onresolve.scriptrunner.customfield.GroovyCustomField] Script field failed on issue: INFOSYS-230, field: Issues in Release
java.lang.NullPointerException: Cannot invoke method getDirectoryUser() on null object
at Script94.run(Script94.groovy:36)
2014-11-11 17:40:59,285 IssueIndexer:thread-5 ERROR AZEMTCHI 1033x17124x1 16yuonn 10.10.6.70 /secure/admin/jira/IndexReIndex.jspa [onresolve.scriptrunner.customfield.GroovyCustomField] *************************************************************************************
2014-11-11 17:40:59,285 IssueIndexer:thread-5 ERROR AZEMTCHI 1033x17124x1 16yuonn 10.10.6.70 /secure/admin/jira/IndexReIndex.jspa [onresolve.scriptrunner.customfield.GroovyCustomField] Script field failed on issue: INFOSYS-231, field: Deployment Related Issues List
java.lang.NullPointerException: Cannot invoke method getDirectoryUser() on null object
at Script5.run(Script5.groovy:33)
2014-11-11 17:40:59,285 IssueIndexer:thread-4 ERROR AZEMTCHI 1033x17124x1 16yuonn 10.10.6.70 /secure/admin/jira/IndexReIndex.jspa [onresolve.scriptrunner.customfield.GroovyCustomField] *************************************************************************************
2014-11-11 17:40:59,286 IssueIndexer:thread-4 ERROR AZEMTCHI 1033x17124x1 16yuonn 10.10.6.70 /secure/admin/jira/IndexReIndex.jspa [onresolve.scriptrunner.customfield.GroovyCustomField] Script field failed on issue: INFOSYS-232, field: Deployment Related Issues List
java.lang.NullPointerException: Cannot invoke method getDirectoryUser() on null object
at Script5.run(Script5.groovy:33)

 

What I am trying to understand is  why this has started happening since the upgrade of Script Runner and JIRA. We have asked the customer to remark out the offending scripted fields and see if they can re-index. I'm also open to suggestions on how we can resolve this problem permanently.

 

Thanks,

Chris

 

 

Just to add a correction to my previous post- This has always been a problem and is not a problem that occurred after the upgrade. Just thought I would make that clear.

I don't think this is related to the OP's question, so I'd create a new question including the field script.

Hi Jamie,

i have the same problem like Tracy, after upgrading for JIRA5.2 and Scriptrunner 2 to JIRA 6.3 and Scriptrunner3.

Also, my indexing time increased with the upgrade from 40 minutes to about 10 hours. Don't know it this has something to do with this. 

My scripted worked fine with JIRA5.2 and Scriptrunner2 and it also looks to work fine with JIRA 6.3 and Scriptrunner3. I don't get any errors, just the output as expected.

Here's the Script:

//zeigt verwandte Meldungen nach Kartennummer und Autor
enableCache = {false}

import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.jira.web.bean.PagerFilter

SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
UserUtil userUtil = ComponentAccessor.getUserUtil()
User user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
IssueManager issueManager = ComponentAccessor.getIssueManager()
 
if (!user) {
    user = userUtil.getUserObject('someuser')
}
 
List<Issue> issuesByCard = null
List<Issue> issuesByMA = null

if ( getCustomFieldValue("Kartennummer") ) {
    String Kartennummer=getCustomFieldValue("Kartennummer")
    println "DEBUG Kartennummer: ${Kartennummer}"
    jqlSearchByCard = "project = BEM and issuetype = eC-Ausweis and Kartennummer ~ '${Kartennummer}' and not issuekey = ${issue.key} order by updated"
    if ( Kartennummer ) {
        SearchService.ParseResult parseResult1 = searchService.parseQuery(user, jqlSearchByCard)
        if (parseResult1.isValid()) {
            def searchResult1 = searchService.search(user, parseResult1.getQuery(), PagerFilter.getUnlimitedFilter())
            // Transform issues from DocumentIssueImpl to the "pure" form IssueImpl (some methods don't work with DocumentIssueImps)
            issuesByCard = searchResult1.issues.collect {issueManager.getIssueObject(it.id)}
            println "DEBUG issuesByCard: ${issuesByCard}"
        } else {
            log.error("Invalid JQL: " + jqlSearchByCard);
        }
    }
}
if ( getCustomFieldValue("betroffene Person") ) {
    String Mitarbeiter=getCustomFieldValue("betroffene Person").name
    println "DEBUG Mitarbeiter: ${Mitarbeiter}"
    jqlSearchByMA = "project = BEM and issuetype = eC-Ausweis and 'betroffene Person' = '${Mitarbeiter}' and not issuekey = ${issue.key} order by updated"
    if ( Mitarbeiter ) {
        SearchService.ParseResult parseResult2 = searchService.parseQuery(user, jqlSearchByMA)
        if (parseResult2.isValid()) {
            def searchResult2 = searchService.search(user, parseResult2.getQuery(), PagerFilter.getUnlimitedFilter())
            issuesByMA = searchResult2.issues.collect {issueManager.getIssueObject(it.id)}
            println "DEBUG issuesByMA: ${issuesByMA}"
        } else {
            log.error("Invalid JQL: " + jqlSearchByMA);
        }
    }
}
 
String issueList = ""
if ( issuesByCard ) {
    String HeaderSingleIssueByCard = "Verwandte Meldungen nach Kartennummer: <br>"
    issueList=issueList + HeaderSingleIssueByCard
    for ( singleIssueByCard in issuesByCard ) {
        Date date = Date.parse("yyyy-MM-dd hh:mm:ss.S","${singleIssueByCard.updated}")
        String issueUpdatedDate = date.format("dd.MM.yyyy")     
        issueList = issueList + "<a href=/jira/browse/" + singleIssueByCard + " target=newwinecausweis>${singleIssueByCard}</a>  (Status: ${singleIssueByCard.status.name}, letzte Aktualisierung: ${issueUpdatedDate})<br>"
    }
}
if ( issuesByMA ) {
    String HeaderSingleIssueByMA = "Verwandte Meldungen nach Mitarbeiter: <br>"
    issueList=issueList + HeaderSingleIssueByMA
    for ( singleIssueByMA in issuesByMA ) {
        Date date = Date.parse("yyyy-MM-dd hh:mm:ss.S","${singleIssueByMA.updated}")
        String issueUpdatedDate = date.format("dd.MM.yyyy")     
        issueList = issueList + "<a href=/jira/browse/" + singleIssueByMA + " target=newwinecausweis>${singleIssueByMA}</a> (Status: ${singleIssueByMA.status.name}, letzte Aktualisierung: ${issueUpdatedDate})<br>"
    }
}

if ( issueList != "" ) {
    return(issueList);
} else {
    return ("Keine Daten gefunden");
}

Update: i looks like the bug is located in the interaction of JIRA-reindexing and the script itself: the script includes a JQL search. But during a indexing progress you can't search. That's the cause, why the script fails and also increases the indexing time extremely.

Solution: disabling the search for the scripted fields.

@Jamie: with JIRA5.2/Scriptrunner2 the behavior was other (no errors occurred).

Hi Jamie,

We are having some issues with script runner which is a great plug-in. We do not have any custom code in our JIRA instance. Script runner was running great on JIRA 6.2.7. But JIRA gave us the following errors after we have upgrade JIRA to 6.3.11. We are having Script runner 3.0.7.

========================================================================================

2014-12-21 21:12:04,031 JiraTaskExectionThread-3 ERROR jerry.lee@xxxx.com 1255x17354x1 17h7cqv 67.170.248.236 /secure/admin/jira/IndexReIndex.jspa

[onresolve.scriptrunner.customfield.GroovyCustomField] *************************************************************

2014-12-21 21:12:04,031 JiraTaskExectionThread-3 ERROR jerry.lee@xxxx.com 1255x17354x1 17h7cqv 67.170.248.236 /secure/admin/jira/IndexReIndex.jspa [onresolve.scriptrunner.customfield.GroovyCustomField] Script field failed on issue: PPV-24, field: Release Week

java.lang.NullPointerException

=======================================================================================

Thanks,

Jerry

 

Hello... I think you do have some custom code. It's telling you you have a field called Release Week, which uses a script to calculate its value. That's failing.

Thanks for your quick response, Jamie. We may have created a custom field of "Release Week" before. But I can not find it anymore within our JIRA instance. I guess somebody created and then deleted it. Will this cause this issue?

Go to admin -> Script Fields. If you don't see it there then the CF has been removed. If not it's still there...

Thanks Jamie. I have found it following your comment. Deleted "Release Week" custom field already. Hope the errors will be gone. Will update here later.

I found a fix to this. Usually this happens to a script field (custom field that has a JQL function in it). The fix is to go to Admin -> Issues -> Custom Fields > choose your field (Edit) , and the choose "None" for the searcher template.

This will fix the issue because re-index will no longer trying to evaluate the scripted field. I have lowered the re-index time from 10 hours to 18 minutes.

 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 25, 2018 in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

465 views 7 5
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you