title: Problem with JAXB marshalling an object: javax.xml.bind.JAXBException: class ... or any of its super class is known to this context
body: <p>In my JAX-RS project (Jersey) I'm having a problem getting one of the JAXB-annotated objects marshalled to JSON.  Here is the error message I see in the logs:</p>
  
  <blockquote>
    <p>SEVERE: Internal server error
    javax.ws.rs.WebApplicationException: javax.xml.bind.JAXBException: class com.dnb.applications.webservice.mobile.view.CompaniesAndLocations nor any of its super class is known to this context.</p>
  </blockquote>
  
  <p>Does this point to any specific problem?  My resource has a method like this:</p>
  
  <pre><code>@Path("/name/{companyname}/location/{location}")
  @Produces("application/json; charset=UTF-8;")
  @Consumes("application/json")
  @POST
  public Viewable findCompanyByCompanyNameAndLocationAsJSON(@PathParam("companyname") String companyName,
          @PathParam("location") String location, CriteriaView criteria) {
      criteria = criteria != null ? criteria : new CriteriaView();
      criteria.getKeywords().setCompanyName(companyName);
      return getCompanyListsHandler().listsByCompanyNameAndLocation(criteria, location);
  }
  </code></pre>
  
  <p><code>Viewable</code> is an empty interface.  The above method returns an object of type <code>CompaniesAndLocations</code>, defined as follows:</p>
  
  <pre><code>@XmlRootElement
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "companiesAndLocations", propOrder = { "count", "normalizedLocations", "companyList", "companyMap", "modifiers",
          "modifiersMap", "companyCount", "navigators" })
  public class CompaniesAndLocations extends BaseCompanies implements Viewable {
  
      @XmlElement(name = "normalizedLocations", required = false)
      protected List&lt;NormalizedLocation&gt; normalizedLocations;
  
      public List&lt;NormalizedLocation&gt; getNormalizedLocations() {
          if (normalizedLocations == null) {
              normalizedLocations = new ArrayList&lt;NormalizedLocation&gt;();
          }
          return normalizedLocations;
      }
  
  }
  </code></pre>
  
  <p>BaseCompanies defines a number of other fields:</p>
  
  <pre><code>@XmlTransient
  public abstract class BaseCompanies {
  
      @XmlElement(name = "modifiers", required = false)
      private List&lt;Modifiers&gt; modifiers;
  ....
  </code></pre>
  
  <p>I should add that I'm deviating slightly from the approach used by other working code in the app.  The other resource methods get their objects from an ObjectFactory that is annotated with <code>@XmlRegistry</code>.  I don't think this is necessary, though.  I have seen other code that directly instantiates the JAXB-annotated POJO'swithout using the ObjectFactory factory.</p>
  
  <p>Any ideas?</p>