Connection refused: no further information

Sohail Anwar May 5, 2019

I am trying to get issue with Jira-rest-java-client API but what I get is Connection refused: no further information error

 

Here is my code

package com.app;

import com.atlassian.jira.rest.client.api.JiraRestClient;
import com.atlassian.jira.rest.client.api.domain.BasicIssue;
import com.atlassian.jira.rest.client.api.domain.BasicProject;
import com.atlassian.jira.rest.client.api.domain.Issue;
import com.atlassian.jira.rest.client.api.domain.SearchResult;
import com.atlassian.jira.rest.client.internal.ServerVersionConstants;
import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory;
import com.google.common.collect.Lists;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
public class ConnectJira {

/*
* Class variables
* */

private static URI base_url = URI.create("http://localhost:2990/jira");


public static void main(String[] args) throws URISyntaxException, IOException {

System.out.println("\n\nprogram started\n\n");

parseArgs(args);

final AsynchronousJiraRestClientFactory jiraRestClientFactory = new AsynchronousJiraRestClientFactory();
String username = "myemail@mydomain.com";
String password = "myPassword";

try (JiraRestClient jiraRestClient = jiraRestClientFactory.createWithBasicHttpAuthentication(base_url, username, password)) {

final int buildNumber = jiraRestClient.getMetadataClient().getServerInfo().claim().getBuildNumber();

if (buildNumber > ServerVersionConstants.BN_JIRA_4_3) {
final Iterable<BasicProject> projectsList = jiraRestClient.getProjectClient().getAllProjects().claim();

for (BasicProject basicProject : projectsList) {

System.out.println("\nProjects List\n+" + basicProject + "\n\n");
}

}
if (buildNumber >= ServerVersionConstants.BN_JIRA_4_3) {
final SearchResult searchResult = jiraRestClient.getSearchClient().searchJql("assignee is not EMPTY").claim();
for (BasicIssue issue : searchResult.getIssues()) {
System.out.println("\nIssue ID\n+" + issue.getKey() + "\n\n");

}
}

final Issue issue = jiraRestClient.getIssueClient().getIssue("PSR-18").claim();

System.out.println("\nIssue\n+" + issue + "\n\n");

}

// close connection

}


private static void parseArgs(String[] argsArray) throws URISyntaxException {
final List<String> args = Lists.newArrayList(argsArray);

if (!args.isEmpty()) {
base_url = new URI(args.get(0));
}
}
}

and here is stack trace 

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException: java.net.ConnectException: Connection refused: no further information
at com.atlassian.httpclient.apache.httpcomponents.ApacheAsyncHttpClient.lambda$doExecute$4(ApacheAsyncHttpClient.java:345)
at io.atlassian.util.concurrent.Promises.lambda$biFunction$7(Promises.java:424)
at java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:822)
at java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:797)
at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$1.lambda$doFailed$1(SettableFuturePromiseHttpPromiseAsyncClient.java:42)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient.runInContext(SettableFuturePromiseHttpPromiseAsyncClient.java:61)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalDelegateRunnable.run(SettableFuturePromiseHttpPromiseAsyncClient.java:129)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
... 1 more

Its is my first program any help ?

1 answer

1 accepted

1 vote
Answer accepted
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 6, 2019

Hello Sohail,

Thank you for sending over you’re code snippet along with the logs/error message. After reviewing this and the error which is “Caused by: java.lang.RuntimeException: java.net.ConnectException: Connection refused: no further information”, it seems your issue is due to nothing listening at the address you have within your script. The sanitized address you have listed is http://localhost:2990/jira. Something off about this is that it’s listed as HTTP and not HTTPS. Along with this, ensure this address is proper and the port you have specified if the port Jira is currently running on. A simple test would be to access the URL via a browser and ensure the site loads.

Additional information on the Jira ports may be found at Changing JIRA application TCP ports.

I hope this helps to find the cause of the connection error and you’re able to communicate with your Jira instance.

Regards,
Stephen Sifers

Sohail Anwar May 14, 2019

thanks dear solved it was URL Issue

Like Stephen Sifers likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events