0

I am a newbie who started to integrate JIRA using Java, following the issues & document, I am trying to get issues using Java.

Everything's fine, but I am getting the following error.

Exception in thread "main" java.lang.IncompatibleClassChangeError: Class com.atlassian.jira.rest.client.auth.BasicHttpAuthenticationHandler does not implement the requested interface com.atlassian.jira.rest.client.api.AuthenticationHandler

This is my pom.xml

<!-- https://mvnrepository.com/artifact/com.atlassian.jira/jira-rest-java-client -->
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client</artifactId>
<version>1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.atlassian.jira/jira-rest-java-client-api -->
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-api</artifactId>
<version>5.1.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.atlassian.jira/jira-rest-java-client-core -->
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>5.1.6</version>
</dependency>

<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-app</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>com.atlassian.fugue</groupId>
<artifactId>fugue</artifactId>
<version>2.6.1</version>
</dependency>

</dependencies>
<repositories>
<repository>
<id>atlassian-public</id>
<url>https://m2proxy.atlassian.com/repository/public</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>atlassian-public</id>
<url>https://m2proxy.atlassian.com/repository/public</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>

And this is my code.

import java.io.IOException;
import java.net.URI;

import com.atlassian.jira.rest.client.api.JiraRestClient;
import com.atlassian.jira.rest.client.api.domain.Issue;
import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory;

public class Dummy {

private String username;
private String password;
private String jiraUrl;
private JiraRestClient restClient;

private Dummy(String username, String password, String jiraUrl) {
this.username = username;
this.password = password;
this.jiraUrl = jiraUrl;
this.restClient = getJiraRestClient();
}

private JiraRestClient getJiraRestClient() {
return new AsynchronousJiraRestClientFactory().createWithBasicHttpAuthentication(getJiraUri(), this.username,
this.password);
}

private URI getJiraUri() {
return URI.create(this.jiraUrl);
}

private Issue getIssue(String issueKey) {
return restClient.getIssueClient().getIssue(issueKey).claim();
}

public static void main(String[] args) throws IOException {
Dummy myJiraClient = new Dummy("username", "password", "http://localhost:8080/secure/WelcomeToJIRA.jspa");
String issueKey = issueKey;
Issue issue = myJiraClient.getIssue(issueKey);
System.out.println(issue.getDescription());

myJiraClient.restClient.close();
}


}

 

I didn't find any solution for the error, also I don't know where I am wrong. It would be appreciated if someone helps me out where I am wrong. Any help is much appreciated.

Thank you!

1 Answer 1

1

It think, it is a dependency conflict. By using mvn dependency:tree command,.. can analyse and find out.

Also I checked this sample (client) in atlassion bitbucket. In this example, atlassian.httpclient.version is 2.0.0. Hope this would help.

https://bitbucket.org/atlassian/jira-rest-java-client/src/master/pom.xml

https://bitbucket.org/atlassian/jira-rest-java-client/src/75a64c9d81aad7d8bd9beb11e098148407b13cae/test/src/test/java/samples/ExampleCreateIssuesAsynchronous.java?at=master&_ga=2.100062872.72364915.1593881496-21279827.1593881496

Sign up to request clarification or add additional context in comments.

2 Comments

yeah it was a dependency problem, it's working fine as standalone, I am trying to get an issue dynamically, I am trying to send a request using postman, the call isn't getting called, do you have any idea about this?
Fine, If you are getting 401 error (Unauthorized), please check this url community.atlassian.com/t5/New-to-JSD-questions/…. Otherwise, the service endpoint could be a different one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.