I'm having a problem using the latest JavaMail (v 1.3) with Tomcat 4.1.12.
We had 
been using JavaMail 1.2 and everything worked fine.

I include the mail.jar v1.3 file in our <webapp>/WEB-INF/lib/ directory,
however, I
get an error calling a method specific to v1.3.  The code fails when I use
the new
constructor for InternetAddress: InternetAddress(String address, boolean
strict)

I know that JavaMail 1.2 is bundled with Tomcat and that seems to be the
conflict.  
I've checked the classloader howto and I think that the web-inf/lib/mail.jar
classes 
should be loaded for my webapp before the common/lib/mail.jar.  I've also
checked 
bugzilla and have seen similar sounding problems regarding xml related jars.


To troubleshoot the problem, I created a simple servlet within my webapp
which makes 
the straightfoward JavaMail calls to send a hardcoded message to a hardcoded
address.

This servlet fails with the errors:
Exception:
javax.servlet.ServletException: Servlet execution threw an exception
  at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:269)
  at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
  at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:260)
  ...
Root Cause:
java.lang.IllegalAccessError: try to access method
javax.mail.internet.InternetAddress.(Ljava/lang/String;Z)V from class
TestSMTP
  ...

My code works fine if I do any one of the following:
 - I remove mail.jar v1.2 and activation.jar from TOMCAT_HOME/common/lib 
 - I replace TOMCAT_HOME/common/lib/mail.jar with the 1.3 version
 - I put mail.jar v1.3 and activation.jar under JAVA_HOME/jre/lib/ext/ 

So is this a problem, or am I just not understanding how class loading
should work when using Tomcat?
I'd really like to be able to include whichever version of JavaMail I want
in my own lib directory and
not have to worry about the container's common jars.

Some more info: JDK 1.3.1_03, Tomcat 4.1.12, Win2K

Much thanks in advance for any help,
Mike

Reply via email to