Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Jersey » Message Body Writer for Moxy List
Message Body Writer for Moxy List [message #1840504] Fri, 16 April 2021 18:36 Go to next message
Brian Lavender is currently offline Brian LavenderFriend
Messages: 20
Registered: July 2009
Junior Member
I am trying to send json in my REST POST, yet when I try to pass a List to the writer, the interceptor that sets the MessageBodyWriter comes up with nothing and throws an exception. I am using the Moxy provider. Any help?

List<AMCRegistration> customers = new ArrayList<>();
customers.add(myReg);

Client client = ClientBuilder.newClient();

HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("user", "pass");
client.register(feature);
WebTarget target = client.target("https://foosvc.foo.org/api/amc");
target = target.path("PostFOO");
// Exception thrown here
String postResponse = target.request(MediaType.APPLICATION_JSON)
                .post(Entity.entity(customers, MediaType.APPLICATION_JSON),String.class);


Apr 16, 2021 11:29:02 AM org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor aroundWriteTo
SEVERE: MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList, genericType=class java.util.ArrayList.
Exception in thread "main" org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/json, type=class java.util.ArrayList, genericType=class java.util.ArrayList.


<dependency>
	<groupId>org.glassfish.jersey.media</groupId>
	<artifactId>jersey-media-moxy</artifactId>
</dependency>		
Re: Message Body Writer for Moxy List [message #1840511 is a reply to message #1840504] Fri, 16 April 2021 23:31 Go to previous message
Brian Lavender is currently offline Brian LavenderFriend
Messages: 20
Registered: July 2009
Junior Member
I switched over to the jackson support and turned on debugging. It was able to map the data into the correct json. I also turned on debugging to see what was going on.
Client client = ClientBuilder
   .newBuilder()
    .property(LoggingFeature.LOGGING_FEATURE_VERBOSITY_CLIENT, LoggingFeature.Verbosity.PAYLOAD_ANY)
     .property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_CLIENT, "INFO")
    .build();


<dependency>
	<groupId>org.glassfish.jersey.media</groupId>
	<artifactId>jersey-media-json-jackson</artifactId>
</dependency>
Previous Topic:IPv6 support
Next Topic:Jersey/Jetty API Handler/Container re-sends the GET request every 1 min
Goto Forum:
  


Current Time: Thu Jul 07 08:43:10 GMT 2022

Powered by FUDForum. Page generated in 0.02177 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top