Unable to connect to Jira using Java ..need urgent help

HariK August 29, 2014

final HttpClient httpClient = new AsynchronousHttpClientFactory().createClient(serverUri, authenticationHandler);

Exception in thread "main" java.lang.NoClassDefFoundError: com/atlassian/sal/api/ApplicationProperties

at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.create(AsynchronousJiraRestClientFactory.java:35)

at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.createWithBasicHttpAuthentication(AsynchronousJiraRestClientFactory.java:41)

2 answers

1 accepted

0 votes
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 30, 2014

You are not using a "simple java program" here. You are using a pre-written library that already handles a lot of the connection stuff, and the error you are getting is a common one for people who have just picked it up and thought "I don't need to understand this stuff, I can just start using it without reading how to use it or what it's actually for".

Your best option is to work within the Atlassian SDK, which includes the dependencies you need for using JRJC, or you need to understand what you need to pull in the right dependencies. My bookmarks contain https://ecosystem.atlassian.net/wiki/display/JRJC/Downloadfor understanding that, and a note to include com.atlassian.sal in the pom.xml

HariK August 31, 2014

Thank you for your help. I'll go through what you suggested.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 29, 2014

You haven't imported the application properties class, or you've not included the library in your class path.

HariK August 29, 2014

Thank you for your help. Can you please suggest me what library I need to include ?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 29, 2014

The one containing the application properties class.

Diffficult to tell you though - we don't know where your code is actually running. Plugin, connect, externally etc?

HariK August 29, 2014

Thiss my method which I'm calling from a class and I'm doing this in eclipse.

public JiraIssueAgent(JiraConfig config) throws URISyntaxException {

JiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();

URI jiraServerUri = new URI(config.getUrl());

JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraServerUri, config.getUsername(), config.getPassword());

init(restClient);

}

Please suggest me the necessary libraries to include..

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 29, 2014

No, sorry, I was not clear when I said we don't know *where* your code is running.

Is it a plugin/addon for Jira? A "Connect" addon? A hack in the core of Jira? A gadget? An external program (Which won't need the the library, because it's outside Jira)?

HariK August 29, 2014

Thank you for your patience. It's An external program trying to connect to Jira with a login user and password

JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraServerUri, config.getUsername(), config.getPassword());

this lines returns me an error syaing Exception in thread "main" java.lang.NoClassDefFoundError: com/atlassian/sal/api/ApplicationProperties

what is this com/atlassian/sal How should I get this.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 29, 2014

You don't need the com/atlassian/sal stuff for external programs. You connect via REST and get JSON formatted responses back.

HariK August 30, 2014

Thank you for your help.

I'm connecting through Rest client only . I'm using following .jars to run my code.

jira-rest-java-client-2.0.0-m2

atlassian-util-concurrent-2.4.1.

Please help me i'm stuck with this. I've read data from Jira

HariK August 30, 2014

I'm exactly having a problem like below. Not sure how Joe resolved this. My code i've not used any maven plugins..Please suggest. How to connect to jira from a simple java simple java program and required references and corresponding pom.xml file please

https://answers.atlassian.com/questions/316728/java-lang-noclassdeffounderror-com-atlassian-sal-api-applicationproperties

Jagmeet Randhawa May 19, 2018

Hi @HariK, what turned out to be solution for you? I am having similar issue.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 19, 2018

They used the REST API as documented.

Suggest an answer

Log in or Sign up to answer