Reputation: 67
I have a Maven jersey server that sends json objects to my JavaFX client, in my server I have model classes that have strings and int and in the client model class I tried to use Stringproperty and IntegerProperty (for the bind use and I have proper getter and setters(setter = name.set("example"), getter = return name.get)) but when I do I get
Both front and backend have JSON as mediatype and when I change client modelclass variables to String and Int everything works as expected.I want to find a way to keep the property of strings and int for the bind method, I tried to google but no one else seems to have had this problem, does anyone know what can solve this and let me use property of variables
I caught the exception as processingException e
e.getCause(): null
e.getMessage():
MessageBodyReader not found for media type=application/json, type=interface java.util.List, genericType=java.util.List<models.Users>.
[org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:207), org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:139), org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1109), org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:853), org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:812), org.glassfish.jersey.client.ClientResponse.readEntity(ClientResponse.java:309), org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:813), org.glassfish.jersey.client.JerseyInvocation.access$600(JerseyInvocation.java:90), org.glassfish.jersey.client.JerseyInvocation$3.call(JerseyInvocation.java:693), org.glassfish.jersey.internal.Errors.process(Errors.java:315), org.glassfish.jersey.internal.Errors.process(Errors.java:297), org.glassfish.jersey.internal.Errors.process(Errors.java:228), org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:422), org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:689), org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:405), org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:301), Repository.UserRepo.getUsers(UserRepo.java:55), cleaner.Cleaner.start(Cleaner.java:35), com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863), com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326), com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295), java.security.AccessController.doPrivileged(Native Method), com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294), com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95), com.sun.glass.ui.win.WinApplication._runLoop(Native Method), com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191), java.lang.Thread.run(Thread.java:745)]
When I run get method with postman the backend works, so that tells me it something with client.
client: glassfish 4.1 Jersey 2.5.1 (JAX-RS RI) javax.ws.rs-api-2.0.1
server: glassfish 4.1 jersey 2.26-b03
Thanks in advance!
Upvotes: 2
Views: 696
Reputation: 6577
Add the following dependency to your client to provide a MessageBodyReader implementation that knows how to deserialize an incoming JSON string to an instance of Users.
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.4.4</version>
</dependency>
Upvotes: 1