У меня возникла проблема с httpPost из Java-приложения, которое работает на HCP-Trial-Account в Tomcat7-Container. Я использую HttpClient 4.5.3.Почтовый запрос от Java-приложения на HCP не выполнен
Код работает на моем локальном Tomcat7-сервере и работает. Однако при развертывании его на 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. Приложение застревает, а токенRequest работает навсегда.
Вот темы, которые выполняются навсегда, которые я могу видеть в режиме отладки:
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