users@glassfish.java.net

Re: GF 3.1.1 Classloading issue ... how to tackle it?

From: <forums_at_java.net>
Date: Wed, 30 Nov 2011 19:33:56 -0600 (CST)

The child-first class loading behavior from the servlet spec
('delegate=false' here) can be problematic for WARs that bundle jar files
that duplicate classes higher up in the class loader heirarchy. If
org.Foo.class is defined in the common loader, for example, and that same
class is defined in the web loader, the two Class instances are distinct
types: you can't cast an object created from one to the other type, even
though the types have the exact same name. This is the infamous
ClassCastException problem, but there are other more insidious variations
that result in LinkageErrors; both kinds of errors are extremely frustrating
and hard to diagnose. Most servers have switched this behavior off by default
because these problems do occur, though clearly not with every web app.

This feature is really only needed when you explicitly DO want to duplicate
classes or resources (the latter in your case). Duplicating resources is
certainly safer than duplicating classes. Even duplicating classes is often
safe, but this is hard to predict because it really depends on exactly if or
how the duplicate classes interact; generally, if they never come in contact
there will be no error.


--
[Message sent by forum member 'batsatt']
View Post: http://forums.java.net/node/867610