我正在使用groovy http-builder并使用RestClient从JIRA访问Web服务。 在开发模式下,它运行正常,但是当我在Tomcat服务器上部署war时,它会抛出异常
" org.apache.commons.collections.map.ListOrderedMap:method()V 未找到。 Stacktrace如下: org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: 执行控制器[com.tristar.JiraController]的动作[list] 导致异常:运行时错误执行操作 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)引起:org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: 运行时错误执行操作 ... 3更多引起:java.lang.reflect.InvocationTargetException ... 3更多引起:java.lang.NoSuchMethodError:org.apache.commons.collections.map.ListOrderedMap:method()V 未找到 在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) 在groovyx.net.http.HTTPBuilder $ RequestConfigDelegate。(HTTPBuilder.java:946) at groovyx.net.http.RESTClient.post(RESTClient.java:140) 在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 :(得分:1)
我在Build Config中添加了这些依赖项
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对象
答案 1 :(得分:0)
在Grails应用程序中使用JIRA REST Client for JAVA不是必需的,尽管它可能已经解决了您的问题。我遇到了同样的问题,并且能够使用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