0
我在客戶端應用程序有這樣的代碼發送對象作爲XML
Client c = ClientBuilder.newClient();
WebTarget t = c.target("http://localhost:8080/PlayerRest/r/Player");
Player p = new Player();
p.setPid(new Integer(954));
p.setNickname("testForPUT");
t.request(MediaType.APPLICATION_XML).put(Entity.entity(p, MediaType.APPLICATION_XML));
這給了我多汁例外:
Exception in thread "main" org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/xml, type=class Player, genericType=class Player.
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:227)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:149)
at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1139)
at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:495)
at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:270)
at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:182)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:227)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:655)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:652)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:422)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:652)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:412)
at org.glassfish.jersey.client.JerseyInvocation$Builder.put(JerseyInvocation.java:306)
at ClientRest.main(ClientRest.java:20)
可能是什麼問題就在這裏?
謝謝!