title: @XmlAnyElement on a single Object to accept entities (@XmlRootElement) and java.lang.String
body: <p>I want to annotate a single element to marshall to :</p>
  
  <pre><code>&lt;root&gt;
      &lt;entity&gt;Any String&lt;/entity&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>&lt;root&gt;
      &lt;entity&gt;
          &lt;myEntity&gt;&lt;name&gt;Entity id
                    &lt;/name&gt;
          &lt;/myEntity&gt;
      &lt;/entity&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>Where <code>entity</code> can be an entity annotated with <code>@XmlRootElement</code> or an instance of <code>java.lang.String</code>. This is the class:</p>
  
  <pre><code>@XmlRootElement( name = "root" )
  public class Root {
  
      @XmlAnyElement
      private Object entity;
  
  // setter...
  }
  </code></pre>
  
  <p>The <code>javadoc</code> says:</p>
  
  <pre><code>This annotation can be used with {@link XmlMixed} like this:
  // List of java.lang.String or DOM nodes.
  @XmlAnyElement @;XmlMixed
  List&lt;Object&gt; others;
  </code></pre>
  
  <p>But it's for a <code>List</code>. Nevetherless I tried but same thing. I place a <code>java.lang.String</code> it throws:</p>
  
  <pre><code>com.sun.istack.SAXException2: unable to marshal type "java.lang.String" as an element because it is missing an @XmlRootElement annotation
  </code></pre>
  
  <p>What am I missing.</p>
  
  <p>Thanks.</p>