> -----Oorspronkelijk bericht----- > Van: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Namens Michiel Meeuwissen > Verzonden: dinsdag 3 februari 2004 10:18 > Aan: [EMAIL PROTECTED] > Onderwerp: Re: mail.jar > > Rob van Maris <[EMAIL PROTECTED]> wrote: > > Since MMBase containts a class that depends on it > > (org.mmbase.module.JMSendMail), it should ship with mail.jar. > > Application servers may ship with it as well, but they're > not required > > to. > > > > Regarding the common/endorsed directory: it is not intended > for this > > purpose. > > The correct location for thirdparty libraries is the webapp's > > WEB-INF/lib. Or alternatively Tomcat's shared/lib if you > want to make > > it available to all webapps. See: > > > http://jakarta.apache.org/tomcat/tomcat-5.0-doc/class-loader-howto.htm > > l > > > I don't believe anything before I see it. > > Placing them in WEB-INF/lib gives the following error in mmbase.log: > > 10:10:09,880 ERR 6082 kb org.mmbase.servlet.MMBaseServlet error.74 - > javax/mail/Sessionjava.lang.NoClassDefFoundError: javax/mail/Session > at > org.apache.naming.factory.MailSessionFactory$1.run(MailSession Factory.java:163) > at java.security.AccessController.doPrivileged(Native Method) > at > org.apache.naming.factory.MailSessionFactory.getObjectInstance > (MailSessionFactory.java:147) > at > org.apache.naming.factory.ResourceFactory.getObjectInstance(Re > sourceFactory.java:176) > at > javax.naming.spi.NamingManager.getObjectInstance(NamingManager > .java:301) > at > org.apache.naming.NamingContext.lookup(NamingContext.java:837) > at > org.apache.naming.NamingContext.lookup(NamingContext.java:184) > at > org.apache.naming.NamingContext.lookup(NamingContext.java:825) > at > org.apache.naming.NamingContext.lookup(NamingContext.java:197) > at org.mmbase.module.JMSendMail.init(JMSendMail.java:53) > at org.mmbase.module.Module.startModule(Module.java:83) > at org.mmbase.module.Module.startModules(Module.java:282) > at org.mmbase.module.Module.getModule(Module.java:326) > at org.mmbase.module.core.MMBase.getMMBase(MMBase.java:428) > at > org.mmbase.servlet.MMBaseServlet.init(MMBaseServlet.java:168) > at javax.servlet.GenericServlet.init(GenericServlet.java:256) > at > org.apache.catalina.core.StandardWrapper.loadServlet(StandardW > rapper.java:1044) > > > > Placing them in shared/lib is even worse: > > 10:11:23,053 ERR 4743 kb org.mmbase.servlet.MMBaseServlet error.74 - > javax/mail/MessagingExceptionjava.lang.NoClassDefFoundError: > javax/mail/MessagingException > at java.lang.Class.forName0(Native Method) > at java.lang.Class.forName(Class.java:141) > at > org.mmbase.module.Module.loadModulesFromDisk(Module.java:390) > at org.mmbase.module.Module.getModule(Module.java:322) > at org.mmbase.module.core.MMBase.getMMBase(MMBase.java:428) > at > org.mmbase.servlet.MMBaseServlet.init(MMBaseServlet.java:168) > at javax.servlet.GenericServlet.init(GenericServlet.java:256) > > > Only placing in common/endorsed works flawlessly. > > > So well, I think this is a bit of a problem, because it is > impossible to ship something which works out of the box.
If you would ask me, the mail.jar belongs in the common/lib directory of tomcat. Why? The mail/Session resource is configured in the server.xml and binds to the JNDI tree of tomcat. All resources defined in the server.xml are loaded by a class that is loaded by the catalina classloader (see url Rob posted for classloader hierarchy). IOW, the classloader for the resource classes has to be the common classloader so it is visible for the catalina (server) and webapp (MMBase) classloader. The common classloader can only load classes from the common/classes and common/lib dir or the classes accessible by his parent classloaders (system, bootstrap and endorsed). The endorsed dir is not the right place, because according to http://java.sun.com/j2se/1.4.2/docs/guide/standards/index.html it is not an endorsed standard api. Nico Klasens Finalist IT Group Java Specialists
