You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Byron Appelt <ba...@x.sensorlogic.com> on 2005/07/21 15:07:33 UTC

Classloader oddness

I am using JAMES 2.2.0 and have experienced problems I attribute to classloader oddness. Can anyone explain the Avalon classloader, or point me to some documentation about it? I have experienced the following and would like to understand why. Also, is there a plan to move JAMES off of Avalon in the near future? Other than these problems which I attribute to Avalon, I find JAMES to be an extremely useful product.

1. I use sun JMS from within my mailets, if I place the JMS jars in the SAR-INF/lib I get ClassNotFound problems. Things seem to work properly if I move them to the james-2.2.0/lib directory.

2. Previously, I was able to put the Oracle ojdbc14.jar in the SAR-INF/lib, but since we moved to a slightly newer version of that jar, I have to put it in the james-2.2.0/lib to get things to work. The stacktrace that I get in this case in extremely strange, it starts off with: 

     java.lang.RuntimeException: opt
          at oracle.i18n.util.ConverterArchive.readObj(ConverterArchive.java:319)

  Where "opt" is the first part of the path where JAMES is installed.

3. Until now I was only sending JMS messages from JAMES, I tried to receive them for the first time and I get a ClassNotFound Exception for a class that JAMES clearly can and does load. I have not yet figured out how to make this work.

Thanks,

Byron K. Appelt
Development
SensorLogic│M2M made easy.
byron@sensorlogic.com
www.SensorLogic.com


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Classloader oddness

Posted by ap...@bago.org.
> I am using JAMES 2.2.0 and have experienced problems I 
> attribute to classloader oddness. 

You can start looking to the mailet "Loader":
org.apache.james.transport.Loader

Your mailets are loaded from that loader.

And here is a suggestion:
-------------------
Many Java tools internally use Class.forName(String).newInstance()  to
instantiate some part of its internal functionality. This works if the
class's Jar is mounted at the top-level system classloader. In the case of
many Avalon containers, the Jar in question will actually be mounted in a
classloader at some other point in a tree of classloaders. Thus
Class.forName()  will fail with ClassNotFoundException if running in a
container.

A better thing to do would be to use
this.getClass().getClassLoader().loadClass(String). This means that the
class will always be loaded from classloader that hosts the rest of the
classes for the tool. It can run at any point in a tree of classloaders
without problem. 
-------------------

Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org