Jersey returns 500 when trying to return an XML response

前端 未结 4 1200
闹比i
闹比i 2021-01-20 03:56

I\'m trying to create my own RESTful WS application using Jersey 2.12 based from this article. I want to return an XML representation of a class depending on the id been pas

4条回答
  •  一整个雨季
    2021-01-20 04:51

    This happens when you don't provide a default no arg constructor to your JAXB bean. So in your case you should amend the class by adding one:

      public TestRestModel(){
    
        }
    

    This is due to a requirement in the JSR-222:

    existing types, authored by users, are required to provide a no arg constructor. The no arg constructor is used by an unmarshaller during unmarshalling to create an instance of the type.

提交回复
热议问题