I am developing rest plugin for jira atlassian and I have this kind of problem. every time I want that my apis are showing up I need to add empty constructor to my new api in this format
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@Path("/import-issues")
public class ImportIssuesRestResource {
private ImportIssuesAction importIssuesAction;
public ImportIssuesRestResource() {
}
public ImportIssuesRestResource(final ImportIssuesAction importIssuesAction) {
this.importIssuesAction = importIssuesAction;
}
@GET
@Path("issueNumber")
@Produces(MediaType.APPLICATION_JSON)
public Response getFields() {
return Response.ok().entity(importIssuesAction.getIssueNumber()).build();
}
}
However what I want is something like this
@Scanned
@Path("/import-issues")
public class ImportIssuesRestResource{
private ImportIssuesAction importIssuesAction;
@Inject
public ImportIssuesRestResource(final ImportIssuesAction importIssuesAction) {
this.importIssuesAction = importIssuesAction;
}
@GET
@Path("issueNumber")
@Produces(MediaType.APPLICATION_JSON)
public Response getFields() {
return Response.ok().entity(importIssuesAction.getIssueNumber()).build();
}
}
with injected constructor and @Scanned. I get this error when I am using the second version of code with @Named in ImportIssuesAction. I have tried also @Scanned.
Error creating bean with name 'rest.ImportIssuesRestResource': Unsatisfied dependency expressed through constructor argument with index 0 of type [action.ImportIssuesAction] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
The others custom implemented working api have similar injected constructor and using annotations @Scanned or @Named. I need my api real-time getting information from class. However currently I am getting NullPointerException from empty constructor in rest of my public getter getIssueNumber. When I am using @Named @Inject combination the all of my custom apis are hidden. I have tried also
<component-import key="importIssuesAction" interface="sk.eea.jira.telecom.extension.action."/>
in atlassian-plugin.xml. In atlassian-plugin I have also
<rest name="CSMT Rest Resource" key="csmt-rest-resource" path="/csmt" version="1.0">
<description>CSMT Rest Resources</description>
</rest>
Can somebody help with implementing custom REST API?
Hi,
Did you look a the community developer, i think you will find more answer. You can also post your question there.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.