javax.ws.rs.ProcessingException: java.lang.IllegalArgumentException: invalid start or end

Java.net JIRA | jrh3k5 | 3 years ago
  1. 0

    I've attached a project that reproduces this. If I have a {{ContainerRequestFilter}} abort a transaction and add a {{WWW-Authenticate}} header missing an authentication scheme (e.g., "Basic " or "OAuth ") and I try to process this response using a Jersey client, I get the following error: {noformat} Exception in thread "main" javax.ws.rs.ProcessingException: java.lang.IllegalArgumentException: invalid start or end at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:236) at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:655) at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:652) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.process(Errors.java:228) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:422) at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:652) at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:387) at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:291) at org.glassfish.test.TestApp.main(TestApp.java:20) Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: invalid start or end at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1137) at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:2338) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:388) at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:276) at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:182) at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:227) ... 10 more Caused by: java.lang.IllegalArgumentException: invalid start or end at sun.net.www.HeaderParser.subsequence(HeaderParser.java:58) at sun.net.www.protocol.http.AuthenticationHeader.parse(AuthenticationHeader.java:155) at sun.net.www.protocol.http.AuthenticationHeader.<init>(AuthenticationHeader.java:119) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1261) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379) ... 13 more {noformat} It's not a problem with the headers, as they seem well-formed (when I hit it using Live HTTP Headers in Firefox): {noformat} http://localhost:8080/ GET / HTTP/1.1 Host: localhost:8080 User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:26.0) Gecko/20100101 Firefox/26.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Connection: keep-alive HTTP/1.1 401 Unauthorized WWW-Authenticate: oauth_problem=token_rejected Date: Fri, 17 Jan 2014 21:12:33 GMT Content-Length: 0 {noformat} What's interesting is that if I set this header in a {{ContainerResponseFilter}}, the client processes it just fine. You can exercise this problem using the {{org.glassfish.test.TestApp}} application in the Maven project attached to this bug.

    Java.net JIRA | 3 years ago | jrh3k5
    javax.ws.rs.ProcessingException: java.lang.IllegalArgumentException: invalid start or end
  2. 0

    I've attached a project that reproduces this. If I have a {{ContainerRequestFilter}} abort a transaction and add a {{WWW-Authenticate}} header missing an authentication scheme (e.g., "Basic " or "OAuth ") and I try to process this response using a Jersey client, I get the following error: {noformat} Exception in thread "main" javax.ws.rs.ProcessingException: java.lang.IllegalArgumentException: invalid start or end at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:236) at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:655) at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:652) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.process(Errors.java:228) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:422) at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:652) at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:387) at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:291) at org.glassfish.test.TestApp.main(TestApp.java:20) Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: invalid start or end at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1137) at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:2338) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:388) at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:276) at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:182) at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:227) ... 10 more Caused by: java.lang.IllegalArgumentException: invalid start or end at sun.net.www.HeaderParser.subsequence(HeaderParser.java:58) at sun.net.www.protocol.http.AuthenticationHeader.parse(AuthenticationHeader.java:155) at sun.net.www.protocol.http.AuthenticationHeader.<init>(AuthenticationHeader.java:119) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1261) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379) ... 13 more {noformat} It's not a problem with the headers, as they seem well-formed (when I hit it using Live HTTP Headers in Firefox): {noformat} http://localhost:8080/ GET / HTTP/1.1 Host: localhost:8080 User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:26.0) Gecko/20100101 Firefox/26.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Connection: keep-alive HTTP/1.1 401 Unauthorized WWW-Authenticate: oauth_problem=token_rejected Date: Fri, 17 Jan 2014 21:12:33 GMT Content-Length: 0 {noformat} What's interesting is that if I set this header in a {{ContainerResponseFilter}}, the client processes it just fine. You can exercise this problem using the {{org.glassfish.test.TestApp}} application in the Maven project attached to this bug.

    Java.net JIRA | 3 years ago | jrh3k5
    javax.ws.rs.ProcessingException: java.lang.IllegalArgumentException: invalid start or end
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    [PDI-6622] OLAP Input step fails when spoon is connected to an EE repository - Pentaho BI Platform Tracking

    pentaho.com | 1 year ago
    java.lang.RuntimeException: java.lang.IllegalArgumentException: URI can't be null.
  5. 0

    Connection to local docker

    GitHub | 2 years ago | alexkamp
    com.spotify.docker.client.DockerException: com.sun.jersey.api.client.ClientHandlerException: java.lang.RuntimeException: java.lang.IllegalArgumentException: protocol = http host = null

    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.lang.IllegalArgumentException

      invalid start or end

      at sun.net.www.HeaderParser.subsequence()
    2. Java RT
      HttpURLConnection.getResponseCode
      1. sun.net.www.HeaderParser.subsequence(HeaderParser.java:58)
      2. sun.net.www.protocol.http.AuthenticationHeader.parse(AuthenticationHeader.java:155)
      3. sun.net.www.protocol.http.AuthenticationHeader.<init>(AuthenticationHeader.java:119)
      4. sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1261)
      5. java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
      5 frames
    3. jersey-core-client
      JerseyInvocation$1.call
      1. org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:276)
      2. org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:182)
      3. org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:227)
      4. org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:655)
      5. org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:652)
      5 frames
    4. Jersey Core
      RequestScope.runInScope
      1. org.glassfish.jersey.internal.Errors.process(Errors.java:315)
      2. org.glassfish.jersey.internal.Errors.process(Errors.java:297)
      3. org.glassfish.jersey.internal.Errors.process(Errors.java:228)
      4. org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:422)
      4 frames
    5. jersey-core-client
      JerseyInvocation$Builder.get
      1. org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:652)
      2. org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:387)
      3. org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:291)
      3 frames
    6. org.glassfish.test
      TestApp.main
      1. org.glassfish.test.TestApp.main(TestApp.java:20)
      1 frame