Get JIRA issue field in Crucible/Fisheye in Custom Plugin
Asked by nejia:

Hi,

We have a custom add on report in Crucible/Fisheye, Now I want to add one JIRA issue field in it.

So we try to use Atlassian SAL to build commnunication between Crucible/Fisheye and JIRA. But I met error as below:

My code is

ReportResource.java

private CrucibleDataAccessor crucibleData;

public ReportResource(ReviewService reviewService,  
ProjectService projectService,  
SearchService searchService,  
ApplicationLinkService applicationLinkService)  
{  
this.crucibleData = new CrucibleDataAccessor(reviewService, projectService, searchService, applicationLinkService);  
}

CrucibleDataAccessor.java

private ReviewService reviewService;  
private ProjectService projectService;  
private SearchService searchService;  
private ApplicationLinkService applicationLinkService;  
private ApplicationLink appLink;  

public CrucibleDataAccessor(ReviewService reviewService,  
ProjectService projectService,  
SearchService searchService,  
ApplicationLinkService applicationLinkService) {  
this.reviewService = reviewService;  
this.projectService = projectService;  
this.searchService = searchService;  
this.applicationLinkService = applicationLinkService;  
}

public String createRequest(com.atlassian.sal.api.net.Request.MethodType methodType,  
java.lang.String url) {

String testResponse= "";  
ApplicationLinkRequest request = null;  
for(ApplicationLink applicationLink: this.applicationLinkService.getApplicationLinks(JiraApplicationType.class)){  
if(applicationLink.getId().get().equalsIgnoreCase("JIRA")){  
appLink = applicationLink;  
}  
}

ApplicationLinkRequestFactory requestFactory = appLink.createAuthenticatedRequestFactory();

try {  
request = requestFactory.createRequest(Request.MethodType.GET,  
"[https://jira-dev.XXXXXX.cc/rest/reports/latest/reviewfindings?header=true\&project=ITS\&startDate=08/01/2017\&endDate=08/11/2017](https://jira-dev.XXXXXX.cc/rest/reports/latest/reviewfindings?header=true&project=ITS&startDate=08/01/2017&endDate=08/11/2017)");  
testResponse = request.execute();

} catch (ResponseException e) {  
e.printStackTrace();  
} catch (CredentialsRequiredException e) {  
e.printStackTrace();  
}  
return testResponse;  
}

After atlas-run, I get jar file and upload to Crucible/Fisheye, when I try to run the URL to generate report [https://fisheye-dev.XXXXXX.cc/rest/reports/latest/reviewfindings?header=true\&showtext=true\&showkey=true\&showname=true\&project=DEVOPS-CR\&startDate=08/01/2017\&endDate=08/31/2017](https://fisheye-dev.XXXXXX.cc/rest/reports/latest/reviewfindings?header=true&showtext=true&showkey=true&showname=true&project=DEVOPS-CR&startDate=08/01/2017&endDate=08/31/2017).

In webpage it show error message

### The requested resource cannot be found. {#toc-hId-1565622994}

#### Not Found {#toc-hId--1183047472}

In log, it show below error

2017-09-13 05:09:08,059 ERROR \[qtp502848122-185622 \] com.atlassian.plugin.servlet.DefaultServletModuleManager DefaultServletModuleManager-getInstance - Unable to create new reference LazyLoadedFilterReference{descriptor=com.XXXX.fecru.plugins.XXXXXX-reporting:XXXXXXXXReportsRest-filter (Provides XXXXXXX Reports services.), filterConfig=com.atlassian.plugin.servlet.filter.PluginFilterConfig@439b2acc}  
com.atlassian.util.concurrent.LazyReference$InitializationException: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.XXXXXXX.fecru.plugins.ReportResource': Unsatisfied dependency expressed through constructor argument with index 3 of type \[com.atlassian.applinks.api.ApplicationLinkService\]: No qualifying bean of type \[com.atlassian.applinks.api.ApplicationLinkService\] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type \[com.atlassian.applinks.api.ApplicationLinkService\] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}  
at com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:149) \[atlassian-util-concurrent-3.0.0.jar:?\]  
at com.atlassian.util.concurrent.LazyReference.get(LazyReference.java:112) \[atlassian-util-concurrent-3.0.0.jar:?\]  
at com.atlassian.plugin.servlet.DefaultServletModuleManager.getInstance(DefaultServletModuleManager.java:447) \[atlassian-plugins-servlet-4.4.0.jar:?\]

Could you help to give some suggestion about it or please suggest how to use SAL to build connection between Crucible and JIRA.

Thanks, Neo


Answers:
author: Marek Parfianowicz
body: Did you import the ApplicationLinkService component?

src/main/resources/atlassian-plugin.xml

```
<component-import key="applicationLinkService">
    <interface>com.atlassian.applinks.api.ApplicationLinkService</interface>
</component-import>
```


Tags: developer

fisheye-development

jira

jira-development