Forums

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

Jira REST plugin does not work after upgrade to 10.3.5 - Could not find a suitable constructor

Haoyu Zhang May 7, 2025

After upgrading to 10.3.5, all my REST plugins stop working.

I did not change any code, and my plugin was referring to this doc: https://developer.atlassian.com/server/framework/atlassian-sdk/rest-plugin-module/#rest-plugin-module 

The error message is below, looks like it's the JAX-RS issue that could not initialize the constructor. I looked over stackoverflow, that said this error happens when annotations were added to interface rather than actual classes, but I did not do it and only follow Jira official documents.


A MultiException has 1 exceptions.  They are:
1. java.lang.NoSuchMethodException: Could not find a suitable constructor in com.***.plugin.ProjectRoleActions class.
A MultiException has 1 exceptions.  They are:
    1. java.lang.NoSuchMethodException: Could not find a suitable constructor in com.***.plugin.ProjectRoleActions class.
    
	at org.jvnet.hk2.internal.Collector.throwIfErrors(Collector.java:65) [hk2-locator-2.6.1.jar:?]
	at org.jvnet.hk2.internal.Utilities.justCreate(Utilities.java:1044) [hk2-locator-2.6.1.jar:?]
	at org.jvnet.hk2.internal.ServiceLocatorImpl.create(ServiceLocatorImpl.java:968) [hk2-locator-2.6.1.jar:?]
	at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1072) [hk2-locator-2.6.1.jar:?]
	at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1064) [hk2-locator-2.6.1.jar:?]
	at org.glassfish.jersey.inject.hk2.AbstractHk2InjectionManager.createAndInitialize(AbstractHk2InjectionManager.java:201) [jersey-hk2-2.42.jar:?]
	at org.glassfish.jersey.inject.hk2.ImmediateHk2InjectionManager.createAndInitialize(ImmediateHk2InjectionManager.java:30) [jersey-hk2-2.42.jar:?]
	at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:123) [jersey-common-2.42.jar:?]
	at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:260) [jersey-server-2.42.jar:?]
	at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:51) [jersey-server-2.42.jar:?]
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:86) [jersey-server-2.42.jar:?]
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:89) [jersey-server-2.42.jar:?]

1 answer

0 votes
MattD
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.
May 7, 2025

You may find more help about this in the developer community, for example
https://community.developer.atlassian.com/t/platform-7-changes-with-jira-10-and-rest-v2-plugin/83478/3

Haoyu Zhang May 9, 2025

Thank you @MattD, we got this problem finally resolved by reviewing this document: https://bitbucket.org/atlassian/atlassian-rest/src/master/README.md

trung2204
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 19, 2025

@Haoyu Zhang please show me how you fixed it

Haoyu Zhang June 19, 2025

@trung2204 Here is a solution doc to this question

https://bitbucket.org/atlassian/atlassian-rest/src/master/UPGRADE_720.md#problem-1-nosuchmethodexception-could-not-find-a-suitable-constructor-in-class 

You might possibly need to refer to other parts of the documentation as well.

 


Problem 1 - NoSuchMethodException : Could not find a suitable constructor in ... class.

Problem

NoSuchMethodException : Could not find a suitable constructor in ... class.

java.lang.NoSuchMethodException: Could not find a suitable constructor in com.atlassian.healthcheck.core.rest.HealthCheckResource class.
at org.glassfish.jersey.inject.hk2.JerseyClassAnalyzer.getConstructor(JerseyClassAnalyzer.java:168)
...

Solution

1. Add javax.inject dependency to the POM, ideally it should be managed by the Platform

<dependency>
    <groupId>jakarta.inject</groupId>
    <artifactId>jakarta.inject-api</artifactId>
    <scope>provided</scope>
</dependency>

2. Add @Inject annotation to the constructor in the resource class to inject the beans.

import javax.inject.Inject;
...

@Path("/hello")
public class HelloWorld {
    @Inject // Add @Inject annotation
    public HelloWorld(UserManager userManager) {
        this.userManager = userManager;
    }
}

Spring @Autowired annotation clarification

REST v1:

  • In REST v1 it is possible to use Spring @Autowired annotation or @Autowired annotation could be omitted and Spring will use that constructor and inject all necessary dependencies. More can be found here: Spring injects dependencies in constructor without @Autowired annotation.

REST v2:

  • The NoSuchMethodException will be thrown if the the resource method is annotated with Spring @Autowired annotation.
  • The @Autowired annotation is no longer supported and should be migrated to the @Inject annotation.
  • @Autowired is Spring specific and @javax.inject.Inject is part of a standard (Java EE / Jakarta EE - JSR-330). It's better to rely on the standard rather than on the specific implementation. It allows the use of other dependency injection libraries.
  • Dependency injection is managed by Jersey and HK2, dependency: org.glassfish.jersey.inject:jersey-hk2.
  • @Inject annotation needs to be added, otherwise there will be an exception mentioned in the description of this problem (java.lang.NoSuchMethodException: Could not find a suitable constructor in ... class).
trung2204
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 19, 2025

@Haoyu Zhang i fixed it
thank you

Like Haoyu Zhang likes this

Suggest an answer

Log in or Sign up to answer