当我调用使用CXF构建的特定的restful服务方法时,我收到以下错误,有人知道为什么以及如何解决它?
发生JAXBException:类com.octory.ws.dto.ProfileDto也不是它的任何超类都知道这个上下文...
以下是服务方法和相关的DTO:
public class Service { public Response results() { CollectionprofilesDto = new ArrayList (); ... SearchResultDto srd = new SearchResultDto(); srd.setResultEntities(profilesDto); // Setting profilesDto collection as resultEntities srd.setResultSize(resultSize); return Response.ok(srd).build(); } }
SearchResultDto:
@XmlRootElement(name="searchResult") public class SearchResultDto { private Collection resultEntities; private int resultSize; public SearchResultDto() { } @XmlElementWrapper(name="resultEntities") public Collection getResultEntities() { return resultEntities; } public void setResultEntities(Collection resultEntities) { this.resultEntities = resultEntities; } public int getResultSize() { return resultSize; } public void setResultSize(int resultSize) { this.resultSize = resultSize; } }
ProfileDto:
@XmlRootElement(name="profile") public class ProfileDto { ... ... public ProfileDto() { } ... }
lexicore.. 37
您的ProfileDto
课程未被引用SearchResultDto
.尝试添加@XmlSeeAlso(ProfileDto.class)
到SearchResultDto
.
您的ProfileDto
课程未被引用SearchResultDto
.尝试添加@XmlSeeAlso(ProfileDto.class)
到SearchResultDto
.
我有这个错误,因为我在这行代码中注册了错误的类:
JAXBContext context = JAXBContext.newInstance(MyRootXmlClass.class);