0

I am trying to return a Single.just(..) from my endpoint. I have created it using jersey and rx-jersey. I keep getting this message on my browser:

No serializer found for class io.reactivex.internal.operators.single.SingleJust and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)

Here is my code:-

JerseyCOnfig:

@Component
public class JerseyConfig  extends ResourceConfig {

    public JerseyConfig() {
        register(RxJerseyServerFeature.class);
        register(RxJerseyClientFeature.class);
        register(new JacksonJsonProvider(new ObjectMapper().disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)));
        register(UserService.class);
    }
}

My End point

@Path("/users")
public class UserService {

    @GET
    @Path("/setup/rx")
    @Produces(MediaType.APPLICATION_JSON)
    public Single<User> setupRx() {
        return Single.just(new User(29));
    }
}

User:-

    public class User {

        private Integer age;
//getters and settters
Amar Dev
  • 1,360
  • 2
  • 18
  • 38

1 Answers1

0

It doesn't make sense for the jersey service to return any kind of observable. You would use chains of observables to produce concrete files or pages, but not observables.

In your case, the result of the GET method would be User, not instructions on how to get User.

Bob Dalgleish
  • 8,167
  • 4
  • 32
  • 42
  • I want to create a backend service that fetches data from DB reactively. This is a trivial example but the idea is that the UI based on react will call this backend service to get details – Amar Dev May 07 '18 at 20:45
  • Whether it is reactive or not, you cannot serve an observable over the internet. At some point, you have to transmit real data values. – Bob Dalgleish May 07 '18 at 20:57
  • My apologies for the confusion that I caused. Were you able to copy and paste the sample code and get it working? – Bob Dalgleish May 08 '18 at 14:28
  • Its ok, you don' t need to apologise. No, I was not able to make it work!!! – Amar Dev May 08 '18 at 14:52
  • @AmarDev Stop using `!!!`. In American culture it's like you are screaming at the person. It's like using all capitals. – Paul Samsotha May 08 '18 at 19:23
  • Oh apologies, I did not know. Any ideas about my issue here. – Amar Dev May 08 '18 at 19:48