<snip />
> >for magnus: it still behaves like that in 0.9.1g (you said that you'd
> >fixed several classloader bugs. if this is one, it's still there)
> >
<snip />
No, this is not a bug, this is how classloader delegation works in a JVM.
I'll try expanding some on what Luke said:
A class is *not* (common mistake) defined by name, but by name + loader.
Lack of this knowledge is what leads to a lot of ClassCastException
questions
in various forums. The serializer does not have a problem finding the class,
it simply does object.getClass(), the deserializer however needs to know
exactly
which loader to load from (since it gets the name from the stream but is
still missing
the loader info).
Classes can see classes that are
a) loaded by the same loader
b) loaded by a loader below the current one (parent, more core).
The ClassLoader in Orion looks something like this (somewhat simplified,
bottom beeing more core):
JSP page loader (myjsp.jsp)
TagLib loader (mytags.jar)
Servlet/Beans loader (orion-web.xml <classpath .../> and WEB-INF/classes)
Local Application EJB loader (<ejb-module .. /> in
META-INF/orion-application.xml)
Parent Application EJB loader (if any)
Global application EJB loader (config/application.xml, <ejb-module>)
Library loader (<library .. />)
----- JVM layers ----
Application loader (classpath or manifest if using -jar, in orion:
orion.jar, ejb.jar, mail.jar, jndi.jar etc)
Ext loader (jre/lib/ext)
Core loader (rt.jar)
Note that the above list is simplified but it demonstrates the general
principle. In reality it is a tree - not a list, and each
loader is a node. My recommendation is to put TunnelServlet at the
Servlet/Beans level (usually where it belongs) and
to put the beans either in the same loader or a parent (lower) loader than
the servlet. If you dont want to do this
then supply (thru some means) the TunnelServlet with the loader it's
supposed to use and override ObjectInputStream's
resolveClass() method to find it (somewhat more complicated).
I hope that helps, I'd recommend some further reading on the subject but I
can't think of any useful URLs/books right now
unfortunately. One thing to remember btw is that classes are loaded by the
most root loader it exists in (hence putting a
servlet in the core classpath stops auto-reloading from working etc).
/Magnus Stenman, the Orion team
PS. The 0.9.1 bug was that the servlet loader did not get access to the
library loader if no EJBs where deployed in the application.