Jersey Exception : SEVERE: A message body reader for Java class

后端 未结 15 1865
说谎
说谎 2020-11-29 11:08

I have a Jersey based Rest WS which outputs JSON. I am implementing a Jersey Client to invoke the WS and consume the JSON response. The client code I have is below



        
相关标签:
15条回答
  • 2020-11-29 11:40

    I know that this post is old and you figured this out a long time ago, but just to save the people who will read this some time.

    You probably forgot to add annotation to the entity you are passing to the endpoint, so Jersey does not know how to process the POJO it receives. Annotate the pojo with something like this:

    @XmlRootElement(name = "someName")
    
    0 讨论(0)
  • 2020-11-29 11:43

    To make it work you only need two things. Check if you are missing:

    1. First of all, you need @XmlRootElement annotation for your object class/entity.
    2. You need to add dependency for jersey-json if you are missing.For your reference I added this dependency into my pom.xml.

      <dependency>
          <groupId>com.sun.jersey</groupId>
          <artifactId>jersey-json</artifactId>
          <version>1.17.1</version>
      </dependency>
      
    0 讨论(0)
  • 2020-11-29 11:43

    just put this

        <init-param>
            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
            <param-value>true</param-value>
        </init-param>
    
    0 讨论(0)
提交回复
热议问题