title: How to specify a particular JAXB implementation?
body: <p>It seems as though I have already done this once in the past, but I cannot find any reference to what I had done to get it to work.</p>
  
  <p>I have a web application in which I want to specify a different JAXB implementation than the one provided by my web server/jre.  I downloaded the appropriate artifact from maven, and see that the jar is properly packaged in my war, however, when I start my web app, I see that it is still using the bundled JRE implementation.</p>
  
  <p>I vaguely remember something about a properties file that I could configure, but cannot find a reference to how it needs to be configured.  Moreover, if the implementation I want to use is the same one (just a newer version), the class names would be the same as though packaged in the JRE.  How can I specify that I want to use the ones bundled in my WAR?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I'm currently running on JBoss 7.0.2, with Oracle JDK 1.6_0_27, JAXB RI that comes with the JRE (I think it is v2.1).  I'm trying to upgrade to JAXB RI 2.2.5 (found on MvnRepository). </p>
  
  <p>I've done a little more digging this morning, and noticed a strange error message in my logs:</p>
  
  <pre><code>09:43:18,325 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-12) Class Path entry jaxb-api.jar in "/C:/servers/jboss-as-7.0.2.Final/standalone/deployments/LendingSimulationServiceEAR.ear/LendingSimulationService.war/WEB-INF/lib/jaxb-impl-2.2.5.jar"  does not point to a valid jar for a Class-Path reference.
  09:43:18,325 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-12) Class Path entry activation.jar in "/C:/servers/jboss-as-7.0.2.Final/standalone/deployments/LendingSimulationServiceEAR.ear/LendingSimulationService.war/WEB-INF/lib/jaxb-impl-2.2.5.jar"  does not point to a valid jar for a Class-Path reference.
  09:43:18,326 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-12) Class Path entry jsr173_1.0_api.jar in "/C:/servers/jboss-as-7.0.2.Final/standalone/deployments/LendingSimulationServiceEAR.ear/LendingSimulationService.war/WEB-INF/lib/jaxb-impl-2.2.5.jar"  does not point to a valid jar for a Class-Path reference.
  09:43:18,326 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-12) Class Path entry jaxb1-impl.jar in "/C:/servers/jboss-as-7.0.2.Final/standalone/deployments/LendingSimulationServiceEAR.ear/LendingSimulationService.war/WEB-INF/lib/jaxb-impl-2.2.5.jar"  does not point to a valid jar for a Class-Path reference.
  </code></pre>
  
  <p>Which I found very strange.  I wasn't sure where it was finding that information.  A little more research found this line in the MANIFEST.MF:</p>
  
  <pre><code>Class-Path: jaxb-api.jar activation.jar jsr173_1.0_api.jar jaxb1-impl.jar
  </code></pre>
  
  <p>So now I'm even more confused than ever.  It would appear that the jaxb implementation depends on the api, activation, jsr and jaxb1 implementation jars.  But they aren't listed in the jaxb pom.  A little digging online found me <a href="http://jaxb.java.net/guide/Migrating_JAXB_2_0_applications_to_JavaSE_6.html" rel="noreferrer">this link</a> which discusses how to use JAXB 2.2 in a Java6SE environment.  Unfortunately, this has not seemed to work either; I still get the above WARN messages.</p>
  
  <p>I'm using the following snippet to list the JAXB implementation that is running; perhaps this is incorrect?</p>
  
  <pre><code>/**
   * Print the JAXB Implementation information
   */
  public static void outputJaxpImplementationInfo() {
      logger.debug(getImplementationInfo("DocumentBuilderFactory", DocumentBuilderFactory.newInstance().getClass()));
      logger.debug(getImplementationInfo("XPathFactory", XPathFactory.newInstance().getClass()));
      logger.debug(getImplementationInfo("TransformerFactory", TransformerFactory.newInstance().getClass()));
      logger.debug(getImplementationInfo("SAXParserFactory", SAXParserFactory.newInstance().getClass()));
  }
  
  /**
   * Get the JAXB implementation information for a particular class
   * @param componentName
   * @param componentClass
   * @return
   */
  private static String getImplementationInfo(String componentName, Class componentClass) {
      CodeSource source = componentClass.getProtectionDomain().getCodeSource();
      return MessageFormat.format(
              "{0} implementation: {1} loaded from: {2}",
              componentName,
              componentClass.getName(),
              source == null ? "Java Runtime" : source.getLocation());
  }
  </code></pre>
  
  <p>This snippet produces the following log:</p>
  
  <pre><code>10:28:27,402 INFO  [stdout] (MSC service thread 1-14) 2012-04-04 10:28:27,402 DEBUG cws.cs.lendingsimulationservice.util.JAXBUtil  - DocumentBuilderFactory implementation: __redirected.__DocumentBuilderFactory loaded from: file:/C:/servers/jboss-as-7.0.2.Final/jboss-modules.jar
  10:28:27,403 INFO  [stdout] (MSC service thread 1-14) 2012-04-04 10:28:27,403 DEBUG cws.cs.lendingsimulationservice.util.JAXBUtil  - XPathFactory implementation: __redirected.__XPathFactory loaded from: file:/C:/servers/jboss-as-7.0.2.Final/jboss-modules.jar
  10:28:27,404 INFO  [stdout] (MSC service thread 1-14) 2012-04-04 10:28:27,404 DEBUG cws.cs.lendingsimulationservice.util.JAXBUtil  - TransformerFactory implementation: __redirected.__TransformerFactory loaded from: file:/C:/servers/jboss-as-7.0.2.Final/jboss-modules.jar
  10:28:27,406 INFO  [stdout] (MSC service thread 1-14) 2012-04-04 10:28:27,406 DEBUG cws.cs.lendingsimulationservice.util.JAXBUtil  - SAXParserFactory implementation: __redirected.__SAXParserFactory loaded from: file:/C:/servers/jboss-as-7.0.2.Final/jboss-modules.jar
  </code></pre>