Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JIRA Scripts Failing after Upgrade - [Static type checking] - Cannot find matching method

Chris Rescigno April 24, 2018

I'm trying to upgrade my JIRA versions to latest-greatest as I inherited a system that is way behind.  When running the upgrade in our test environment, I am getting some script failures that I found after the fact.

In our current JIRA, I see these errors when running the script registry:

  • Script209.groovy:60 Public use of this method is deprecated - please use ComponentAccessor instead. Since v5.2. @ line 60, column 39.
  • Script209.groovy:60 Get this component injected in your constructor or use ComponentAccessor for static access instead. Since v5.2. @ line 60, column 39.

 

These are the lines in question:

def ProjectManager     projectMgr   = ComponentManager.getInstance().getProjectManager()
def IssueManager       issueMgr     = ComponentManager.getInstance().getIssueManager()
def IssueLinkManager   linkMgr      = ComponentManager.getInstance().getIssueLinkManager()
def CustomFieldManager custFldMgr   = ComponentManager.getInstance().getCustomFieldManager()
def IssueFactory       issueFactory = ComponentManager.getInstance().getIssueFactory()

 

 

For instance on ProjectManager, I tried changing it to the below but it gives an error after restarting JIRA.

def ProjectManager     projectMgr   = ComponentAccessor.getProjectManager()

 

Script78.groovy:60 [Static type checking] - Cannot find matching method com.atlassian.jira.ComponentManager#getProjectManager(). Please check if the declared type is right and if the method exists.

 

 

I'm new to groovy, etc... so I'm not sure how to continue with this.

 

 

 

 

 

 

 

 

 

 

 

1 answer

0 votes
Chris Rescigno April 24, 2018

I was able to get passed that issue.  Now on to the next.

The script is calling the IssueManager interface.  Originally it looked like this before I changed from ComponentManager to ComponentAccessor:

 subTask = issueMgr.createIssue( currentUserObj, newIssue )

 

Looking at the API doc, I changed to this but am getting an error:

     subTask = issueMgr.createIssueObject(currentUser, newIssue)

 

Script79.groovy:120 [Static type checking] - Cannot find matching method com.atlassian.jira.issue.IssueManager#createIssueObject(com.atlassian.crowd.model.user.User, com.atlassian.jira.issue.MutableIssue). Please check if the declared type is right and if the method exists. @ line 120, column 15.

 

 

Here is where currentUser and newIssue is being defined:

// get current user
String currentUser = ( (WorkflowContext) theTransientVars.get("context") ).getCaller()
User currentUserObj = UserUtils.getUser( currentUser )

def MutableIssue    newIssue    = null

 

    // create new issue object and assign some things
    newIssue = issueFactory.getIssue()
    newIssue.setSummary( "RP_" + theIssue.summary )
    newIssue.setProjectObject( theProject )
    newIssue.setIssueTypeObject( newIssueType )
    newIssue.description = theIssue.description
    newIssue.reporter = theIssue.getReporter()

Chris Rescigno April 24, 2018

This is the error I'm seeing in the atlassian-jira.log:

 

org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'crescigno(crescigno)' with class 'com.atlassian.jira.user.DelegatingApplicationUser' to class 'com.atlassian.crowd.model.user.User'
    at CreateRpIssues.run(CreateRpIssues.groovy:53)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events