Jira plugin using Jersey client for REST call to external resource.

Peter Csiba September 9, 2012

In my JIRA plugin I want to GET an external resource from 3rd party site (for example https://api.twitter.com/1.1/statuses/mentions_timeline.json?count=2&since_id=14927799, but much simpler).

After I was unable to make an HTTP request directly from JIRA I made my choice for Jersey (Jira REST API uses it too). I defined my simple resource

@XmlRootElement
public class ValidatorResource {
	public String response; //yes, no
	
	public ValidatorResource(String response){
		this.response = response; 
	}
}

And according to Jersey tutorial I configured a client for retrieving it as JSON:

ClientConfig client_config = new DefaultClientConfig(); 
		client_config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); 
		Client client = Client.create(new DefaultClientConfig());

But both Eclipse and Jira tell me that:

"The type com.sun.jersey.core.util.FeaturesAndProperties cannot be resolved. It is indirectly referenced from required .class files"

I am not a maven guru, it should be something with dependencies. After hours of googling I am giving up. My plugin dependencies are:

<dependency>
			<groupId>javax.ws.rs</groupId>
			<artifactId>jsr311-api</artifactId>
			<version>1.1.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax.xml.bind</groupId>
			<artifactId>jaxb-api</artifactId>
			<version>2.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>com.sun.jersey</groupId>
			<artifactId>jersey-json</artifactId>
			<version>1.13</version>
		</dependency>
		<dependency>
			<groupId>com.sun.jersey</groupId>
			<artifactId>jersey-client</artifactId>
			<version>1.13</version>
		</dependency>

2 answers

0 votes
Philipp Göllner July 3, 2013

Hi Peter, Hi Maxim,

did you try to include atlassians version of jersey? I was sucessful with the following modifications to my pom:

First add atlassians maven repository

<project>
......
  <repositories>
        <repository>
            <id>atlassian-public</id>
            <url>https://maven.atlassian.com/repository/public</url>
        </repository>
    </repositories>
.....
</project>

Second add dependencies to the atlassian version

<dependency>
          <groupId>com.sun.jersey</groupId>
          <artifactId>jersey-client</artifactId>
          <version>1.8-atlassian-11</version>
      </dependency>
 
      <dependency>
          <groupId>com.sun.jersey</groupId>
          <artifactId>jersey-json</artifactId>
          <version>1.8-atlassian-11</version>
      </dependency>
 
      <dependency>
          <groupId>com.sun.jersey</groupId>
          <artifactId>jersey-core</artifactId>
          <version>1.8-atlassian-11</version>
      </dependency>

Keep me updated if it works.

Best regards Philipp

0 votes
Maxim Abramovich March 10, 2013

Hello!

Do you resolve your problem? At this moment I have same problem. It will be great, if you can help me. Thanks

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events