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:?]
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
Thank you @MattD, we got this problem finally resolved by reviewing this document: https://bitbucket.org/atlassian/atlassian-rest/src/master/README.md
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Haoyu Zhang please show me how you fixed it
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@trung2204 Here is a solution doc to this question
You might possibly need to refer to other parts of the documentation as well.
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)
...
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:
REST v2:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Haoyu Zhang i fixed it
thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.