I've got a Dropwizard project (using Jersey 2.x) where I need to use another library that has a dependency on jersey-client from 1.x and I'm having some trouble getting both to coexist on the classpath. It looks like what is happening is that HK2 is finding anything that implements providers from javax.ws.rs.* and attempting to instantiate them. When it's a class from Jersey 1.x, the dependency injection that it needs isn't there and I end up with lots of errors like:
Caused by: java.lang.IllegalArgumentException: The MultiPartConfig instance we expected is not present. Have you registered the MultiPartConfigProvider class?
at com.sun.jersey.multipart.impl.MultiPartReaderClientSide.<init>(MultiPartReaderClientSide.java:107)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1107)
at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:274)
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:368)
Is there any way to get Jersey 2.x/HK2 to ignore anything in the com.sun.jersey.* package space?