问题
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