How Classloaders work?
My application has a web module and a RAR(connector module). There are some common classes in these two module. I have deployed web module as a war file. If I call a function of connector module from the servlet it givesClassCastException. Now if I wrap this war file in a ear file and then deploy, it works fine. WHY?
What I could understand is that when I deploy as a war, classes under WAR and RAR are loaded by separate classloader. but in case of EAR and RAR the classloader is same. Is it true? please clarify.
From developers guide.
The Shared Classloader is a single instance that loads classes (such as individually deployed connector modules) that are shared across all applications.
So you can call the functions of the connector midule from a web module, you will get <b>ClasscastExceptionn</b>. You are able to access the shared module from ear file, which is an application.
Thanks
-Parsu
Hi,
Following is the information I collected. Please try it and let us know.
"Please check to see if the shared classes are in both war module and under the $INSTANCE/lib directory.
To avoid this, either remove the shared classes from the war module or turn on the delegation flag to true in web class loader. Add "<class-loader delegate="true"/> in the sun-web.xml file."
Here is the doc for more information:
http://docs.sun.com/source/816-7149-10/dgdeploy.html#58624
Thanks,
Judy