Skip to main content


Showing posts from 2009

JAI imageio casting problem

I recently had problems using Java Advanced Imaging (JAI).
Here is the simplified version of the problem, so we have:
SomeClass c = (SomeClass) obj.getSomeClassParent() it happens sometimes to trigger exception
org.somepackage.SomeClass can't be cast to org.somepackage.SomeClass
Original code:
ImageInputStream iis = ImageIO.createImageInputStream(src); Iterator iter = ImageIO.getImageReadersByFormatName("DICOM"); ImageReader reader =; DicomImageReadParam param = (DicomImageReadParam) reader.getDefaultReadParam();

And the original exception

The problem was that I was missing that sometime the class is loaded by different class loader and it can happen that the casted class is not the same whit the one form the default class loader. Now this would have been obvious if it was in two different vm's , or maybe some object received via de/serialization ...

The question on StackOverflow


Now here comes our offer to pull you into the robotics world: Let us show you how to build your own robots through lectures, practical work and a competition at the end of many awards.
But we are limited to 30 people! What are you waiting for? Just apply via our website!!! There you can find all the information needed. And for those, who are already experienced in this field and want to apply for the competition only take your own robot with you and join us in RoboMAC! We promise you lots of fun and awards. Are you interested? Go on reading…
From 22nd February - 1st March 2009, RoboMAC will take place at the Faculty of Electrical Engineering and Information Technologies in Skopje, Macedonia.
IEEE Student Branch Macedonia and BEST-Skopje want to give 30 engineering students the chance to apply for our 5 days training with professors from our University (23-27 February) and the competition (28 February). For those lucky students, we will provide accommodation, food, local t…