2014-07-09 69 views
0

我使用groovy http-builder並使用RestClient從JIRA訪問Web服務。 在開發模式下,它工作正常,但是當我的Tomcat服務器上部署的戰爭,它拋出異常,因爲Grails和Jira使用RESTClient集成

"org.apache.commons.collections.map.ListOrderedMap: method()V not found. Stacktrace follows: org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Executing action [list] of controller [com.tristar.JiraController] caused exception: Runtime error executing action at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) Caused by: org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Runtime error executing action ... 3 more Caused by: java.lang.reflect.InvocationTargetException ... 3 more Caused by: java.lang.NoSuchMethodError: org.apache.commons.collections.map.ListOrderedMap: method()V not found at net.sf.json.JSONObject.(JSONObject.java:1603) at groovyx.net.http.EncoderRegistry.encodeJSON(EncoderRegistry.java:301) at groovyx.net.http.HTTPBuilder$RequestConfigDelegate.setBody(HTTPBuilder.java:1200) at groovyx.net.http.HTTPBuilder$RequestConfigDelegate.setPropertiesFromMap(HTTPBuilder.java:1111) at groovyx.net.http.HTTPBuilder$RequestConfigDelegate.(HTTPBuilder.java:946) at groovyx.net.http.RESTClient.post(RESTClient.java:140) at com.tristar.JiraController.list(JiraController.groovy:221) "

def jiraApiUrl = 'http://ipAddress:8080/rest/api/2/' 
def jiraClient = new RESTClient(jiraApiUrl) 

def searchResults = jiraClient.post(requestContentType: JSON, 
      path: 'search', 
      body: [jql: "project=XYZ AND (status=Open OR status='In Progress') AND issuetype!=Epic AND  issuetype!='Technical task'", startAt: offset, maxResults: params.max, fields: ['summary', 'description','issuetype']]) 

我怎樣才能解決這個問題?

+0

嘗試在構建之前進行全面清理。 'grails clean && rm -rf ./target/ && grails refresh-dependencies && grails war'。此外,您可以嘗試通過下一個命令「grails dev war」進行構建。 – wwarlock

+0

我已經完成了所有這些事情,但沒有成功。任何方式,我已經改變了我的執行情況,現在它工作正常。謝謝 – arvind

+0

請描述您的更改作爲答案 – wwarlock

回答

1

我在構建添加這些依賴配置

compile 'com.atlassian.jira:jira-rest-java-client-api:2.0.0-m25' 
compile 'com.atlassian.jira:jira-rest-java-client-core:2.0.0-m25' 

,並使用

AsynchronousJiraRestClientFactory factory = new AsynchronousJiraRestClientFactory() 
def jiraServerUri = URI.create("ipaddress") 
JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraServerUri, "username", "password") 

進行身份驗證和獲取RESTClient實現對象

+0

這很好。它提供了其他調用的方法,就像Bob Swift的soap API過去一樣。 –

-1

使用JIRA的REST客戶端JAVA在Grails應用程序是沒有必要的,儘管它可能解決了你的問題。我面臨同樣的問題,並能夠使用Groovy HTTP Builder創建JIRA REST客戶端。

我在BuildConfig.groovy添加的唯一依賴是:

dependencies { 
compile("org.codehaus.groovy.modules.http-builder:http-builder:0.5.0-RC1") { 
    excludes 'groovy', 'xml-apis' } } 

然後建立自己的JSON的查詢和發佈您的要求:

jiraClient.post(requestContentType: JSON, body: query) 

如果您正在尋找更多的信息這個博客帖子可能有所幫助:

http://ashahrami.blogspot.ca/2014/12/jira-rest-client-implementation-in.html