title: Powermock imageio UnsatisfiedLinkError
body: <p>After adding powermock (1.5.6 in combination with Easymock 3.2) to my current project (jdk 1.6.0) I get some test failures in test methods which worked perfectly fine before:</p>
  
  <blockquote>
    <p>java.lang.UnsatisfiedLinkError:
    com.sun.imageio.plugins.jpeg.JPEGImageReader.initReaderIDs(Ljava/lang/Class;Ljava/lang/Class;Ljava/lang/Class;)V</p>
  </blockquote>
  
  <p>The following code fails:</p>
  
  <pre><code>BufferedImage img = null;
  try {
      img = ImageIO.read(this.getClass().getResourceAsStream("/example.jpg"));
  }
  catch (IOException e) {
      fail(e.getMessage());
  }
  </code></pre>
  
  <p>The powermock page already has a <a href="https://code.google.com/p/powermock/issues/detail?id=141" rel="nofollow">bug</a> from 2009 but no fix and no workaround. (Going back to 32Bit is nonsense since those methods work without powermock) So does anybody know how to fix this?</p>
  
  <p><strong>Update I:</strong> A switch to 32 Bit is no option and besides that this is not the problem. If I don't use PowerMock every test is working perfectly in my 64Bit JVM...</p>
  
  <p><strong>Update II:</strong> Ok here are the requested infos</p>
  
  <p><strong>Update III:</strong> Extended the class</p>
  
  <ol>
  <li><p>Class to be tested</p>
  
  <pre><code>import java.awt.image.BufferedImage;
  import java.io.ByteArrayOutputStream;
  import java.io.IOException;
  import java.security.GeneralSecurityException;
  import java.security.cert.X509Certificate;
  import javax.imageio.ImageIO;
  import sun.security.x509.CertificateIssuerName;
  import sun.security.x509.CertificateSubjectName;
  import sun.security.x509.X500Name;
  import sun.security.x509.X509CertImpl;
  import sun.security.x509.X509CertInfo;
  
  public class App {
      private X509Certificate certificate = null;
  
      public ByteArrayOutputStream readImage() {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      BufferedImage img = null;
  try {
      img = ImageIO.read(this.getClass().getResourceAsStream("/example.jpg"));
      ImageIO.write(img, "png", baos);
  }
  catch (IOException e) {
      e.printStackTrace();
  }
  
  return baos;
  }
  
  public String readCertificate() throws Exception{
   this.certificate = generateCertificate();
   return this.certificate.getIssuerX500Principal().getName();
  }
  
  private static X509Certificate generateCertificate() throws   GeneralSecurityException, IOException{
        X509CertInfo info = new X509CertInfo();
        X500Name owner = new X500Name("CN=example.net");
        info.set(X509CertInfo.SUBJECT, new CertificateSubjectName(owner));
        info.set(X509CertInfo.ISSUER, new CertificateIssuerName(owner));
        return new X509CertImpl(info);
   }   
  }
  </code></pre></li>
  <li><p>Test case:</p>
  
  <pre><code>import org.junit.Assert;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.powermock.core.classloader.annotations.PowerMockIgnore;
  import org.powermock.core.classloader.annotations.PrepareForTest;
  import org.powermock.modules.junit4.PowerMockRunner;
  @RunWith(PowerMockRunner.class)
  @PrepareForTest(App.class)
  @PowerMockIgnore("javax.imageio.*, javax.security.*") 
  public class AppTest {
  
   @Test
   public void testApp(){
       App test = new App();
       Assert.assertNotNull(test.readImage());
       Assert.assertEquals(284506, test.readImage().size());
   }
   @Test
   public void testCertificate() throws Exception{
     App test = new App();
     test.readCertificate();
   }
  }
  </code></pre></li>
  <li><p>Maven dependencies:</p>
  
  <pre><code>&lt;dependencies&gt;
      &lt;!-- TEST --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;4.11&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.easymock&lt;/groupId&gt;
          &lt;artifactId&gt;easymock&lt;/artifactId&gt;
          &lt;version&gt;3.2&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.powermock&lt;/groupId&gt;
          &lt;artifactId&gt;powermock-module-junit4&lt;/artifactId&gt;
          &lt;version&gt;1.5.6&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.powermock&lt;/groupId&gt;
          &lt;artifactId&gt;powermock-api-easymock&lt;/artifactId&gt;
          &lt;version&gt;1.5.6&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p></p></li>
  </ol>
  
  <p>So if you comment the line:
  <code>//@RunWith(PowerMockRunner.class)</code>
  it is working. If uncommented it the above error is thrown (again!)</p>