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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,500,321
Community Members
 
Community Events
179
Community Groups

Getting NoSuchMethod Exception when trying to update an issue

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

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.

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?

What version of JIRA are you on?

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

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

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