This Question have 2 answers right now.

Trouble with Jersey MIME Type “text/xml;charset=UTF-8 was not found”

By : jonbros
Source: Stackoverflow.com
Question!

Why do I get the following Exception when running the program within a jar bundle, but not getting this Exception when executing it within netbeans?

com.sun.jersey.api.client.ClientHandlerException: A message body reader for Java class javax.xml.bind.JAXBElement, and Java type javax.xml.bind.JAXBElement, and MIME media type text/xml;charset=UTF-8 was not found

I am building my program with maven and the assembly plugin.

mvn assembly:assembly

What does netbeans do different when I am running "Run File"?

By : jonbros


Answers

Somehow the JAXB provider was not found. Probably some classpath problem: in Netbeans the class was added to the classpath, while in maven it wasn't.

I suggest you compare the actual classpathes. In Maven you can see the actual classpath by running mvn dependency:build-classpath. Not sure how to do it in Netbeans.

By : Tarlog


I've asked the same question on the jersey mailing (http://java.net/projects/jersey/lists) list and recieved a working answer, which leaves me answering my on question here. But I have to admit that I dont completely understand the solution and reason for the problem. So please fell free to leave some comments or a new answer.

The problem seems to be, that the assembly plugin is not correctly merging some META-INF files. As I undertand there needs to be a renaming of descriptions or so!?

Instead of using the assembly plugin for maven use the shade plugin!

Read the problem and solution here: http://jersey.576304.n2.nabble.com/issue-with-POST-when-packaging-into-jar-td5460103.html

And see the shade plugin for maven here: http://maven.apache.org/plugins/maven-shade-plugin/

By : jonbros


Video about Trouble with Jersey MIME Type “text/xml;charset=UTF-8 was not found”