ClassCastException
Hi there
I have been trying to pass an object between 2 web applications on the same tomcat server. I set crossContext for both apps to "true" in their context xml files.
I have created an interface "AuthProcessManager" and packaged it into a JAR file which is on the class path of both apps ( in their WEB-INF/classes/lib folders). The object being passed implements this interface.
The class is received at web application 2 ok. And if it is cast to an object, there is no error. But when I try to cast it to the name of the interface it actually implements, I get ClassCastException.
Here is the code:
ServletContext scont =null;
ServletConfig sconf =null;
AuthProcessManager mgr=null;
sconf= servlet.getServletConfig();
scont = sconf.getServletContext().getContext("/" + contextName);
Object obj = scont.getAttribute(Constants.AUTH_PROCESS_MANAGER);
log.debug(Constants.AUTH_PROCESS_MANAGER +" from " + contextName +" => classname:" + obj.getClass().getName());
mgr = (AuthProcessManager)obj;
The error occurs on the final line. The actual error message is:
ERROR [http-80-Processor23] ActionExceptionHandler.logException(
145) | java.lang.ClassCastException: $Proxy21 cannot be cast to com.bitwalker.authdownloads.service.AuthProcessManager
I do not really understand why I get $Proxy21 as my class name. The actual class name is AuthProcessManagerImpl.
I have also tried putting the JAR file into tomcats common lib folder.But the result doesn't change. I have been battling this for days.
Can anyone help me?

