-
1. Re: ClassCastException when jar NOT in WEB-INF/lib but is in EAR/lib
jaikiran Jul 7, 2012 1:30 AM (in response to mikemil)Mike Miller wrote:
but when I hit the servlet, I got an ClassCastException.
The exception came because the jar that is needed by the war was NOT in the WEB-INF/lib folder, I had put it in the ear/lib and expected that to work. Adding the jar to the WEB-INF/lib folder resolved the issue but I don't quite understand why I had do to that?
That doesn't look like a reason for ClassCastException. Can you please post the entire exception stacktrace and also more details about the jar which you moved around? You can also post the output of:
jar -tf yourear.ear
and
jar -tf yourwar.war
-
2. Re: ClassCastException when jar NOT in WEB-INF/lib but is in EAR/lib
mikemil Jul 8, 2012 11:15 PM (in response to jaikiran)Not sure what happened but now I cannot recreate the scenario. I have tried going back to the ear/war combo and removing the jar that was causing the problem but no luck.
The initial problem was our startup servlet trying to initialize Hibernate 2. Hibernate was not given a caching provider and so was setting up the default, ehchache. We got NoClassDefFoundExceptions, followed by the ClassCastException. The error read something like "Cannot cast from net.sf.ehchache.hibernate.Provider to the net.sf.hibernate.cache.Cache" and it seemed like the problem was ehcache jar was in the ear/lib but not in the WEB-INF/lib folder. I put the ehcache jar in the WEB-INF/lib folder and the problem went away.
I already deleted all the logs, etc because this happened on Thursday and by Friday, I had moved on to trying our full ear, with 20 jars, and 8 wars as part of the migration research.