This content has been marked as final. Show 3 replies
Probably a classloader issue. Right before you do the cast, print out the class of the object (or look at it in a debugger). If the classname is exactly what you expect--including package name and capitalization--then it's definitely a classloader issue.
I don't know about websphere's class loading, so you'll have to look at its docs or forum for details there. The short version is that if the same class is loaded by two different classloaders, then it's not the same class. You'll need to make sure that class is in ONE place where it can be picked up by all the classloaders that need it.
Piggybacking on what jverd said, you should look at the classloader and class name of both the source (what the object actually is) and target (the class you're trying to cast it to).
Object o = getServletContext().getContext(IExt.CTX_BOUTIQUE).getAttribute("detailCommande"); Class c = o.getClass(); // assuming o isn't null here System.out.println("Actual class: " + c + ", loaded from " + c.getClassLoader()); c = DetailCommandeInterface.class; System.out.println("Desired class: " + c + "; loaded from " + c.getClassLoader());
jverd , thanks that right ...
The classloader between my two war are in conflict ( the same interface ).
I've pushed my interface in a jar that loaded with the ear and delete it of my two war and now this work fine.