title: Problems with JAXB, Marshal, - unable to marshal type “java.lang.String”
body: <p>when I run the marshal operation I get the following error: </p>
  
  <pre><code>javax.xml.bind.MarshalException
   - with linked exception:
  [com.sun.istack.internal.SAXException2: unable to marshal type "java.lang.String" as an element because it is missing an @XmlRootElement annotation]
      ...
  
  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(XMLSerializer.java:237)
      at com.sun.xml.internal.bind.v2.runtime.LeafBeanInfoImpl.serializeRoot(LeafBeanInfoImpl.java:126)
      at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:483)
      at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:308)
      ... 6 more
  </code></pre>
  
  <p>This is my function for Marshalling...  </p>
  
  <pre><code>public StringBuffer Marshaller(Object marshall){   // make marshalling-&gt;Java to XML
          StringWriter writer = new StringWriter();
          try {
              JAXBContext jaxbContext=JAXBContext.newInstance(marshall.getClass());
              Marshaller jaxbMarshaller=jaxbContext.createMarshaller();
              // çıktı
              jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
              jaxbMarshaller.marshal(marshall, writer);
              System.out.println(writer.getBuffer().toString());
          } catch (PropertyException e) {
              e.printStackTrace();
          } catch (JAXBException e) {
              e.printStackTrace();
          }
          return writer.getBuffer();
  
      }
  </code></pre>
  
  <p>Thanks for your interests..</p>