我复制了Java Toolkit for Rally Rest页面底部的“说明如何查询前5个最高优先级缺陷”的代码示例。
我相应地更改了用户名和密码,但我收到了UnknownHostException
。
这是stacktrace:
log4j:WARN No appenders could be found for logger (org.apache.http.impl.conn.BasicClientConnectionManager).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.net.UnknownHostException: rally1.rallydev.com
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:849)
at java.net.InetAddress.getAddressFromNameService(InetAddress.java:1202)
at java.net.InetAddress.getAllByName0(InetAddress.java:1153)
at java.net.InetAddress.getAllByName(InetAddress.java:1083)
at java.net.InetAddress.getAllByName(InetAddress.java:1019)
at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:278)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:162)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:640)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
at com.rallydev.rest.RallyRestApi.doRequest(RallyRestApi.java:253)
at com.rallydev.rest.RallyRestApi.doGet(RallyRestApi.java:323)
at com.rallydev.rest.RallyRestApi.query(RallyRestApi.java:179)
at com.jdes.AgileToRally.AgileToRally.main(AgileToRally.java:37)
第37行:QueryResponse queryResponse = restApi.query(defects);
我尝试过更改服务器名称,用户名和密码,但我没有运气。
由于
答案 0 :(得分:1)
查看堆栈跟踪,看起来您的计算机正在尝试查找rally1.rallydev.com
的IPV6地址,并且它失败了,因为它没有(然后没有回退到IPV4)。这表明您的计算机配置(或它使用的DNS服务器)的问题不仅仅是Java中的问题。
话虽这么说,你可以强迫JVM选择IPV4来解决你的问题:
prompt> java -Djava.net.preferIPv4Stack=true ...
如果您正在使用IDE,则需要将其配置为在运行程序时将-Djava.net.preferIPv4Stack=true
传递给java。
答案 1 :(得分:1)
看起来你有一个代理服务器。
restApi.setProxy(new URI(proxyserver));