当前位置: 代码迷 >> Java相关 >> 用Java调用Jira的接口方法,为何始终提示Connection refused
  详细解决方案

用Java调用Jira的接口方法,为何始终提示Connection refused

热度:48   发布时间:2016-04-22 20:06:20.0
用Java调用Jira的接口方法,为什么始终提示Connection refused:
本帖最后由 mvpme82 于 2012-12-06 21:50:01 编辑
package runner;
import java.sql.*;
import java.net.URI;
import com.sun.jersey.client.apache.config.*;

import com.sun.jersey.api.client.*;

import javax.ws.rs.core.*;
import org.codehaus.jettison.json.*;

import com.sun.jersey.core.util.*;

import org.apache.commons.httpclient.*;
import org.apache.commons.logging.*;
import com.google.common.base.*;
import com.google.common.collect.*;
import org.apache.commons.codec.*;

import com.atlassian.jira.rest.client.*;
import com.atlassian.jira.rest.client.domain.*;
import com.atlassian.jira.rest.client.internal.jersey.*;

public class run {    
    
    public static void main(String args[]){
        
        try{                  
                JerseyJiraRestClientFactory factory = new JerseyJiraRestClientFactory();
                //URI jiraServerUri = new URI("http://10.4.16.75:8090/jira");
                //URI jiraServerUri = new URI("http://10.2.76.80:8090/jira");
                URI jiraServerUri = new URI("http://10.2.42.82:8090/jira");
                JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraServerUri, "qingbo.meng", "32243399");
                NullProgressMonitor pm = new NullProgressMonitor();
                Issue issue = restClient.getIssueClient().getIssue("TES-1", pm);
         
                //System.out.println(issue);
                System.out.println("************************************");
                return;
           
        }catch(Exception e){  
            System.out.println(e.toString());  
        }       
        
        
    }

}

这是我的代码,想要显示一条指定的issue,就是有下面提示:
2012-12-6 20:44:19 org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
信息: I/O exception (java.net.ConnectException) caught when processing request: Connection refused: connect
2012-12-6 20:44:19 org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
信息: Retrying request
------解决思路----------------------
可能是你某个HTTP request的参数没有设置正确
找个工具从浏览器抓个HTTP包看看,就一清二楚了
  相关解决方案