java.nio.charset.IllegalCharsetNameException: "utf-8"

Spring JIRA | Taras Tielkes | 7 years ago
  1. 0

    Accoring to RFC 2045, the following is a valid content type response header: ---- Content-Type: application/xml;charset="utf-8" ---- Trying to access a resource that serves such a header (through RestTemplate) throws the following exception: ---- Exception in thread "main" java.nio.charset.IllegalCharsetNameException: "utf-8" at java.nio.charset.Charset.checkName(Charset.java:284) at java.nio.charset.Charset.lookup2(Charset.java:458) at java.nio.charset.Charset.lookup(Charset.java:437) at java.nio.charset.Charset.forName(Charset.java:502) at org.springframework.http.MediaType.checkParameters(MediaType.java:300) at org.springframework.http.MediaType.<init>(MediaType.java:266) at org.springframework.http.MediaType.parseMediaType(MediaType.java:570) at org.springframework.http.HttpHeaders.getContentType(HttpHeaders.java:286) at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:64) at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:619) at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:1) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:446) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:401) at org.springframework.web.client.RestTemplate.getForEntity(RestTemplate.java:221) <...user code...> ---- I assume MediaType is simply missing the logic to optionally unwrap the value.

    Spring JIRA | 7 years ago | Taras Tielkes
    java.nio.charset.IllegalCharsetNameException: "utf-8"
  2. 0

    Accoring to RFC 2045, the following is a valid content type response header: ---- Content-Type: application/xml;charset="utf-8" ---- Trying to access a resource that serves such a header (through RestTemplate) throws the following exception: ---- Exception in thread "main" java.nio.charset.IllegalCharsetNameException: "utf-8" at java.nio.charset.Charset.checkName(Charset.java:284) at java.nio.charset.Charset.lookup2(Charset.java:458) at java.nio.charset.Charset.lookup(Charset.java:437) at java.nio.charset.Charset.forName(Charset.java:502) at org.springframework.http.MediaType.checkParameters(MediaType.java:300) at org.springframework.http.MediaType.<init>(MediaType.java:266) at org.springframework.http.MediaType.parseMediaType(MediaType.java:570) at org.springframework.http.HttpHeaders.getContentType(HttpHeaders.java:286) at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:64) at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:619) at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:1) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:446) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:401) at org.springframework.web.client.RestTemplate.getForEntity(RestTemplate.java:221) <...user code...> ---- I assume MediaType is simply missing the logic to optionally unwrap the value.

    Spring JIRA | 7 years ago | Taras Tielkes
    java.nio.charset.IllegalCharsetNameException: "utf-8"
  3. 0

    java.nio.charset.IllegalCharsetNameException jersey client

    Stack Overflow | 1 year ago | Java Kid
    java.nio.charset.IllegalCharsetNameException: "utf-8"
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Illegal Charset when passing parameters

    GitHub | 3 years ago | rgururaj
    java.nio.charset.IllegalCharsetNameException: application/json
  6. 0

    charset header with quotes gives an error

    GitHub | 3 years ago | bangnab
    java.nio.charset.IllegalCharsetNameException: "UTF-8"

    1 unregistered visitors
    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.nio.charset.IllegalCharsetNameException

      "utf-8"

      at java.nio.charset.Charset.checkName()
    2. Java RT
      Charset.forName
      1. java.nio.charset.Charset.checkName(Charset.java:284)
      2. java.nio.charset.Charset.lookup2(Charset.java:458)
      3. java.nio.charset.Charset.lookup(Charset.java:437)
      4. java.nio.charset.Charset.forName(Charset.java:502)
      4 frames
    3. Spring
      RestTemplate.getForEntity
      1. org.springframework.http.MediaType.checkParameters(MediaType.java:300)
      2. org.springframework.http.MediaType.<init>(MediaType.java:266)
      3. org.springframework.http.MediaType.parseMediaType(MediaType.java:570)
      4. org.springframework.http.HttpHeaders.getContentType(HttpHeaders.java:286)
      5. org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:64)
      6. org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:619)
      7. org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:1)
      8. org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:446)
      9. org.springframework.web.client.RestTemplate.execute(RestTemplate.java:401)
      10. org.springframework.web.client.RestTemplate.getForEntity(RestTemplate.java:221)
      10 frames