org.springframework.web.client.ResourceAccessException: I/O error: Received authentication challenge is null; nested exception is java.io.IOException: Received authentication challenge is null

Spring JIRA | Roy Clarkson | 5 years ago
  1. 0

    This was identified while investigating ANDROID-80. The Commons Http Client and HttpComponents Client both correctly set a 401 status code, while HttpURLConnection throws an IOException: java.io.IOException: Received authentication challenge is null The logs from unit testing illustrate this very clearly. Commons Http Client: I/TestRunner(10439): started: testGetEntityNotAuthorized(org.springframework.web.client.RestTemplateIntegrationCommonsClientTests) W/System.err(10439): 2012-05-02 16:04:46.842::INFO: jetty-0.0 W/System.err(10439): 2012-05-02 16:04:46.855::INFO: Started SocketConnector@0.0.0.0:8080 I/TestRunner(10439): failed: testGetEntityNotAuthorized(org.springframework.web.client.RestTemplateIntegrationCommonsClientTests) I/TestRunner(10439): ----- begin exception ----- I/TestRunner(10439): I/TestRunner(10439): org.springframework.web.client.HttpClientErrorException: 401 Unauthorized I/TestRunner(10439): at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:76) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:504) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:461) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:419) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.getForEntity(RestTemplate.java:239) I/TestRunner(10439): at org.springframework.web.client.AbstractRestTemplateIntegrationTests.testGetEntityNotAuthorized(AbstractRestTemplateIntegrationTests.java:128) I/TestRunner(10439): at java.lang.reflect.Method.invokeNative(Native Method) I/TestRunner(10439): at java.lang.reflect.Method.invoke(Method.java:507) I/TestRunner(10439): at junit.framework.TestCase.runTest(TestCase.java:154) I/TestRunner(10439): at junit.framework.TestCase.runBare(TestCase.java:127) I/TestRunner(10439): at junit.framework.TestResult$1.protect(TestResult.java:106) I/TestRunner(10439): at junit.framework.TestResult.runProtected(TestResult.java:124) I/TestRunner(10439): at junit.framework.TestResult.run(TestResult.java:109) I/TestRunner(10439): at junit.framework.TestCase.run(TestCase.java:118) I/TestRunner(10439): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) I/TestRunner(10439): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) I/TestRunner(10439): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529) I/TestRunner(10439): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448) I/TestRunner(10439): ----- end exception ----- I/TestRunner(10439): finished: testGetEntityNotAuthorized(org.springframework.web.client.RestTemplateIntegrationCommonsClientTests) HttpComponents Http Client: I/TestRunner(10439): started: testGetEntityNotAuthorized(org.springframework.web.client.RestTemplateIntegrationHttpComponentsClientTests) W/System.err(10439): 2012-05-02 16:04:51.069::INFO: jetty-0.0 W/System.err(10439): 2012-05-02 16:04:51.081::INFO: Started SocketConnector@0.0.0.0:8080 D/dalvikvm(10439): GC_FOR_MALLOC freed 553K, 46% free 4493K/8263K, external 1625K/2137K, paused 53ms W/DefaultRequestDirector(10439): Authentication error: Unable to respond to any of these challenges: {} I/TestRunner(10439): failed: testGetEntityNotAuthorized(org.springframework.web.client.RestTemplateIntegrationHttpComponentsClientTests) I/TestRunner(10439): ----- begin exception ----- I/TestRunner(10439): I/TestRunner(10439): org.springframework.web.client.HttpClientErrorException: 401 Unauthorized I/TestRunner(10439): at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:76) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:504) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:461) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:419) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.getForEntity(RestTemplate.java:239) I/TestRunner(10439): at org.springframework.web.client.AbstractRestTemplateIntegrationTests.testGetEntityNotAuthorized(AbstractRestTemplateIntegrationTests.java:128) I/TestRunner(10439): at java.lang.reflect.Method.invokeNative(Native Method) I/TestRunner(10439): at java.lang.reflect.Method.invoke(Method.java:507) I/TestRunner(10439): at junit.framework.TestCase.runTest(TestCase.java:154) I/TestRunner(10439): at junit.framework.TestCase.runBare(TestCase.java:127) I/TestRunner(10439): at junit.framework.TestResult$1.protect(TestResult.java:106) I/TestRunner(10439): at junit.framework.TestResult.runProtected(TestResult.java:124) I/TestRunner(10439): at junit.framework.TestResult.run(TestResult.java:109) I/TestRunner(10439): at junit.framework.TestCase.run(TestCase.java:118) I/TestRunner(10439): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) I/TestRunner(10439): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) I/TestRunner(10439): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529) I/TestRunner(10439): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448) I/TestRunner(10439): ----- end exception ----- I/TestRunner(10439): finished: testGetEntityNotAuthorized(org.springframework.web.client.RestTemplateIntegrationHttpComponentsClientTests) Standard J2SE facilities (HttpURLConnection): I/TestRunner(10439): started: testGetEntityNotAuthorized(org.springframework.web.client.RestTemplateIntegrationSimpleClientTests) W/System.err(10439): 2012-05-02 16:04:56.329::INFO: jetty-0.0 W/System.err(10439): 2012-05-02 16:04:56.343::INFO: Started SocketConnector@0.0.0.0:8080 I/TestRunner(10439): failed: testGetEntityNotAuthorized(org.springframework.web.client.RestTemplateIntegrationSimpleClientTests) I/TestRunner(10439): ----- begin exception ----- I/TestRunner(10439): I/TestRunner(10439): org.springframework.web.client.ResourceAccessException: I/O error: Received authentication challenge is null; nested exception is java.io.IOException: Received authentication challenge is null I/TestRunner(10439): at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:471) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:419) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.getForEntity(RestTemplate.java:239) I/TestRunner(10439): at org.springframework.web.client.AbstractRestTemplateIntegrationTests.testGetEntityNotAuthorized(AbstractRestTemplateIntegrationTests.java:128) I/TestRunner(10439): at java.lang.reflect.Method.invokeNative(Native Method) I/TestRunner(10439): at java.lang.reflect.Method.invoke(Method.java:507) I/TestRunner(10439): at junit.framework.TestCase.runTest(TestCase.java:154) I/TestRunner(10439): at junit.framework.TestCase.runBare(TestCase.java:127) I/TestRunner(10439): at junit.framework.TestResult$1.protect(TestResult.java:106) I/TestRunner(10439): at junit.framework.TestResult.runProtected(TestResult.java:124) I/TestRunner(10439): at junit.framework.TestResult.run(TestResult.java:109) I/TestRunner(10439): at junit.framework.TestCase.run(TestCase.java:118) I/TestRunner(10439): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) I/TestRunner(10439): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) I/TestRunner(10439): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529) I/TestRunner(10439): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448) I/TestRunner(10439): Caused by: java.io.IOException: Received authentication challenge is null I/TestRunner(10439): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.processAuthHeader(HttpURLConnectionImpl.java:1153) I/TestRunner(10439): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.processResponseHeaders(HttpURLConnectionImpl.java:1095) I/TestRunner(10439): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.retrieveResponse(HttpURLConnectionImpl.java:1048) I/TestRunner(10439): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:726) I/TestRunner(10439): at org.springframework.http.client.SimpleClientHttpResponse.getStatusCode(SimpleClientHttpResponse.java:49) I/TestRunner(10439): at org.springframework.web.client.DefaultResponseErrorHandler.hasError(DefaultResponseErrorHandler.java:46) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:457) I/TestRunner(10439): ... 15 more I/TestRunner(10439): ----- end exception ----- I/TestRunner(10439): finished: testGetEntityNotAuthorized(org.springframework.web.client.RestTemplateIntegrationSimpleClientTests)

    Spring JIRA | 5 years ago | Roy Clarkson
    org.springframework.web.client.ResourceAccessException: I/O error: Received authentication challenge is null; nested exception is java.io.IOException: Received authentication challenge is null
  2. 0

    This was identified while investigating ANDROID-80. The Commons Http Client and HttpComponents Client both correctly set a 401 status code, while HttpURLConnection throws an IOException: java.io.IOException: Received authentication challenge is null The logs from unit testing illustrate this very clearly. Commons Http Client: I/TestRunner(10439): started: testGetEntityNotAuthorized(org.springframework.web.client.RestTemplateIntegrationCommonsClientTests) W/System.err(10439): 2012-05-02 16:04:46.842::INFO: jetty-0.0 W/System.err(10439): 2012-05-02 16:04:46.855::INFO: Started SocketConnector@0.0.0.0:8080 I/TestRunner(10439): failed: testGetEntityNotAuthorized(org.springframework.web.client.RestTemplateIntegrationCommonsClientTests) I/TestRunner(10439): ----- begin exception ----- I/TestRunner(10439): I/TestRunner(10439): org.springframework.web.client.HttpClientErrorException: 401 Unauthorized I/TestRunner(10439): at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:76) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:504) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:461) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:419) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.getForEntity(RestTemplate.java:239) I/TestRunner(10439): at org.springframework.web.client.AbstractRestTemplateIntegrationTests.testGetEntityNotAuthorized(AbstractRestTemplateIntegrationTests.java:128) I/TestRunner(10439): at java.lang.reflect.Method.invokeNative(Native Method) I/TestRunner(10439): at java.lang.reflect.Method.invoke(Method.java:507) I/TestRunner(10439): at junit.framework.TestCase.runTest(TestCase.java:154) I/TestRunner(10439): at junit.framework.TestCase.runBare(TestCase.java:127) I/TestRunner(10439): at junit.framework.TestResult$1.protect(TestResult.java:106) I/TestRunner(10439): at junit.framework.TestResult.runProtected(TestResult.java:124) I/TestRunner(10439): at junit.framework.TestResult.run(TestResult.java:109) I/TestRunner(10439): at junit.framework.TestCase.run(TestCase.java:118) I/TestRunner(10439): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) I/TestRunner(10439): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) I/TestRunner(10439): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529) I/TestRunner(10439): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448) I/TestRunner(10439): ----- end exception ----- I/TestRunner(10439): finished: testGetEntityNotAuthorized(org.springframework.web.client.RestTemplateIntegrationCommonsClientTests) HttpComponents Http Client: I/TestRunner(10439): started: testGetEntityNotAuthorized(org.springframework.web.client.RestTemplateIntegrationHttpComponentsClientTests) W/System.err(10439): 2012-05-02 16:04:51.069::INFO: jetty-0.0 W/System.err(10439): 2012-05-02 16:04:51.081::INFO: Started SocketConnector@0.0.0.0:8080 D/dalvikvm(10439): GC_FOR_MALLOC freed 553K, 46% free 4493K/8263K, external 1625K/2137K, paused 53ms W/DefaultRequestDirector(10439): Authentication error: Unable to respond to any of these challenges: {} I/TestRunner(10439): failed: testGetEntityNotAuthorized(org.springframework.web.client.RestTemplateIntegrationHttpComponentsClientTests) I/TestRunner(10439): ----- begin exception ----- I/TestRunner(10439): I/TestRunner(10439): org.springframework.web.client.HttpClientErrorException: 401 Unauthorized I/TestRunner(10439): at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:76) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:504) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:461) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:419) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.getForEntity(RestTemplate.java:239) I/TestRunner(10439): at org.springframework.web.client.AbstractRestTemplateIntegrationTests.testGetEntityNotAuthorized(AbstractRestTemplateIntegrationTests.java:128) I/TestRunner(10439): at java.lang.reflect.Method.invokeNative(Native Method) I/TestRunner(10439): at java.lang.reflect.Method.invoke(Method.java:507) I/TestRunner(10439): at junit.framework.TestCase.runTest(TestCase.java:154) I/TestRunner(10439): at junit.framework.TestCase.runBare(TestCase.java:127) I/TestRunner(10439): at junit.framework.TestResult$1.protect(TestResult.java:106) I/TestRunner(10439): at junit.framework.TestResult.runProtected(TestResult.java:124) I/TestRunner(10439): at junit.framework.TestResult.run(TestResult.java:109) I/TestRunner(10439): at junit.framework.TestCase.run(TestCase.java:118) I/TestRunner(10439): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) I/TestRunner(10439): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) I/TestRunner(10439): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529) I/TestRunner(10439): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448) I/TestRunner(10439): ----- end exception ----- I/TestRunner(10439): finished: testGetEntityNotAuthorized(org.springframework.web.client.RestTemplateIntegrationHttpComponentsClientTests) Standard J2SE facilities (HttpURLConnection): I/TestRunner(10439): started: testGetEntityNotAuthorized(org.springframework.web.client.RestTemplateIntegrationSimpleClientTests) W/System.err(10439): 2012-05-02 16:04:56.329::INFO: jetty-0.0 W/System.err(10439): 2012-05-02 16:04:56.343::INFO: Started SocketConnector@0.0.0.0:8080 I/TestRunner(10439): failed: testGetEntityNotAuthorized(org.springframework.web.client.RestTemplateIntegrationSimpleClientTests) I/TestRunner(10439): ----- begin exception ----- I/TestRunner(10439): I/TestRunner(10439): org.springframework.web.client.ResourceAccessException: I/O error: Received authentication challenge is null; nested exception is java.io.IOException: Received authentication challenge is null I/TestRunner(10439): at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:471) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:419) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.getForEntity(RestTemplate.java:239) I/TestRunner(10439): at org.springframework.web.client.AbstractRestTemplateIntegrationTests.testGetEntityNotAuthorized(AbstractRestTemplateIntegrationTests.java:128) I/TestRunner(10439): at java.lang.reflect.Method.invokeNative(Native Method) I/TestRunner(10439): at java.lang.reflect.Method.invoke(Method.java:507) I/TestRunner(10439): at junit.framework.TestCase.runTest(TestCase.java:154) I/TestRunner(10439): at junit.framework.TestCase.runBare(TestCase.java:127) I/TestRunner(10439): at junit.framework.TestResult$1.protect(TestResult.java:106) I/TestRunner(10439): at junit.framework.TestResult.runProtected(TestResult.java:124) I/TestRunner(10439): at junit.framework.TestResult.run(TestResult.java:109) I/TestRunner(10439): at junit.framework.TestCase.run(TestCase.java:118) I/TestRunner(10439): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) I/TestRunner(10439): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) I/TestRunner(10439): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529) I/TestRunner(10439): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448) I/TestRunner(10439): Caused by: java.io.IOException: Received authentication challenge is null I/TestRunner(10439): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.processAuthHeader(HttpURLConnectionImpl.java:1153) I/TestRunner(10439): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.processResponseHeaders(HttpURLConnectionImpl.java:1095) I/TestRunner(10439): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.retrieveResponse(HttpURLConnectionImpl.java:1048) I/TestRunner(10439): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:726) I/TestRunner(10439): at org.springframework.http.client.SimpleClientHttpResponse.getStatusCode(SimpleClientHttpResponse.java:49) I/TestRunner(10439): at org.springframework.web.client.DefaultResponseErrorHandler.hasError(DefaultResponseErrorHandler.java:46) I/TestRunner(10439): at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:457) I/TestRunner(10439): ... 15 more I/TestRunner(10439): ----- end exception ----- I/TestRunner(10439): finished: testGetEntityNotAuthorized(org.springframework.web.client.RestTemplateIntegrationSimpleClientTests)

    Spring JIRA | 5 years ago | Roy Clarkson
    org.springframework.web.client.ResourceAccessException: I/O error: Received authentication challenge is null; nested exception is java.io.IOException: Received authentication challenge is null
  3. 0

    java.io.IOException: Received authentication challenge is null

    Stack Overflow | 5 years ago | user1372363
    java.io.IOException: Received authentication challenge is null
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    YouTube Video upload error in Android app

    Stack Overflow | 5 years ago | jaimin
    java.io.IOException: content-length promised 476 bytes, but received 10
  6. 0

    How to Send Image to Twitpic from Android

    londatiga.net | 12 months ago
    java.io.IOException: Received authentication challenge is null 04-01 21:15:39.898: W/System.err(15687): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.processAuthHeader(HttpURLConnectionImpl.java:1153)

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.io.IOException

      Received authentication challenge is null

      at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.processAuthHeader()
    2. org.apache.harmony
      HttpURLConnectionImpl.getResponseCode
      1. org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.processAuthHeader(HttpURLConnectionImpl.java:1153)
      2. org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.processResponseHeaders(HttpURLConnectionImpl.java:1095)
      3. org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.retrieveResponse(HttpURLConnectionImpl.java:1048)
      4. org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:726)
      4 frames
    3. Spring
      AbstractRestTemplateIntegrationTests.testGetEntityNotAuthorized
      1. org.springframework.http.client.SimpleClientHttpResponse.getStatusCode(SimpleClientHttpResponse.java:49)
      2. org.springframework.web.client.DefaultResponseErrorHandler.hasError(DefaultResponseErrorHandler.java:46)
      3. org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:457)
      4. org.springframework.web.client.RestTemplate.execute(RestTemplate.java:419)
      5. org.springframework.web.client.RestTemplate.getForEntity(RestTemplate.java:239)
      6. org.springframework.web.client.AbstractRestTemplateIntegrationTests.testGetEntityNotAuthorized(AbstractRestTemplateIntegrationTests.java:128)
      6 frames
    4. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invokeNative(Native Method)
      2. java.lang.reflect.Method.invoke(Method.java:507)
      2 frames
    5. JUnit
      TestCase.run
      1. junit.framework.TestCase.runTest(TestCase.java:154)
      2. junit.framework.TestCase.runBare(TestCase.java:127)
      3. junit.framework.TestResult$1.protect(TestResult.java:106)
      4. junit.framework.TestResult.runProtected(TestResult.java:124)
      5. junit.framework.TestResult.run(TestResult.java:109)
      6. junit.framework.TestCase.run(TestCase.java:118)
      6 frames
    6. Android Platform
      Instrumentation$InstrumentationThread.run
      1. android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
      2. android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
      3. android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529)
      4. android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448)
      4 frames