Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Getting NoSuchMethod Exception when trying to update an issue

mikola113 March 27, 2017

I've got this piece of code where I'm trying to update the due date field of an issue on IssueEvent

@EventListener
public void onIssueEvent(IssueEvent issueEvent) {
Long eventTypeId = issueEvent.getEventTypeId();
 MutableIssue issue = (MutableIssue)issueEvent.getIssue();
 GregorianCalendar calendar=new GregorianCalendar(2017,7,13,1,13,13);
 issue.setDueDate(new Timestamp(calendar.getTimeInMillis()));
 IssueService issueService=ComponentAccessor.getIssueService();
if(issueService!=null)
System.out.println("Issue service is not null");
 User user=ComponentAccessor.getJiraAuthenticationContext().getUser().getDirectoryUser();
if (user!=null)
System.out.println("The logged in user is "+user.getName());
 IssueInputParameters inputParameters=issueService.newIssueInputParameters();
 inputParameters.setRetainExistingValuesWhenParameterNotProvided(true);
 IssueService.UpdateValidationResult validationResult=issueService.validateUpdate(user,issue.getId(),inputParameters);
 issueService.update(user,validationResult);
 System.out.println("Issue type:"+issue.getIssueTypeObject().getName());
}

For some reason, I get NoSuchMethod exception when execution reaches to the following line:

IssueService.UpdateValidationResult validationResult=issueService.validateUpdate(user,issue.getId(),inputParameters);

I've also tried to use IssueManager to update issue but I get the same exception for "IssueManager.updateIssue" method. What am I doing wrong?

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 28, 2017

You are passing the wrong argument to valiDateUpdate. You should be passing an ApplicationUser object instead of the old User object. Try passing ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() instead.

mikola113 March 28, 2017

But that validateUpdate method does not accept ApplicationUser argument, it accepts only User. And even if it accepted, what relation can it have to the NoSuchMethod exception?

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 29, 2017

What version of JIRA are you on?

mikola113 March 29, 2017

It's 7.2.6

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 29, 2017
mikola113 March 29, 2017

That's pretty strange, then how can I compile and and upload it to the jira? The two system.out.prints print successfully.

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 29, 2017

Maybe you have a different version in your pom? Or your IDE playing with you? wink 

mikola113 March 29, 2017

Yes, Jobin, you are absolutely right. In the pom, it is 

<jira.version>6.0.4</jira.version>.

In fact I downloaded the sample listener plugin from Bitbucket and tried to run it against 7.2.6 I did this because with my own plugin I was getting "Plugin not in valid state..." error. It seems the spring version needs to be set correctly. In the tutorial, for the spring-framework dependency, it says "use the version used by your UPM". Do you happen to know where I can see what spring-framework version the UPM uses, and where I can find that version. Thanks a lot ahead.

TAGS
AUG Leaders

Atlassian Community Events