title: javax.xml.bind.PropertyException when jaxb marshalling
body: <p>I am trying to marshal a list of objects into xml.
  Below is the method:</p>
  
  <pre><code>import com.sun.xml.bind.marshaller.NamespacePrefixMapper;
  import javax.xml.bind.Marshaller;
  import javax.xml.bind.JAXBContext;
  import javax.xml.bind.JAXBException;
  
  public class ItemMarshaller
  {
      public String marshallItems(final List&lt;Items&gt; items)
      {
          try
          {
              final JAXBContext context = JAXBContext.newInstance("com.project.jaxb.items");
              final Marshaller m = context.createMarshaller();
              m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
  
              m.setProperty("com.sun.xml.bind.namespacePrefixMapper", new NamespacePrefixMapper()
              {
                  @Override
                  public String getPreferredPrefix(String uri, String suggestion, boolean requirePrefix)
                  {
                      return "";
                  }
              });
  
              final StringWriter writer = new StringWriter();
              m.marshal(items, writer);
  
              return writer.toString();
          }
          catch (final JAXBException e)
          {
              ErrorLogger.LOGGER.error("Marshalling failed.", e); //$NON-NLS-1$
          }
  
          return null;
      }
  }
  </code></pre>
  
  <p>When I call m.setProperty("com.sun.xml.bind.namespacePrefixMapper", new NamespacePrefixMapper() I get the following error:</p>
  
  <pre><code>javax.xml.bind.PropertyException: name: com.sun.xml.bind.namespacePrefixMapper value: com.project.ItemMarshaller$1@eb6e072
  at javax.xml.bind.helpers.AbstractMarshallerImpl.setProperty(AbstractMarshallerImpl.java:358)
  at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.setProperty(MarshallerImpl.java:527)
  </code></pre>
  
  <p>Now if I use the Internal class:
  com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper;</p>
  
  <p>instead, it works. However this project is to be built using maven and it complains when you have a dependency on an internal class. Also it's a bad idea to use internal classes, or so I'm told.</p>
  
  <p>How can I fix this?</p>