Olaf Bergner wrote:

-----Original Message-----
From: Niclas Hedhman [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 31, 2003 2:39 AM

I "wild" guess;
The (Kernel) cast would then implicitly load the merlin-api jar, which
probably then conflicts with the merlin-api being loaded by the
avalon-repository system.


Probably something along those lines. Doubt that I will ever find out. I tried to follow your advice and traced all classloading events during the testcase. To that end I wrote a custom classloader which simply spat out which class was currently being loaded and if the effective class loader was the parent classloader or this classloader. This gave me a whole lot of info, albeit nothing useful. At least not for me. My faithful classloader was tracing and tracing and then, right out of the middle of nowhere there was this good ol' LinkageError again.

But then again, I had a look at the source for java.lang.ClassLoader and
java.net.URLClassLoader. At least I learned a bit from this one.


Olaf:


Including container implementation jars in a project.xml will cause problems due to classloader logic in the JRE. The problem is that if an implementation class is included in the project.xml, then it going into a classloader constructed by maven. When you kernel or something like the AMTC kicks in the avalon-repository package is constructing a child classloader with the complete set of implementation resources - however, if an implementation class in merlin invokes an operation on another class, and if the other class is in the maven classloader, and the other class invokes an operation on a third class (which would normally be in the merlin classloader), it will not be found. This is because class lookup is always up relative to the classloader associated with the class making the invocation.

The solution (that will let you get back to normal code and avoid reflection) is to declare a factory. So instead of using the repository package to load merlin you should use the repository package to load your own factory. The repository package will then create the classloader you need with everything in it and your dependencies in project.xml can be reduced down to nothing more than avalon-repository-main.

End result - classloader conflicts disappear.

Cheers, Stephen.

--
|------------------------------------------------|
| Magic by Merlin                                |
| Production by Avalon                           |
|                                                |
| http://avalon.apache.org/merlin                |
| http://dpml.net/                               |
|------------------------------------------------|


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to