MIMEParsingException in REST

孤街浪徒 提交于 2020-01-14 20:13:49

问题


I have a question about MIMEParsingException. I use Java EE 6 with NetBeans 6.8. I write a simple REST web service in Java to print "hello world", it runs well. Then I write a REST web services client (Java Main Class) to test REST :

public class HelloWorldClient {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    ClientConfig config = new DefaultClientConfig();
    Client client = Client.create(config);
    WebResource service = client.resource(getBaseURI());
    String xml = service.path("resources").path("helloworld").accept(MediaType.TEXT_XML).get(String.class);
    System.out.println(xml);
}

private static URI getBaseURI() {
    return UriBuilder.fromUri("http://localhost:8080/HelloWorldApplication").build();
}

}

It complies without error, but when I run it, it throws MIMEParsingException at this line : Client client = Client.create(config);

Exception in thread "main" com.sun.jersey.spi.service.ServiceConfigurationError: jersey-client-components: A dependent class, org/jvnet/mimepull/MIMEParsingException, of the class com.sun.jersey.multipart.impl.MultiPartReader implementing the provider class java.lang.Object is not found. The provider implementation is ignored. at com.sun.jersey.spi.service.ServiceFinder.fail(ServiceFinder.java:388) at com.sun.jersey.spi.service.ServiceFinder.access$200(ServiceFinder.java:144) at com.sun.jersey.spi.service.ServiceFinder$LazyClassIterator.next(ServiceFinder.java:595) at com.sun.jersey.spi.service.ServiceFinder$LazyClassIterator.next(ServiceFinder.java:571) at com.sun.jersey.spi.service.ServiceFinder.toClassArray(ServiceFinder.java:374) at com.sun.jersey.api.client.Client.(Client.java:167) at com.sun.jersey.api.client.Client.(Client.java:139) at com.sun.jersey.api.client.Client.create(Client.java:466) at helloWorld.client.HelloWorldClient.main(HelloWorldClient.java:29)

Who can resolve this problem ? Thanks a lot.


回答1:


You're missing a dependency:

Non-maven developers require:

mimepull.jar, jersey-multipart.jar



来源:https://stackoverflow.com/questions/2975513/mimeparsingexception-in-rest

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