Yeah, I had a similar theory except that it shouldn't matter if a class is
loaded by two classloaders.. I think what matters is that the same
classloader can't cast an object that wasn't loaded by it's classloader
tree.  Since I was using a static initializer for loading the CRS, I think
that caused a problem like that between my different deployed services on
that webapp.  As soon as I made it a static method rather than loading the
code in a static block.. all my problems went away, even my hsql locking
problem disappeared.. so there must be something about how the plugin
scanner works in regards to efficiency that won't work in static blocks
because of how a classloader might use the objects.  Anyhow, this is all a
theory because its' tough to troubleshoot, luckily the errors went away so
I'm satisifed with that.

Thanks for the response!

Ryan

On Tue, Jan 13, 2009 at 4:33 AM, Martin Desruisseaux <
[email protected]> wrote:

> Ryan Moquin a écrit :
> > Hi, I have a bit of an issue that has popped up since I started running
> > my application in a tomcat environment.  I have been sporadically
> > getting ClassCastException errors with Geotools during the scanning of
> > plugins... I haven't changed any geotools dependencies or upgrading any
> > of our other dependencies, it seems like it's something triggered with
> > Tomcat.  I've seen this error on my laptop with a MathTransform geotools
> > class, then it mysterious went away.  I deployed the same deployment of
> > our application with tomcat onto another machine using the same Java
> > version, and the error resurfaced but with a different geotools class.
>
> I do not master Tomcat management of JAR dependencies, but it seems to me
> that
> if the same class is loaded twice by two different ClassLoaders in Tomcat,
> they
> are considered as two different classes. So casting a Foo to a Foo (yes,
> really
> the same fully qualified name) raise a ClassCastException if the two Foo
> happen
> to have been loaded by different ClassLoaders.
>
> I would suggest to make sure that no GeoTools JAR appears twice in the
> Tomcat
> classpath. Even if they are totally identical copy of the exact same JAR,
> this
> duplication doesn't hurt in normal Java environment but leads to problems
> with
> Tomcat, because its uses of different ClassLoaders.
>
>        Martin
>
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to