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

Java Jira REST API connect problem

Gabor Bernat April 8, 2013

Hello,

I try to use the JAVA JIRA client (https://bitbucket.org/atlassian/jira-rest-java-client), however I fail to create a connection.

I've used the migration code from here (https://ecosystem.atlassian.net/wiki/display/JRJC/Migrating+from+JRJC+1.x+to+2.x), however at connection creation I get the following exception:

Here's where the error happens (there is no such file):

@Override
public String getVersion() {
 return MavenUtils.getVersion("com.atlassian.jira", "jira-rest-java-com.atlassian.jira.rest.client");
		}

Which results in the exception:

18:42:58.712 [main] DEBUG c.a.j.r.c.i.a.AsynchronousHttpClientFactory$MavenUtils - Could not find version for maven artifact com.atlassian.jira:jira-rest-java-com.atlassian.jira.rest.client
18:42:58.721 [main] DEBUG c.a.j.r.c.i.a.AsynchronousHttpClientFactory$MavenUtils - Got the following exception
java.lang.NullPointerException: null
        at java.util.Properties$LineReader.readLine(Properties.java:434) ~[na:1.7.0_09]
        at java.util.Properties.load0(Properties.java:353) ~[na:1.7.0_09]
        at java.util.Properties.load(Properties.java:341) ~[na:1.7.0_09]
        at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory$MavenUtils.getVersion(AsynchronousHttpClientFactory.java:158) ~[jira_cli.jar:na]
        at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory$RestClientApplicationProperties.getVersion(AsynchronousHttpClientFactory.java:121) [jira_cli.jar:na]
        at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClient.getUserAgent(DefaultHttpClient.java:168) [jira_cli.jar:na]
        at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClient.<init>(DefaultHttpClient.java:139) [jira_cli.jar:na]
        at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory.createClient(AsynchronousHttpClientFactory.java:53) [jira_cli.jar:na]
        at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.create(AsynchronousJiraRestClientFactory.java:35) [jira_cli.jar:na]
        at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.createWithBasicHttpAuthentication(AsynchronousJiraRestClientFactory.java:42) [jira_cli.jar:na]

Any ideas, what am I missing?

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
systemsplanet October 20, 2016

If you need to stick to a release repo, then you can work around this JIRA bug by copying the source of this file to your project

/asdlc-app/src/main/java/com/atlassian/jira/rest/client/internal/async/AsynchronousHttpClientFactory.java

then edit

public String getVersion() {
   return MavenUtils.getVersion("com.atlassian.jira", "jira-rest-java-client-api");
}

 

May also want to increase the socket timeout for slow queries

public DisposableHttpClient createClient(final URI serverUri, final AuthenticationHandler authenticationHandler) {
    final HttpClientOptions options = new HttpClientOptions();
    options.setSocketTimeout(2, TimeUnit.MINUTES); // 2 mins timeout for slow jira queries

Lucy A April 16, 2018

Thank you! Best solution i have seen thus far!

0 votes
Jörgen Persson April 28, 2013

I created a ticket for it: JRJC-149

0 votes
Jörgen Persson April 28, 2013
I don't think you're missing anything, but it's rather a bug. The second argument of the call should be the artifactId which is "jira-rest-java-client-core". So I think the code should look like:
@Override
public String getVersion() {
 return MavenUtils.getVersion("com.atlassian.jira", "jira-rest-java-client-core");
}

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events