A message body writer for Java class not found

前端 未结 6 854
花落未央
花落未央 2020-12-01 04:46

I am new to using JAX-RS and wrote a sample application that outputs a json object. but I am getting an exception. Here is my code:

@Path(\"/hello\")
public          


        
6条回答
  •  醉梦人生
    2020-12-01 05:35

    Working with Jersey 1.8, I was getting the same error while creating a JSON object and hitting a REST API from client side.

    If you are facing issue at server side then, make sure that you have correctly included jersey-json.jar in classpath and mapped correct init-param in web.xml as mentioned in other answers.

    For Client Side

    As per Jersey 1.8 documentation, the following snippet shows how to use the POJO JSON mapping feature on the client side:

     ClientConfig clientConfig = new DefaultClientConfig();
     clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,Boolean.TRUE);
     Client client = Client.create(clientConfig);
    

提交回复
热议问题