How to properly add a JIRA REST client into an already existing JIRA plugin?
I've tried following this tutorial: https://ecosystem.atlassian.net/wiki/display/JRJC/Tutorial
and I've added the following dependency to my pom.xml:
<dependency> <groupId>com.atlassian.jira</groupId> <artifactId>jira-rest-java-client</artifactId> <version>1.1-m02</version> <scope>provided</scope> </dependency>
now, in eclipse (after atlas-mvn eclipse:eclipse) everything shows fine, without any warnings/errors, but at runtime, this line:
JerseyJiraRestClientFactory f = new JerseyJiraRestClientFactory();
gives me an exception like:
java.lang.NoClassDefFoundError "com/atlassian/jira/rest/client/internal/jersey/JerseyJiraRestClientFactory"
Does anyone know how to add/use jira-rest-java-client properly to an already existing plugin?
Community moderators have prevented the ability to post new answers.
See my answer here for a working example - https://answers.atlassian.com/questions/194331/can-anyone-provide-a-simple-example-of-jira-rest-java-client-jrjc-plugin-code/196799
Excellent answer!
Thanks a lot for providing it! :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Put the scope as compile. JRJC is not part of JIRA and so you will need those classes in the plugins classpath.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're the man Jobin!!! :)))
It worked like a charm :) But.. :)
Now, I'm getting the exception "java.lang.NoClassDefFoundError: Could not initialize class org.apache.commons.httpclient.HttpState" at line:
jc = f.createWithBasicHttpAuthentication(new URI("http://localhost:8080"), "admin", "admin");
the test code I tried to execute was something simple:
private void blah() { JerseyJiraRestClientFactory f = new JerseyJiraRestClientFactory(); JiraRestClient jc; try { jc = f.createWithBasicHttpAuthentication(new URI("http://localhost:8080"), "admin", "admin"); SearchResult r = jc.getSearchClient().searchJql("type = Bug ORDER BY RANK ASC", null); for (BasicIssue basicIssue : r.getIssues()) { com.atlassian.jira.rest.client.domain.Issue issue = jc.getIssueClient().getIssue(basicIssue.getKey(), null); System.out.println("Bug: " + issue.getKey() + " " + issue.getSummary()); for (IssueLink issueLink : issue.getIssueLinks()) { com.atlassian.jira.rest.client.domain.Issue issueL = jc.getIssueClient().getIssue((issueLink).getTargetIssueKey(), null); System.out.println(issueLink.getIssueLinkType().getDescription() + ": " + issueL.getKey() + " " + issueL.getSummary() + " " + issueL.getFieldByName("Story Points").getValue()); } } } catch (URISyntaxException e) { // TODO } }
I'll accept your answer, because it solved my initial question though :)
Thanks once again! :)
P.S. Does anyone know how to notify author of that doc page to update the page with <scope>compile</scope>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is the same thing. You are missing another class at runtime. I guess apache httpclient this time. I wonder why it is not pulled in by JRJC dependency but see if you can fix it by adding it in your pom.xml.
https://ecosystem.atlassian.net/wiki/display/JRJC/Project+Dependencies shows the dependencies for JRJC. They should normally be pulled in by JRJC.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was afraid you were going to say that :)
Anyway, thanks a lot again!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use jira-rest-java-client-api instead of jira-rest-java-client.
I too faced the same issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just a curious question. Why do you need the REST client when the add on already provides you access to most of the API?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not sure I quite understand your question, but I need to implement a plugin, which will serve as a kind of a proxy for the gadget's REST calls (retrieving information from another JIRA instance), so at one point my plugin needs to act as a REST service provider (towards the gadget) and at another point (towards another JIRA instance) it needs to act as a REST client, right?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yea. That is one way to do it. But you can always just use a Jersey client to call the other REST instead of using the whole JIRA REST client.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.