title: Maven JarClassLoader: Warning:Foo.class in X.jar is hidden byY.jar (with different bytecode)
body: <p>As soon as I added java.mail support to my project:</p>
  
  <pre><code>     &lt;dependency&gt;
          &lt;groupId&gt;javax.mail&lt;/groupId&gt;
          &lt;artifactId&gt;mail&lt;/artifactId&gt;
          &lt;version&gt;1.4.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.activation&lt;/groupId&gt;
          &lt;artifactId&gt;activation&lt;/artifactId&gt;
          &lt;version&gt;1.1.1&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>I started receiving a flood of warning messages like these (when I run the built jar):</p>
  
  <pre><code>JarClassLoader: Warning: javax/mail/Address.class in lib/mail-1.4.1.jar is hidden by lib/geronimo-javamail_1.4_spec-1.7.1.jar (with different bytecode)
  JarClassLoader: Warning: javax/mail/AuthenticationFailedException.class in lib/mail-1.4.1.jar is hidden by lib/geronimo-javamail_1.4_spec-1.7.1.jar (with differ
  ent bytecode)
  JarClassLoader: Warning: javax/mail/Authenticator.class in lib/mail-1.4.1.jar is hidden by lib/geronimo-javamail_1.4_spec-1.7.1.jar (with different bytecode)
  JarClassLoader: Warning: javax/mail/BodyPart.class in lib/mail-1.4.1.jar is hidden by lib/geronimo-javamail_1.4_spec-1.7.1.jar (with different bytecode)
  JarClassLoader: Warning: javax/mail/EventQueue.class in lib/mail-1.4.1.jar is hidden by lib/geronimo-javamail_1.4_spec-1.7.1.jar (with different bytecode)
  JarClassLoader: Warning: javax/mail/FetchProfile$Item.class in lib/mail-1.4.1.jar is hidden by lib/geronimo-javamail_1.4_spec-1.7.1.jar (with different bytecode
  )
  </code></pre>
  
  <p>My program runs fine (and sends email fine), but I don't want all these hundreds of JarClassLoader warnings...</p>
  
  <p>Any idea how to restore peace &amp; quiet to my console log?</p>
  
  <hr>
  
  <p>Update: Thanks to the tip by Jigar Joshi below, I found that the undesired geronimo-javamail_1.4_spec-1.7.1.jar comes from <em>org.apache.cxf:cxf-api:jar:2.7.1:compile</em>, so I added an exclusion:</p>
  
  <pre><code>   &lt;dependency&gt; 
          &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
          &lt;artifactId&gt;cxf-api&lt;/artifactId&gt;
          &lt;version&gt;2.7.1&lt;/version&gt;
          &lt;exclusions&gt;
            &lt;exclusion&gt;  
             &lt;groupId&gt;org.apache.geronimo.specs&lt;/groupId&gt;
             &lt;artifactId&gt;geronimo-javamail_1.4_spec&lt;/artifactId&gt;
           &lt;/exclusion&gt;
         &lt;/exclusions&gt; 
      &lt;/dependency&gt;
  </code></pre>
  
  <p>And the <code>mvn dependency:tree</code> command no longer shows "geronimo" as a dependency, but I am still getting all these warnings when I run the newly resulting jar (built from clean!)</p>
  
  <p>Additional suggestions? </p>
  
  <hr>
  
  <p>Update 2: This is the dependencies section in my <strong>pom.xml</strong>:</p>
  
  <pre><code>&lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;junit&lt;/groupId&gt;
      &lt;artifactId&gt;junit&lt;/artifactId&gt;
      &lt;version&gt;3.8.1&lt;/version&gt;
      &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
  
  
    &lt;dependency&gt;
      &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
      &lt;artifactId&gt;cxf-rt-frontend-jaxws&lt;/artifactId&gt;
      &lt;version&gt;2.7.1&lt;/version&gt;
      &lt;type&gt;jar&lt;/type&gt;
      &lt;scope&gt;runtime&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
      &lt;artifactId&gt;cxf-rt-transports-http&lt;/artifactId&gt;
      &lt;version&gt;2.7.1&lt;/version&gt;
      &lt;type&gt;jar&lt;/type&gt;
      &lt;scope&gt;runtime&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
      &lt;version&gt;3.0.7.RELEASE&lt;/version&gt;
    &lt;/dependency&gt;
  
  
    &lt;dependency&gt;
      &lt;groupId&gt;mysql&lt;/groupId&gt;
      &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
      &lt;version&gt;5.1.26&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
      &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
      &lt;version&gt;4.2.6.Final&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt; 
      &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
      &lt;artifactId&gt;cxf-api&lt;/artifactId&gt;
      &lt;version&gt;2.7.1&lt;/version&gt;
      &lt;exclusions&gt;
        &lt;exclusion&gt;
      &lt;groupId&gt;org.apache.geronimo.specs&lt;/groupId&gt;
      &lt;artifactId&gt;geronimo-javamail_1.4_spec&lt;/artifactId&gt;
        &lt;/exclusion&gt;
      &lt;/exclusions&gt; 
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
      &lt;artifactId&gt;cxf-rt-transports-http&lt;/artifactId&gt;
      &lt;version&gt;2.7.1&lt;/version&gt;
      &lt;type&gt;jar&lt;/type&gt;
    &lt;/dependency&gt;
  
    &lt;dependency&gt;
      &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
      &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
      &lt;version&gt;2.5&lt;/version&gt;
    &lt;/dependency&gt;
  
    &lt;dependency&gt; 
      &lt;groupId&gt;javax.mail&lt;/groupId&gt;
      &lt;artifactId&gt;mail&lt;/artifactId&gt;
      &lt;version&gt;1.4.1&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;javax.activation&lt;/groupId&gt;
      &lt;artifactId&gt;activation&lt;/artifactId&gt;
      &lt;version&gt;1.1.1&lt;/version&gt;
    &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  </code></pre>