title: Java casting / classloader issues
body: <p>Here is the simplified version of the problem:</p>
  
  <pre><code> SomeClass c = (SomeClass) obj.getSomeClassParent()
  </code></pre>
  
  <p>not always but it happens sometimes to trigger exception </p>
  
  <pre><code> org.somepackage.SomeClass can't be cast to org.somepackage.SomeClass 
  </code></pre>
  
  <p>How  is this possible ?  I suppose it has something to do with the fact that JAI imageio is   native lib, but relay how can this happen ? I'm probably missing something but what ? </p>
  
  <pre><code>I'm using JAI imageio version 1.1 
  dcm4che 2.0.21  DICOM lib
  </code></pre>
  
  <p>Here is the original code</p>
  
  <pre><code>  ImageInputStream iis = ImageIO.createImageInputStream(src);
    Iterator&lt;ImageReader&gt; iter = ImageIO.getImageReadersByFormatName("DICOM");
    ImageReader reader = iter.next();
    DicomImageReadParam param = (DicomImageReadParam) reader.getDefaultReadParam();
  </code></pre>
  
  <p>And the original exception</p>
  
  <pre><code>org.dcm4che2.imageio.plugins.dcm.DicomImageReadParam can't be cast to    
  org.dcm4che2.imageio.plugins.dcm.DicomImageReadParam
  </code></pre>
  
  <p><a href="http://img215.imageshack.us/img215/3894/exception.jpg" rel="nofollow noreferrer">Exception Image http://img215.imageshack.us/img215/3894/exception.jpg</a></p>