title: Include JAXB using Maven
body: <p>Working on my 1.6.0_16 JDK, I generated my stub classes from a WSDL using Apache CXF 2.5.2, which uses the most recent jaxb-api 2.2. I know it's possible to have it use jaxb-api 2.1, but in order to avoid compatibility issues, I would rather have it use the current version. Since my JDK features jaxb 2.1, the build fails with the following message:</p>
  
  <pre><code>error at @XmlElementRef(name = "protocol", namespace = "urn:ch.beo.emc", type = JAXBElement.class, required = false)
  </code></pre>
  
  <p>Therefore, I tried to make maven include the most recent jaxb api and impl using the following dependencies.</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;javax.xml.bind&lt;/groupId&gt;
      &lt;artifactId&gt;jaxb-api&lt;/artifactId&gt;
      &lt;version&gt;2.2.5&lt;/version&gt;
  &lt;/dependency&gt;
  &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.5&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>While the two jars have been added to Maven Dependencies in Eclipse, the error message persists both in Eclipse and Maven build.</p>
  
  <p>How can I include these jars in my Maven build and have them used both in Eclipse and on the target system?</p>
  
  <hr>
  
  <p>PS: Please Find the complete POM here:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;ch.beo&lt;/groupId&gt;
      &lt;artifactId&gt;emc.front&lt;/artifactId&gt;
      &lt;version&gt;3.1.3-SNAPSHOT&lt;/version&gt;
      &lt;repositories&gt;
          &lt;repository&gt;
              &lt;id&gt;jboss&lt;/id&gt;
              &lt;name&gt;JBoss&lt;/name&gt;
              &lt;url&gt;http://repository.jboss.org/maven2/&lt;/url&gt;
          &lt;/repository&gt;
          &lt;repository&gt;
              &lt;id&gt;freehep&lt;/id&gt;
              &lt;name&gt;Freehep&lt;/name&gt;
              &lt;url&gt;http://java.freehep.org/maven2&lt;/url&gt;
          &lt;/repository&gt;
          &lt;repository&gt;
              &lt;id&gt;JCurl&lt;/id&gt;
              &lt;url&gt;http://jcurl.berlios.de/m2/repo&lt;/url&gt;
          &lt;/repository&gt;
          &lt;repository&gt;
              &lt;id&gt;JavaNet&lt;/id&gt;
              &lt;url&gt;http://download.java.net/maven/2/&lt;/url&gt;
          &lt;/repository&gt;
          &lt;repository&gt;
              &lt;id&gt;djmaven2&lt;/id&gt;
              &lt;url&gt;http://www.fdvs.com.ar/djmaven2&lt;/url&gt;
              &lt;name&gt;DynamicJasper public Repository&lt;/name&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;/properties&gt;
      &lt;build&gt;
          &lt;defaultGoal&gt;compile&lt;/defaultGoal&gt;
          &lt;sourceDirectory&gt;src/main/java&lt;/sourceDirectory&gt;
          &lt;testSourceDirectory&gt;src/test/java&lt;/testSourceDirectory&gt;
          &lt;outputDirectory&gt;target/main&lt;/outputDirectory&gt;
          &lt;testOutputDirectory&gt;target/test&lt;/testOutputDirectory&gt;
          &lt;resources&gt;
              &lt;resource&gt;
                  &lt;targetPath&gt;ch/beo/emc/front/resources&lt;/targetPath&gt;
                  &lt;directory&gt;src/main/resources&lt;/directory&gt;
                  &lt;excludes&gt;
                      &lt;exclude&gt;src/main/resources/security/jarsign&lt;/exclude&gt;
                  &lt;/excludes&gt;
              &lt;/resource&gt;
          &lt;/resources&gt;
          &lt;testResources&gt;
              &lt;testResource&gt;
                  &lt;targetPath&gt;ch/beo/emc/front/resources&lt;/targetPath&gt;
                  &lt;directory&gt;src/test/resources&lt;/directory&gt;
              &lt;/testResource&gt;
              &lt;testResource&gt;
                  &lt;targetPath&gt;ch/beo/emc/front/resources&lt;/targetPath&gt;
                  &lt;directory&gt;src/main/resources&lt;/directory&gt;
                  &lt;excludes&gt;
                      &lt;exclude&gt;src/main/resources/security/jarsign&lt;/exclude&gt;
                  &lt;/excludes&gt;
              &lt;/testResource&gt;
          &lt;/testResources&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.6&lt;/source&gt;
                      &lt;target&gt;1.6&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;aspectj-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;complianceLevel&gt;1.6&lt;/complianceLevel&gt;
                      &lt;aspectLibraries&gt;
                          &lt;aspectLibrary&gt;
                              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                              &lt;artifactId&gt;spring-aspects&lt;/artifactId&gt;
                          &lt;/aspectLibrary&gt;
                      &lt;/aspectLibraries&gt;
                  &lt;/configuration&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;compile&lt;/goal&gt;
                              &lt;goal&gt;test-compile&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;archive&gt;
                          &lt;manifest&gt;
                              &lt;mainClass&gt;ch.beo.emc.front.factory.Front&lt;/mainClass&gt;
                              &lt;addClasspath&gt;true&lt;/addClasspath&gt;
                              &lt;classpathPrefix&gt;lib&lt;/classpathPrefix&gt;
                          &lt;/manifest&gt;
                      &lt;/archive&gt;
                      &lt;descriptors&gt;
                          &lt;descriptor&gt;assembly.xml&lt;/descriptor&gt;
                      &lt;/descriptors&gt;
                  &lt;/configuration&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;make-assembly&lt;/id&gt;
                          &lt;phase&gt;package&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;single&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;includes&gt;
                          &lt;include&gt;ch/beo/emc/front/AllTests.java&lt;/include&gt;
                      &lt;/includes&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.4&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;phase&gt;package&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;shade&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;createDependencyReducedPom&gt;false&lt;/createDependencyReducedPom&gt;
                              &lt;transformers&gt;
                                  &lt;transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"&gt;
                                      &lt;mainClass&gt;ch.beo.emc.front.factory.Front&lt;/mainClass&gt;
                                  &lt;/transformer&gt;
                                  &lt;transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"&gt;
                                      &lt;resource&gt;META-INF/spring.handlers&lt;/resource&gt;
                                  &lt;/transformer&gt;
                                  &lt;transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"&gt;
                                      &lt;resource&gt;META-INF/spring.schemas&lt;/resource&gt;
                                  &lt;/transformer&gt;
                              &lt;/transformers&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;sign&lt;/id&gt;
                          &lt;phase&gt;package&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;sign&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;keystore&gt;src/main/resources/security/jarsign/server.pfx&lt;/keystore&gt;
                              &lt;type&gt;pkcs12&lt;/type&gt;
                              &lt;alias&gt;beo-it.ch&lt;/alias&gt;
                              &lt;storepass&gt;****&lt;/storepass&gt;
                              &lt;signedjar&gt;${project.build.directory}/signed/${project.build.finalName}.jar&lt;/signedjar&gt;
                              &lt;verify&gt;true&lt;/verify&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.l2fprod&lt;/groupId&gt;
              &lt;artifactId&gt;l2fprod-common-all&lt;/artifactId&gt;
              &lt;version&gt;6.9.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.swixml&lt;/groupId&gt;
              &lt;artifactId&gt;swixml&lt;/artifactId&gt;
              &lt;version&gt;1.5.144&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;net.java.balloontip&lt;/groupId&gt;
              &lt;artifactId&gt;balloontip&lt;/artifactId&gt;
              &lt;version&gt;1.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.swinglabs&lt;/groupId&gt;
              &lt;artifactId&gt;swingx&lt;/artifactId&gt;
              &lt;version&gt;1.6&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
              &lt;version&gt;2.5.6.SEC01&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
              &lt;version&gt;2.5.6.SEC01&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
              &lt;version&gt;2.5.6.SEC01&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-aspects&lt;/artifactId&gt;
              &lt;version&gt;2.5.6.SEC01&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
              &lt;version&gt;2.5.6.SEC01&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
              &lt;version&gt;2.5.6.SEC01&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;artifactId&gt;junit&lt;/artifactId&gt;
                      &lt;groupId&gt;junit&lt;/groupId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;jfree&lt;/groupId&gt;
              &lt;artifactId&gt;jfreechart&lt;/artifactId&gt;
              &lt;version&gt;1.0.9&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.4&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.java.jnlp&lt;/groupId&gt;
              &lt;artifactId&gt;jnlp&lt;/artifactId&gt;
              &lt;version&gt;6.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.thoughtworks.xstream&lt;/groupId&gt;
              &lt;artifactId&gt;xstream&lt;/artifactId&gt;
              &lt;version&gt;1.3.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;commons-lang&lt;/groupId&gt;
              &lt;artifactId&gt;commons-lang&lt;/artifactId&gt;
              &lt;version&gt;2.5&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.jscience&lt;/groupId&gt;
              &lt;artifactId&gt;jsr-275&lt;/artifactId&gt;
              &lt;version&gt;0.8.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
              &lt;artifactId&gt;poi&lt;/artifactId&gt;
              &lt;version&gt;3.7&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;net.sf.jasperreports&lt;/groupId&gt;
              &lt;artifactId&gt;jasperreports&lt;/artifactId&gt;
              &lt;version&gt;3.7.4&lt;/version&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;commons-beanutils&lt;/groupId&gt;
                      &lt;artifactId&gt;commons-beanutils&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;commons-collections&lt;/groupId&gt;
                      &lt;artifactId&gt;commons-collections&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;commons-logging&lt;/groupId&gt;
                      &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;jfree&lt;/groupId&gt;
                      &lt;artifactId&gt;jcommon&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;jfree&lt;/groupId&gt;
                      &lt;artifactId&gt;jfreechart&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;xml-apis&lt;/groupId&gt;
                      &lt;artifactId&gt;xml-apis&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;bouncycastle&lt;/groupId&gt;
                      &lt;artifactId&gt;bcmail-jdk14&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;bouncycastle&lt;/groupId&gt;
                      &lt;artifactId&gt;bcprov-jdk14&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;bouncycastle&lt;/groupId&gt;
                      &lt;artifactId&gt;bctsp-jdk14&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;artifactId&gt;jdtcore&lt;/artifactId&gt;
                      &lt;groupId&gt;eclipse&lt;/groupId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.eclipse.jdt.core.compiler&lt;/groupId&gt;
              &lt;artifactId&gt;ecj&lt;/artifactId&gt;
              &lt;version&gt;3.5.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;ar.com.fdvs&lt;/groupId&gt;
              &lt;artifactId&gt;DynamicJasper&lt;/artifactId&gt;
              &lt;version&gt;3.1.2&lt;/version&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;jasperreports&lt;/groupId&gt;
                      &lt;artifactId&gt;jasperreports&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;commons-logging&lt;/groupId&gt;
                      &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.xml.bind&lt;/groupId&gt;
              &lt;artifactId&gt;jaxb-api&lt;/artifactId&gt;
              &lt;version&gt;2.2.5&lt;/version&gt;
          &lt;/dependency&gt;
          &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.5&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>