title: JAXB Exception: Class not known to this context
body: <p>When I call a particular restful service method, which is built using <em>CXF</em>, I get the following error, anyone know why and how to resolve it?</p>
  
  <blockquote>
    <p>JAXBException occurred : class
    com.octory.ws.dto.<strong>ProfileDto</strong> nor any
    of its super class is known to this
    context...</p>
  </blockquote>
  
  <p>Following are the service method and relevant DTOs:</p>
  
  <pre><code>public class Service {
     public Response results() {
     Collection&lt;ProfileDto&gt; profilesDto = new ArrayList&lt;ProfileDto&gt;();
     ...
     SearchResultDto srd = new SearchResultDto();
     srd.setResultEntities(profilesDto); // Setting profilesDto collection as resultEntities
     srd.setResultSize(resultSize);
     return Response.ok(srd).build();
     }
  }
  </code></pre>
  
  <p><strong>SearchResultDto:</strong></p>
  
  <pre><code>@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;
      }
  }
  </code></pre>
  
  <p><strong>ProfileDto:</strong></p>
  
  <pre><code>@XmlRootElement(name="profile")
  public class ProfileDto {
      ...
      ...
      public ProfileDto() { }
      ...
  }
  </code></pre>