org.springframework.web.client.HttpClientErrorException

If you like a tip written by other Samebug users, mark is as helpful! Marks help our algorithm provide you better solutions and also help other users.
tip

Check if your path is correct, if it's correct already you have to register your path to the mapping configuration.


rafaelrafael

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • I have setup my machine behind a firewall that requires me to use an authenticating proxy to make external connection. The proxy uses 'digest' based authentication (this may or may not matter). I have the proxy setup correctly in Eclipse preferences, including user credentials. When I right click CF in servers view and attempt to 'Connect' I get this error: {code} eclipse.buildId=4.3.0.M20130911-1000 java.version=1.7.0_45 java.vendor=Oracle Corporation BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_CA Framework arguments: -product org.springsource.sts.ide Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.springsource.sts.ide Error Mon Dec 23 10:21:32 PST 2013 An internal error occurred during: "Connecting to server". org.springframework.web.client.HttpClientErrorException: 407 Proxy Authentication Required at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:76) at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:486) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:443) at org.cloudfoundry.client.lib.rest.LoggingRestTemplate.doExecute(LoggingRestTemplate.java:54) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:401) at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:199) at org.cloudfoundry.client.lib.rest.CloudControllerClientFactory.getInfoMap(CloudControllerClientFactory.java:86) at org.cloudfoundry.client.lib.rest.CloudControllerClientFactory.newCloudController(CloudControllerClientFactory.java:65) at org.cloudfoundry.client.lib.CloudFoundryClient.<init>(CloudFoundryClient.java:97) at org.cloudfoundry.client.lib.CloudFoundryClient.<init>(CloudFoundryClient.java:89) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryClientFactory.getCloudFoundryOperations(CloudFoundryClientFactory.java:72) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryClientFactory.getCloudFoundryOperations(CloudFoundryClientFactory.java:55) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour.createClient(CloudFoundryServerBehaviour.java:1614) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour.createClient(CloudFoundryServerBehaviour.java:1596) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour.createClient(CloudFoundryServerBehaviour.java:1586) at org.cloudfoundry.ide.eclipse.internal.server.core.spaces.CloudSpaceServerLookup.getCloudOrgsAndSpaces(CloudSpaceServerLookup.java:118) at org.cloudfoundry.ide.eclipse.internal.server.core.spaces.CloudSpaceServerLookup.getCloudOrgsAndSpaces(CloudSpaceServerLookup.java:113) at org.cloudfoundry.ide.eclipse.internal.server.core.spaces.CloudSpaceServerLookup.getCloudSpace(CloudSpaceServerLookup.java:88) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour.getClient(CloudFoundryServerBehaviour.java:1116) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour.getClient(CloudFoundryServerBehaviour.java:1138) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour$Request.run(CloudFoundryServerBehaviour.java:1714) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour.connect(CloudFoundryServerBehaviour.java:168) at org.cloudfoundry.ide.eclipse.internal.server.ui.actions.ConnectAction$1.run(ConnectAction.java:61) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) {code}
    via by Kris De Volder (c),
  • I have setup my machine behind a firewall that requires me to use an authenticating proxy to make external connection. The proxy uses 'digest' based authentication (this may or may not matter). I have the proxy setup correctly in Eclipse preferences, including user credentials. When I right click CF in servers view and attempt to 'Connect' I get this error: {code} eclipse.buildId=4.3.0.M20130911-1000 java.version=1.7.0_45 java.vendor=Oracle Corporation BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_CA Framework arguments: -product org.springsource.sts.ide Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.springsource.sts.ide Error Mon Dec 23 10:21:32 PST 2013 An internal error occurred during: "Connecting to server". org.springframework.web.client.HttpClientErrorException: 407 Proxy Authentication Required at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:76) at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:486) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:443) at org.cloudfoundry.client.lib.rest.LoggingRestTemplate.doExecute(LoggingRestTemplate.java:54) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:401) at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:199) at org.cloudfoundry.client.lib.rest.CloudControllerClientFactory.getInfoMap(CloudControllerClientFactory.java:86) at org.cloudfoundry.client.lib.rest.CloudControllerClientFactory.newCloudController(CloudControllerClientFactory.java:65) at org.cloudfoundry.client.lib.CloudFoundryClient.<init>(CloudFoundryClient.java:97) at org.cloudfoundry.client.lib.CloudFoundryClient.<init>(CloudFoundryClient.java:89) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryClientFactory.getCloudFoundryOperations(CloudFoundryClientFactory.java:72) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryClientFactory.getCloudFoundryOperations(CloudFoundryClientFactory.java:55) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour.createClient(CloudFoundryServerBehaviour.java:1614) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour.createClient(CloudFoundryServerBehaviour.java:1596) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour.createClient(CloudFoundryServerBehaviour.java:1586) at org.cloudfoundry.ide.eclipse.internal.server.core.spaces.CloudSpaceServerLookup.getCloudOrgsAndSpaces(CloudSpaceServerLookup.java:118) at org.cloudfoundry.ide.eclipse.internal.server.core.spaces.CloudSpaceServerLookup.getCloudOrgsAndSpaces(CloudSpaceServerLookup.java:113) at org.cloudfoundry.ide.eclipse.internal.server.core.spaces.CloudSpaceServerLookup.getCloudSpace(CloudSpaceServerLookup.java:88) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour.getClient(CloudFoundryServerBehaviour.java:1116) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour.getClient(CloudFoundryServerBehaviour.java:1138) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour$Request.run(CloudFoundryServerBehaviour.java:1714) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour.connect(CloudFoundryServerBehaviour.java:168) at org.cloudfoundry.ide.eclipse.internal.server.ui.actions.ConnectAction$1.run(ConnectAction.java:61) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) {code}
    via by Kris De Volder (c),
  • I've been trying to send a multipart post via restTemplate and have been unable to get it to work with anything but FileSystemResource. In my use case (a weird file-forwarding use case) this forces me to copy a MultiPartFile InputStream into a temp file in order be able to create a FileSystemResource, which seems undesirable. Here's a testing version of the file-receiving controller (from another project, running in another servlet container): {code} @RestController public class FileReceiveController { private Log log = LogFactory.getLog(FileReceiveController.class); @RequestMapping(method = RequestMethod.POST) public void uploadFile(@RequestParam("customerId") int customerId, @RequestPart("file") MultipartFile multipartFile) { log.info("customerId: " + customerId); log.info("Received multipart file - original filename: " + multipartFile.getOriginalFilename()); log.info("content-type: " + multipartFile.getContentType()); log.info("size: " + multipartFile.getSize()); } } {code} Here's the file-forwarding controller: {code} @RestController public class FileForwardController { private RestTemplate restTemplate; public FileForwardController() { SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); requestFactory.setBufferRequestBody(false); this.restTemplate = new RestTemplate(requestFactory); } @RequestMapping(method = RequestMethod.POST) public void uploadFile(@RequestParam("customerId") int customerId, @RequestPart("file") MultipartFile multipartFile) { MultiValueMap<String,Object> parts = new LinkedMultiValueMap<>(); parts.add("customerId", customerId); try { // copy to temp file and use FileSystemResource // File tempFile = File.createTempFile("xyz", ""); // FileCopyUtils.copy(multipartFile.getInputStream(), new FileOutputStream(tempFile)); // parts.add("file", new FileSystemResource(tempFile)); // OR use InputStreamResource (broken) parts.add("file", new InputStreamResource(multipartFile.getInputStream())); // OR use ByteArrayResource (broken) // parts.add("file", new ByteArrayResource(multipartFile.getBytes())); } catch (IOException e) { throw new RuntimeException(e); } HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.MULTIPART_FORM_DATA); HttpEntity<MultiValueMap<String,Object>> request = new HttpEntity<>(parts, headers); restTemplate.exchange("http://localhost:8080", HttpMethod.POST, request, Void.class); } } {code} In this form, the restTemplate.exchange call throws {code} org.springframework.web.client.HttpClientErrorException: 400 Bad Request at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91) at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:614) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:570) {code} The ByteArrayResource form does the same thing. Only the FileSystemResource form works.
    via by Greg Adams,
    • org.springframework.web.client.HttpClientErrorException: 407 Proxy Authentication Required at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:76) at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:486) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:443) at org.cloudfoundry.client.lib.rest.LoggingRestTemplate.doExecute(LoggingRestTemplate.java:54) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:401) at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:199) at org.cloudfoundry.client.lib.rest.CloudControllerClientFactory.getInfoMap(CloudControllerClientFactory.java:86) at org.cloudfoundry.client.lib.rest.CloudControllerClientFactory.newCloudController(CloudControllerClientFactory.java:65) at org.cloudfoundry.client.lib.CloudFoundryClient.<init>(CloudFoundryClient.java:97) at org.cloudfoundry.client.lib.CloudFoundryClient.<init>(CloudFoundryClient.java:89) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryClientFactory.getCloudFoundryOperations(CloudFoundryClientFactory.java:72) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryClientFactory.getCloudFoundryOperations(CloudFoundryClientFactory.java:55) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour.createClient(CloudFoundryServerBehaviour.java:1614) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour.createClient(CloudFoundryServerBehaviour.java:1596) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour.createClient(CloudFoundryServerBehaviour.java:1586) at org.cloudfoundry.ide.eclipse.internal.server.core.spaces.CloudSpaceServerLookup.getCloudOrgsAndSpaces(CloudSpaceServerLookup.java:118) at org.cloudfoundry.ide.eclipse.internal.server.core.spaces.CloudSpaceServerLookup.getCloudOrgsAndSpaces(CloudSpaceServerLookup.java:113) at org.cloudfoundry.ide.eclipse.internal.server.core.spaces.CloudSpaceServerLookup.getCloudSpace(CloudSpaceServerLookup.java:88) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour.getClient(CloudFoundryServerBehaviour.java:1116) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour.getClient(CloudFoundryServerBehaviour.java:1138) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour$Request.run(CloudFoundryServerBehaviour.java:1714) at org.cloudfoundry.ide.eclipse.internal.server.core.client.CloudFoundryServerBehaviour.connect(CloudFoundryServerBehaviour.java:168) at org.cloudfoundry.ide.eclipse.internal.server.ui.actions.ConnectAction$1.run(ConnectAction.java:61) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

    Users with the same issue

    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    osvzsosvzs
    9 times, last one,
    tvrmsmithtvrmsmith
    5 times, last one,
    batwalrus76batwalrus76
    27 times, last one,
    118 more bugmates