Do you pack the interface classes into both archives, that will force such ClassCastExecptions for the same class, as it is loaded by different classloaders.
You can drop the interface classes from your archive and provide it as a module.
Or you might use call-by-value instead of call-by-reference (in that case you use it global and you can not use local interfaces).