title: Problems with JAXB, Marshal, - unable to marshal type "java.lang.String"
body: <p>i have a problem, I generated the classes using a schema xsd with xjc. when I run the marshal operation I get the following error: </p>
  
  <pre><code>[com.sun.istack.internal.SAXException2: unable to marshal type "java.lang.String" as an element because it is missing an @XmlRootElement annotation]    at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(Unknown Source)    at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(Unknown Source)  at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(Unknown Source)    at prova.StampGenericXML.staticStampGenericXML(StampGenericXML.java:42)     at prova.TestLauncher.main(TestLauncher.java:199) Caused by: com.sun.istack.internal.SAXException2: unable to marshal type "java.lang.String" as an element because it is missing an @XmlRootElement annotation     at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.reportError(Unknown Source)   at com.sun.xml.internal.bind.v2.runtime.LeafBeanInfoImpl.serializeRoot(Unknown Source)  at com.sun.xml.internal.bind.v2.runtime.property.SingleReferenceNodeProperty.serializeBody(Unknown Source)  at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(Unknown Source)     at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(Unknown Source)    at com.sun.xml.internal.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(Unknown Source)    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(Unknown Source)     at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(Unknown Source)    at com.sun.xml.internal.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(Unknown Source)    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(Unknown Source)     at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(Unknown Source)    at com.sun.xml.internal.bind.v2.runtime.property.ArrayElementNodeProperty.serializeItem(Unknown Source)     at com.sun.xml.internal.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(Unknown Source)     at com.sun.xml.internal.bind.v2.runtime.property.ArrayERProperty.serializeBody(Unknown Source)  at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(Unknown Source)     at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(Unknown Source)    at com.sun.xml.internal.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(Unknown Source)    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(Unknown Source)     at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(Unknown Source)    at com.sun.xml.internal.bind.v2.runtime.property.ArrayElementNodeProperty.serializeItem(Unknown Source)     at com.sun.xml.internal.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(Unknown Source)     at com.sun.xml.internal.bind.v2.runtime.property.ArrayERProperty.serializeBody(Unknown Source)  at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(Unknown Source)     at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(Unknown Source)    at com.sun.xml.internal.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(Unknown Source)    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(Unknown Source)     at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(Unknown Source)    at com.sun.xml.internal.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(Unknown Source)    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(Unknown Source)     at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsSoleContent(Unknown Source)    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(Unknown Source)     at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(Unknown Source)
  </code></pre>
  
  <p><strong>the portion of the xsd code is:</strong></p>
  
  <pre><code>&lt;xsd:complexType name="formattedText"&gt;
      &lt;xsd:annotation&gt;
          &lt;xsd:documentation&gt;Formatted text according to parts of XHTML 1.1  &lt;/xsd:documentation&gt;
      &lt;/xsd:annotation&gt;
      &lt;xsd:sequence&gt;
          &lt;xsd:any namespace="http://www.w3.org/1999/xhtml" processContents="lax"/&gt;
      &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;
  </code></pre>
  
  <p>the class FormattedText is:</p>
  
  <pre><code>import javax.xml.bind.annotation.XmlAccessType;
  import javax.xml.bind.annotation.XmlAccessorType;
  import javax.xml.bind.annotation.XmlAnyElement;
  import javax.xml.bind.annotation.XmlType;
  import org.w3c.dom.Element;
  </code></pre>
  
  <p>/**
   * Formatted text according to parts of XHTML 1.1
   * 
   * <p>Java class for formattedText complex type.
   * 
   * <p>The following schema fragment specifies the expected content contained within this class.
   * 
   * <pre>
   * &lt;complexType name="formattedText">
   *   &lt;complexContent>
   *     &lt;restriction base="{<a href="http://www.w3.org/2001/XMLSchema" rel="nofollow">http://www.w3.org/2001/XMLSchema</a>}anyType">
   *       &lt;sequence>
   *         &lt;any processContents='lax' namespace='<a href="http://www.w3.org/1999/xhtml" rel="nofollow">http://www.w3.org/1999/xhtml</a>'/>
   *       &lt;/sequence>
   *     &lt;/restriction>
   *   &lt;/complexContent>
   * &lt;/complexType>
   * </pre>
   * 
   * 
   *</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "formattedText", propOrder = {
  "any"
  })
  public class FormattedText {
  
  @XmlAnyElement(lax = true)
  protected Object any;
  
  /**
   * Gets the value of the any property.
   * 
   * @return
   *     possible object is
   *     {@link Element }
   *     {@link Object }
   *     
   */
  public Object getAny() {
      return any;
  }
  
  /**
   * Sets the value of the any property.
   * 
   * @param value
   *     allowed object is
   *     {@link Element }
   *     {@link Object }
   *     
   */
  public void setAny(Object value) {
      this.any = value;
  }
  
  }
  </code></pre>
  
  <p><strong>this is the class for the marshal operation</strong></p>
  
  <pre><code>public class StampGenericXML {  
  static public void staticStampGenericXML(Object objectJAXB, String context) throws ParserConfigurationException, SAXException, TransformerException{
      try {
  
          JAXBContext jaxbLocalContext = JAXBContext.newInstance ("org.plcopen.xml.tc6_0201");
  
          Marshaller marshaller = jaxbLocalContext.createMarshaller();
          marshaller.setProperty(marshaller.JAXB_FORMATTED_OUTPUT, true);
          marshaller.marshal(objectJAXB, System.out);
      } catch (JAXBException e1) {            
          e1.printStackTrace();
      }
  
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>When i create a FormattedText object:</p>
  
  <pre><code>FormattedText text = new FormattedText();
  text.setAny("table");
  </code></pre>
  
  <p>and run the project i have thi error.
  Why?
  please help me. 
  thanks</p>