title: Using JDK's JAXB without ns2 prefix
body: <p>After having read all posts about this on Oracle forums, Stackoverflow, java.net I'm finally posting here.
  I'm using JAXB to create XML files but the problem is that it adds the famous <strong>ns2</strong> prefix before my elements, I have tried all the solutions no one worked for me.
  java -version gives "1.6.0_37"</p>
  
  <p><strong>Solution 1 : Using package-info.java</strong></p>
  
  <p>I created the file in my package containing my @Xml* annotated classes with the following content :</p>
  
  <pre><code>@XmlSchema(
      namespace = "http://mynamespace",
      elementFormDefault = XmlNsForm.QUALIFIED,
      xmlns = {
          @XmlNs(namespaceURI = "http://mynamespace", prefix = "")
      }
  )
  package com.mypackage;
  import javax.xml.bind.annotation.XmlNs;
  import javax.xml.bind.annotation.XmlNsForm;
  import javax.xml.bind.annotation.XmlSchema;
  </code></pre>
  
  <p><strong>Solution 2 : NamespacePrefixMapper</strong></p>
  
  <p>I created the following class and set the mapper to the marshaller :</p>
  
  <pre><code>// Change mapper to avoid ns2 prefix on generated XML
  class PreferredMapper extends NamespacePrefixMapper {
      @Override
      public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) {
          return "";
      }
  }
  NamespacePrefixMapper mapper = new PreferredMapper();
  try {
      marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", mapper);
  }
  catch (PropertyException e) {
     logger.info("No property for com.sun.xml.bind.namespacePrefixMapper found : " + e.getMessage());
  }
  </code></pre>
  
  <p>With <em>com.sun.xml.bind.namespacePrefixMapper</em> nothing happens, with <em>com.sun.xml.internal.bind.namespacePrefixMapper</em>, it throws the exception.</p>
  
  <p>I've also addded the maven dependency in my pom, but it seems that JRE version has a higher priority :</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;com.sun.xml.bind&lt;/groupId&gt;
      &lt;artifactId&gt;jaxb-impl&lt;/artifactId&gt;
      &lt;version&gt;2.2.4&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Can you help me on this ?</p>
  
  <p>PS : I can't include directly the jar in my classpath for build reasons.
  PS2 : I can't use JDK7.
  Thanks in advance.</p>