0 Replies Latest reply on May 15, 2014 12:06 PM by Vikram jeet

    ClassCastException for JAI jars in Jboss 6

    Vikram jeet Newbie



      I'm new to Jboss Server. We are migrating JBoss 4.2 to Jboss 6. Under this we have a TIFF image processing app. deployed as WAR to server.

      The respective jars(with correct versions) have been placed under modules folder library path with correct module xml(Sorry, cannot provide the xml here due to access issues ).

      We donot have the jars under WEB-INF/lib. Dependency also given to the respective jars in jboss-deployment-descriptor.xml under <dependecies> tag for that module.


      But while running the application, we get classcastException


      cannot cast from com.sun.media.imageio.plugins.tiff.TIFFImageWriteParam to com.sun.media.imageio.plugins.tiff.TIFFImageWriteParam


      on below Code.


      import javax.imageio.IIOImage;

      import javax.imageio.ImageWriteParam;

      import com.sun.media.imageio.plugins.tiff.TIFFImageWriteParam;


      ImageOutputStream ios = null;

        ImageWriter writer = null;


        try {

        // find an appropriate writer

        Iterator it = ImageIO.getImageWritersByFormatName("TIF");

        if (it.hasNext()) {

        writer = (ImageWriter)it.next();

        } else {

        return false;



        // setup writer

        ios = ImageIO.createImageOutputStream(tiffFile);


      TIFFImageWriteParam imageWriteParam = (TIFFImageWriteParam) writer.getDefaultWriteParam();.

      When trying to print the classloader for object and the ref. variable to which we are casting, I get the below.

      Object returned by writer.getDefaultWriteParam() is loaded by - sun.misc.launcher$ExtClassLoader



      TIFFImageWriteParam .classs,getClassLoader return ModuleClassLoader with path from the directory where we have put our JAI jars. 

      Unable to understand why TIFFImageWriteParam ref. is as Module loader and why the object is as ExtClassLoader.  If once the module loader has loaded then why ExtClassLoader is loading the same again.

      On top of this, we dont have any conflicting jars in the ext folder or the path refered for ext.


      Please help