当我对 Oracle Responsys 进行 REST API 调用时,收到以下错误消息:org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor aroundWriteTo
SEVERE: MessageBodyWriter not found for media type=application/json, type=class oracle.responsys.entities.RecipientData, genericType=class oracle.responsys.entities.RecipientData.
以下是我使用的代码片段:
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import oracle.responsys.*;
MetaInfo metaInfo1 = new MetaInfo("CUSTOM1", "c1b_value_new");
MetaInfo metaInfo2 = new MetaInfo("CUSTOM2", "c2b_value_new");
ListName listName = new ListName("WS_REST_SAMPLE", "wsrest");
List<MetaInfo> metaInfoList = new ArrayList<MetaInfo>();
metaInfoList.add(metaInfo1);
metaInfoList.add(metaInfo2);
Recipient recipient = new Recipient("2", "baz.foo@oracle.com", listName, null, null, "TEXT_FORMAT");
RecipientData data = new RecipientData(recipient, metaInfoList );
Client CLIENT = ClientBuilder.newClient();
Config CONFIG = new Config();
ObjectMapper objectMapper = new ObjectMapper();
WebTarget target = CLIENT.target(getAUTHENTICATION().getEndPoint()+CONFIG.getTEST());
Response response = target.request(MediaType.APPLICATION_JSON)
.header("Authorization", AUTHENTICATION.getAuthToken())
.post(
Entity.json(data)
);
并收到以下错误消息:
org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor aroundWriteTo
SEVERE: MessageBodyWriter not found for media type=application/json, type=class oracle.responsys.entities.RecipientData, genericType=class oracle.responsys.entities.RecipientData.
org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/json, type=class oracle.responsys.entities.RecipientData, genericType=class oracle.responsys.entities.RecipientData.
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:247)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1130)
at org.glassfish.jersey.client.ClientRequest.doWriteEntity(ClientRequest.java:517)
at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:499)
at org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:393)
at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:285)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:252)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:684)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:681)
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:444)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:681)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:437)
at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:343)
at oracle.responsys.restservices.OracleResponsysRestService.testAPI(OracleResponsysRestService.java:173)
at Main.main(Main.java:22)
请帮助我。