java.lang.IllegalArgumentException: Illegal uri template: foo/bar:id

JBoss Issue Tracker | Leonard Brünings | 2 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    When calling UriBuilder with a relative path that contains one or more colons, it fails with an IllegalArgumentException. {code:java} javax.ws.rs.core.UriBuilder.fromUri("foo/bar:id") {code} {color:red}{noformat} java.lang.IllegalArgumentException: Illegal uri template: foo/bar:id at org.jboss.resteasy.specimpl.ResteasyUriBuilder.parseHierarchicalUri(ResteasyUriBuilder.java:177) at org.jboss.resteasy.specimpl.ResteasyUriBuilder.uriTemplate(ResteasyUriBuilder.java:135) at org.jboss.resteasy.specimpl.ResteasyUriBuilder.uri(ResteasyUriBuilder.java:188) at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119) {noformat}{color} {code:java} if (!scheme && !"".equals(group) && !group.startsWith("/") && group.indexOf(':') > -1) throw new IllegalArgumentException("Illegal uri template: " + uriTemplate); {code} This line in org.jboss.resteasy.specimpl.ResteasyUriBuilder#parseHierarchicalUri checks explicitly if a colon is contained in the path and throws this exception. According to http://tools.ietf.org/html/rfc3986#appendix-A the colon is allowed in the path at this position. For path-noscheme only the first segment MUST NOT contain a colon, every following segment can contain pchar* including colon. {noformat} path = path-abempty ; begins with "/" or is empty / path-absolute ; begins with "/" but not "//" / path-noscheme ; begins with a non-colon segment / path-rootless ; begins with a segment / path-empty ; zero characters path-abempty = *( "/" segment ) path-absolute = "/" [ segment-nz *( "/" segment ) ] path-noscheme = segment-nz-nc *( "/" segment ) path-rootless = segment-nz *( "/" segment ) path-empty = 0<pchar> segment = *pchar segment-nz = 1*pchar segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" ) ; non-zero-length segment without any colon ":" pchar = unreserved / pct-encoded / sub-delims / ":" / "@" {noformat} This bug causes org.jboss.resteasy.mock.MockHttpRequest#initWithUri(java.lang.String) to fail for relative URIs that contain colons.

    JBoss Issue Tracker | 2 years ago | Leonard Brünings
    java.lang.IllegalArgumentException: Illegal uri template: foo/bar:id
  2. 0

    When calling UriBuilder with a relative path that contains one or more colons, it fails with an IllegalArgumentException. {code:java} javax.ws.rs.core.UriBuilder.fromUri("foo/bar:id") {code} {color:red}{noformat} java.lang.IllegalArgumentException: Illegal uri template: foo/bar:id at org.jboss.resteasy.specimpl.ResteasyUriBuilder.parseHierarchicalUri(ResteasyUriBuilder.java:177) at org.jboss.resteasy.specimpl.ResteasyUriBuilder.uriTemplate(ResteasyUriBuilder.java:135) at org.jboss.resteasy.specimpl.ResteasyUriBuilder.uri(ResteasyUriBuilder.java:188) at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119) {noformat}{color} {code:java} if (!scheme && !"".equals(group) && !group.startsWith("/") && group.indexOf(':') > -1) throw new IllegalArgumentException("Illegal uri template: " + uriTemplate); {code} This line in org.jboss.resteasy.specimpl.ResteasyUriBuilder#parseHierarchicalUri checks explicitly if a colon is contained in the path and throws this exception. According to http://tools.ietf.org/html/rfc3986#appendix-A the colon is allowed in the path at this position. For path-noscheme only the first segment MUST NOT contain a colon, every following segment can contain pchar* including colon. {noformat} path = path-abempty ; begins with "/" or is empty / path-absolute ; begins with "/" but not "//" / path-noscheme ; begins with a non-colon segment / path-rootless ; begins with a segment / path-empty ; zero characters path-abempty = *( "/" segment ) path-absolute = "/" [ segment-nz *( "/" segment ) ] path-noscheme = segment-nz-nc *( "/" segment ) path-rootless = segment-nz *( "/" segment ) path-empty = 0<pchar> segment = *pchar segment-nz = 1*pchar segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" ) ; non-zero-length segment without any colon ":" pchar = unreserved / pct-encoded / sub-delims / ":" / "@" {noformat} This bug causes org.jboss.resteasy.mock.MockHttpRequest#initWithUri(java.lang.String) to fail for relative URIs that contain colons.

    JBoss Issue Tracker | 2 years ago | Leonard Brünings
    java.lang.IllegalArgumentException: Illegal uri template: foo/bar:id

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      Illegal uri template: foo/bar:id

      at org.jboss.resteasy.specimpl.ResteasyUriBuilder.parseHierarchicalUri()
    2. RESTEasy JAX-RS Implementation
      ResteasyUriBuilder.uri
      1. org.jboss.resteasy.specimpl.ResteasyUriBuilder.parseHierarchicalUri(ResteasyUriBuilder.java:177)
      2. org.jboss.resteasy.specimpl.ResteasyUriBuilder.uriTemplate(ResteasyUriBuilder.java:135)
      3. org.jboss.resteasy.specimpl.ResteasyUriBuilder.uri(ResteasyUriBuilder.java:188)
      3 frames
    3. JavaEE 7
      UriBuilder.fromUri
      1. javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
      1 frame