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

元气小坏坏 提交于 2019-12-06 09:12:14

问题


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"?


回答1:


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/




回答2:


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.



来源:https://stackoverflow.com/questions/4945944/trouble-with-jersey-mime-type-text-xmlcharset-utf-8-was-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!