What would help us to resolve your problem is to post the details of your application structure.
Also if would help if you could set a ClassCastException breakpoint in your IDE, and report the two different class loaders that are causing the problem(i.e. the expected class loader and the actual class loader).