JAX-RS URISyntaxException after upgrade to WebLogic 12.1.3+

REST clients fail after WebLogic upgrade from 12.1.2 to 12.1.3 or 12.2.1.

WebLogic 12.1.2 is shipped with Jersey 1.13 and my REST clients are working fine. However, after upgrading WebLogic, they fail as follows:

javax.ws.rs.core.UriBuilderException: java.net.URISyntaxException: Illegal character in path at index 71: http://xxx.no/app/rest/MyRestWS/MyRestMethod/%7B"data":"JTDER28E303031815","active":false%7D
	at com.sun.jersey.api.uri.UriBuilderImpl.createURI(UriBuilderImpl.java:723)
	at com.sun.jersey.api.uri.UriBuilderImpl._build(UriBuilderImpl.java:651)
	at com.sun.jersey.api.uri.UriBuilderImpl.build(UriBuilderImpl.java:641)
	at com.sun.jersey.api.client.WebResource.<init>(WebResource.java:88)
	at com.sun.jersey.api.client.WebResource.path(WebResource.java:396)
	at no.company.app.restclient.wsclient.AppClient.toDataList(AppClient.java:46)
	...

There is a bug reported for for version 1.18.1 - Bug in URL encoding in 1.18.1 but the problem is present in 1.18 as well.

As it appears, downgrading to version 1.17.1 fixes the problem and is done by following the documentation to change the Jersey version used: How to Update the Version of Jersey JAX-RS RI in an EAR File

Action plan outline:

1) Update weblogic-application.xml (or weblogic.xml depending structure)
2) Include jersey-bundle 1.17.1 in your application.
3) Redeploy

weblogic-application.xml

<prefer-application-packages>
    <!-- jersey-bundle-*.jar -->
    <package-name>com.sun.jersey.*</package-name>
    <package-name>com.sun.research.ws.wadl.*</package-name>
    <package-name>com.sun.ws.rs.ext.*</package-name>
    <!-- Jackson-*.jar -->
    <package-name>org.codehaus.jackson.*</package-name>
    <!-- jettison-*.jar -->
    <package-name>org.codehaus.jettison.*</package-name>
    <!-- jsr311*.jar -->
    <package-name>javax.ws.rs.*</package-name>
    <!-- asm.jar -->
    <package-name>org.objectweb.asm.*</package-name>    
</prefer-application-packages>

If you’re building with Maven you also need to add the following to your project’s POM file:

pom.xml

 <dependency>
	<groupId>com.sun.jersey</groupId>
	<artifactId>jersey-bundle</artifactId>
	<version>1.17.1</version>
</dependency>
<!-- Optional - include if you use JSON binding -->
<dependency>
	<groupId>org.codehaus.jettison</groupId>
	<artifactId>jettison</artifactId>
	<version>1.3.7</version>
</dependency>

Now you can live happily even after upgrading WebLogic and you don’t have to rewrite your REST clients to JAX-RS 2.0 which is kinda fiddly because of public API changes.