I'm trying to include Jersey client (1.11) APIs into my application. My application classes are packaged in a JAR w/a Manifest. When I run the jar with 'java -jar' and specify all the Jersey client dependent JARs in the cmd line's classpath arg list it all works fine.
Now I wanted to simplify deployment down to one single JAR so I configured my IDEA project to explode all the dependent JARs into the top level of my JAR so its structure looks something like this:
- com <- The MAIN class pointed to by the MANIFEST is in this folder
When I run it using that jar with: 'java -jar application.jar' it runs fine up until the point that I invoke a webResource which has an entity class. For example:
Foo myFoo = webResource.type(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON).post(Foo.class);
When that call is made I'll get:
SEVERE: A message body reader for Java class com.bar.Foo, and Java type class of com.bar.Foo, and MIME media type application/json was not found
blah blah blah
I've tried this using JAXB JSON mapping and the simple Jackson based POJO mapping and I get the same results. It works when the dependent JARs are separate from the application JAR and listed on the java cmd line class path but not when everything is exploded into one jar.
Interestingly I tried using one-jar  which keeps all the dependancies packaged in their original JARs but rolls them into your applications JAR and plays classloader tricks to load things up. In that case the application works fine. However, I don't really want to have to add one-jar to the mix if I don't have to. I'm not sure why the exploded method does not work but I have the suspicion its classloader related.
you are not merging META-INF/services/* files correctly; these files are most likely just replaced which denies discoverability of some providers (MessageBodyReaders and Writers in this case).
On 5/23/12 12:47 AM, Noah White wrote:
Thanks for the tip! I'll check it out.
On May 23, 2012, at 5:00 AM, Pavel Bucek wrote:
|Powered by Nabble||Edit this page|