MIMEParsingException in REST

I have a question about MIMEParsingException. I am using Java EE 6 with NetBeans 6.8. I am writing a simple Java REST web service to print "hello world", it works 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 runs without errors, but when I run it, it throws a MIMEParsingException on this line: Client client = Client.create (config);

"main" com.sun.jersey.spi.service.ServiceConfigurationError: jersey-client-components: , org/jvnet/mimepull/MIMEParsingException, com.sun.jersey.multipart. impl.MultiPartReader, java.lang.Object . .        com.sun.jersey.spi.service.ServiceFinder.fail(ServiceFinder.java:388)        com.sun.jersey.spi.service.ServiceFinder.access $200 (ServiceFinder.java:144)        com.sun.jersey.spi.service.ServiceFinder $LazyClassIterator.next(ServiceFinder.java:595)        com.sun.jersey.spi.service.ServiceFinder $LazyClassIterator.next(ServiceFinder.java:571)        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)        helloWorld.client.HelloWorldClient.main(HelloWorldClient.java:29)

? .

+3
1
+5

Source: https://habr.com/ru/post/1748546/


All Articles