JAXB Exception: Class not known to this context

后端 未结 6 1033
-上瘾入骨i
-上瘾入骨i 2020-11-29 04:48

When I call a particular restful service method, which is built using CXF, I get the following error, anyone know why and how to resolve it?

6条回答
  •  無奈伤痛
    2020-11-29 05:31

    This error message happens either because your ProfileDto class is not registered in the JAXB Content, or the class using it does not use @XmlSeeAlso(ProfileDto.class) to make processable by JAXB.

    About your comment:

    I was under the impression the annotations was only needed when the referenced class was a sub-class.

    No, they are also needed when not declared in the JAXB context or, for example, when the only class having a static reference to it has this reference annotated with @XmlTransient. I maintain a tutorial here.

提交回复
热议问题