Search code examples
glassfishjerseyjax-rsglassfish-3

Jersey REST URISyntaxException


I am facing an issue at our glassfish 3.1.2 production server. I have a Jersey REST project deployed and it is throwing URISyntaxException when there is a 'space' in path parameter for any URL. For example if I hit this URL: http://MyDomain:8080/MyApp/MyVersion/MyService/MyPathParam/My%20Path%20param Jersey throws java.lang.IllegalArgumentException with root cause java.net.URISyntaxException: Illegal character in path at index 155: http://MyDomain:8080/MyApp/MyVersion/MyService/MyPathParam/My Path param

The error does not occurs for query parameter. This issue is not reproducible at test environment. Is there any possibility at production glassfish which decodes path parameters before Jersey gets them and jersey throws the above exception? I gone through this link which specifies that glassfish has the facility to decode the request parameters before it reaches to our application, but I didn't get the clear idea. Please help me to get rid of this issue.


Solution

  • The Apache Load Balancer was the culprit! mod_jk was decoding the URL and it was forwarding decoded URL to one of the glassfish server. Hence jersey jax rs was throwing URISyntaxException. Issue resolved by changing the property JkOptions of mod_jk configuration from +ForwardURICompat to +ForwardURICompatUnparsed