Tomcat7-Container의 HCP-Trial-Account에서 실행중인 Java 애플리케이션의 httpPost에 문제가 있습니다. 4.5.3 HttpClient를 사용합니다.HCP에서 Java-Application의 게시 요청을 수행하지 않았습니다.
이 코드는 내 로컬 Tomcat7-Server에서 실행되며 작동합니다. 그러나 HCP에 배치하면 문제가 발생합니다.
public static Notebook getAllNotebooks(String code, String redirectUri) throws IOException, URISyntaxException{
ClassLoader classLoader = Connection.class.getClassLoader();
URL resource = classLoader.getResource("org/apache/http/impl/client/HttpClientBuilder.class");
String returnUri = "https://login.live.com/oauth20_token.srf";
HttpPost tokenRequest = new HttpPost(returnUri);
HttpClient client = new DefaultHttpClient();//HttpClientBuilder.create().build(); //Exception: http://stackoverflow.com/questions/22330848/httpclient-example-exception-in-thread-main-java-lang-nosuchfielderror-inst
tokenRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded");
tokenRequest.setEntity(new UrlEncodedFormEntity(Connection.getParametersForURLBody(code, redirectUri), Consts.UTF_8));
tokenRequest.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0");
HttpResponse tokenResponse = client.execute(tokenRequest); //Here it gets stuck
tokenRequest가 실행될 때 문제가 발생합니다. 응용 프로그램이 멈추고 tokenRequest가 영원히 실행됩니다.
SAP JVM Debug Target
Daemon Thread [NioBlockingSelector.BlockPoller-1] (Running)
Daemon Thread [NioBlockingSelector.BlockPoller-2] (Running)
Daemon Thread [RMI TCP Connection(1)-127.0.0.1] (Running)
Thread [Timer-0] (Running)
Daemon Thread [RMI TCP Connection(2)-10.117.35.76] (Running)
Thread [pool-1-thread-1] (Running)
Thread [Timer-1] (Running)
Daemon Thread [ContainerBackgroundProcessor[StandardEngine[Catalina]]] (Running)
Daemon Thread [JCoTimeoutChecker] (Running)
Daemon Thread [http-bio-8001-Acceptor-0] (Running)
Daemon Thread [http-bio-8001-AsyncTimeout] (Running)
Daemon Thread [http-nio-127.0.0.1-9001-ClientPoller-0] (Running)
Daemon Thread [http-nio-127.0.0.1-9001-Acceptor-0] (Running)
Daemon Thread [http-nio-8041-ClientPoller-0] (Running)
Daemon Thread [http-nio-8041-Acceptor-0] (Running)
Daemon Thread [ajp-bio-8009-Acceptor-0] (Running)
Daemon Thread [ajp-bio-8009-AsyncTimeout] (Running)
Daemon Thread [RMI TCP Connection(10)-127.0.0.1] (Running)
Daemon Thread [RMI TCP Connection(11)-10.117.10.34] (Running)
Thread [main] (Running)
Daemon Thread [http-nio-8041-exec-1] (Running)
Daemon Thread [http-nio-8041-exec-2] (Running)
Daemon Thread [http-nio-8041-exec-3] (Running)
Daemon Thread [http-nio-8041-exec-4] (Running)
Daemon Thread [http-nio-8041-exec-5] (Running)
Thread [pool-2-thread-1] (Running)
Daemon Thread [http-nio-8041-exec-6] (Stepping)
Daemon Thread [http-nio-8041-exec-7] (Running)
Daemon Thread [http-nio-8041-exec-8] (Running)
Daemon Thread [http-nio-8041-exec-9] (Running)
Daemon Thread [http-nio-8041-exec-10] (Running)
Daemon Thread [RMI TCP Connection(idle)] (Running)
Daemon Thread [RMI TCP Connection(idle)] (Running)
이 프로그램은이 시점에서 stucked됩니다 : 여기
내가 디버그 모드에서 볼 수 있습니다 영원히 실행중인 스레드입니다.실마리가 없으며 몇 가지 힌트와 도움을 주셔서 감사합니다. :)
인사말 Maverin
아마도 프록시를 구성해야합니다. 해당 답변에서 언급 된 설명서를 참조하십시오. – vap78
그게 전부 괜찮아요,하지만 예제는 모두 UrlConnection과 함께, 나는 httpclient와 함께 그것을 실행하는 방법을 모르겠다. 정말 도움이 되었으면 좋겠다. :) – MaverinCode
https://hc.apache.org/httpcomponents-client-ga/examples.html에서 apache http 클라이언트 및 프록시로 예제를 확인할 수 있습니다. – vap78