B
Berlin Brown
I am working with servlet code on Websphere and when I take code off
the 'servletContext', I keep getting a ClassCastException. They should
be identical and even print outs show the same name.
But when I extract the object off the servletContext, I get a
classCastException. From reading online, I might have to change the
classloader policy within the server?
Error caused here:
IJythonUtilPlugin plugin = (JythonUtilPlugin)
context.getAttribute(JythonUtilPlugin.PLUGIN_NAME_KEY);
Here is the code I am trying to use to fix the issue.
log.info("=========================================");
Object obj = context.getAttribute(JythonUtilPlugin.PLUGIN_NAME_KEY);
log.info("Current Object Type=" + obj.getClass().getName());
log.info("Instance Of=" + (obj instanceof JythonUtilPlugin));
log.info("Class=" + (obj.getClass()));
String tmp1 = "ClassLoader=" + (obj.getClass().getClassLoader());
log.info(tmp1.substring(0, 20));
log.info("This=" + (this.getClass().getClassLoader()));
// More ClassLoader Checks (from IBM thinkworks)
java.lang.ClassLoader ctxCl =
Thread.currentThread().getContextClassLoader();
java.lang.ClassLoader tcCl = JythonUtilPlugin.class.getClassLoader();
java.lang.ClassLoader soCl = obj.getClass().getClassLoader();
tmp1 = "ctxCl=" + ((ctxCl == null) ? "null" : ctxCl.toString());
log.info(tmp1.substring(0, 40));
tmp1 = "targetCl=" + ((tcCl == null) ? "null" : tcCl.toString());
log.info(tmp1.substring(0, 40));
tmp1 = "sourceCl=" + ((soCl == null) ? "null" : soCl.toString());
log.info(tmp1.substring(0, 40));
log.info("=========================================");
// End of Classloader Check
the 'servletContext', I keep getting a ClassCastException. They should
be identical and even print outs show the same name.
But when I extract the object off the servletContext, I get a
classCastException. From reading online, I might have to change the
classloader policy within the server?
Error caused here:
IJythonUtilPlugin plugin = (JythonUtilPlugin)
context.getAttribute(JythonUtilPlugin.PLUGIN_NAME_KEY);
Here is the code I am trying to use to fix the issue.
log.info("=========================================");
Object obj = context.getAttribute(JythonUtilPlugin.PLUGIN_NAME_KEY);
log.info("Current Object Type=" + obj.getClass().getName());
log.info("Instance Of=" + (obj instanceof JythonUtilPlugin));
log.info("Class=" + (obj.getClass()));
String tmp1 = "ClassLoader=" + (obj.getClass().getClassLoader());
log.info(tmp1.substring(0, 20));
log.info("This=" + (this.getClass().getClassLoader()));
// More ClassLoader Checks (from IBM thinkworks)
java.lang.ClassLoader ctxCl =
Thread.currentThread().getContextClassLoader();
java.lang.ClassLoader tcCl = JythonUtilPlugin.class.getClassLoader();
java.lang.ClassLoader soCl = obj.getClass().getClassLoader();
tmp1 = "ctxCl=" + ((ctxCl == null) ? "null" : ctxCl.toString());
log.info(tmp1.substring(0, 40));
tmp1 = "targetCl=" + ((tcCl == null) ? "null" : tcCl.toString());
log.info(tmp1.substring(0, 40));
tmp1 = "sourceCl=" + ((soCl == null) ? "null" : soCl.toString());
log.info(tmp1.substring(0, 40));
log.info("=========================================");
// End of Classloader Check