title: ClassNotFoundException com.sun.mail.util.SharedByteArrayInputStream
body: <p>I am getting the following error when my deployed system sends an email.</p>
  
  <pre><code>Caused by: java.lang.NoClassDefFoundError: com/sun/mail/util/SharedByteArrayInputStream
  ....
  ....
  Caused by: java.lang.ClassNotFoundException: com.sun.mail.util.SharedByteArrayInputStream
      at org.apache.catalina.loader.WebappClassLoaderBase.loadClass
  </code></pre>
  
  <p>I am using:</p>
  
  <pre><code>&lt;dependency&gt;
     &lt;groupId&gt;com.sun.mail&lt;/groupId&gt;
     &lt;artifactId&gt;javax.mail&lt;/artifactId&gt;
     &lt;version&gt;1.5.1&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>This has been working for the past year and now suddenly it is throwing this exception. I have changed any of the versions of <code>javax.mail</code> etc. </p>
  
  <p>I tried adding <code>javax.mail:mail:jar:1.5.0</code> to the dependencies but when compiling I got an error saying that that jar was illegal. Maven gives the following error: <code>Please use the correct artifact for JavaMail. You should be using com.sun.mail:javax.mail...</code> &amp; <code>Found Banned Dependency: javax.mail:mail:jar:1.5.0</code></p>
  
  <p>What seems odd to me is that <code>javax.mail.internet.MimeMessage</code> has the following imports:</p>
  
  <pre><code>import com.sun.mail.util.*;
  import javax.mail.util.SharedByteArrayInputStream;
  </code></pre>
  
  <p>So it seems odd that I get this error when creating a <code>MimeMessage</code> in that it is trying to get <code>com.sun.mail.util.SharedByteArrayInputStream</code> instead of <code>javax.mail.util.SharedByteArrayInputStream</code>.</p>
  
  <p>I know similar questions have been posted but the answers always seem to be to use <code>javax.mail.jar</code> which I am already using.</p>