In trying to configure an SMTPAppender for use with log4j so that error 
reports on the server can be emailed out, I ran into difficulties getting 
JavaMail to work correctly.  I found many posts indicating that the problem 
is either:

   1. multiple copies of the JavaMail classes in the classpath
   2. issues with classloaders, related to the servlet container

To isolate the problem, I created a sample webapp using the GWT Eclipse 
plugin, and modified the auto-generated server-side greet method to log an 
error message, with an appropriately configured log4j.properties file.  The 
only two jar files in the WEB-INF/lib folder are the log4j-1.2.17.jar, 
mail.jar and gwt-servlet.jar files.  The AppEngine is not being used; I've 
seen the docs that mention that the AppEngine jar file contains 
implementations of the javax.mail classes, and that both the AppEngine jar 
and mail.jar should not be present in the classpath.
 
Using this configuration, when the log4j implementation tries to log an 
error message, the following debug info and stack trace is produced:

DEBUG: getProvider() returning 
javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun 
Microsystems, Inc]

java.lang.NoSuchMethodException: : 
com.sun.mail.smtp.SMTPTransport.<init>(javax.mail.Session, 
javax.mail.URLName)

along with an error message indicating that the SMTP provider can't be 
found:

javax.mail.NoSuchProviderException: smtp

However, I found that if I compile and deploy a much more complicated 
application with basically the same configuration to a Tomcat server, it 
works as expected.  This makes me suspect that the embedded server somehow 
contains mail.jar in its runtime classpath (I can't reference the classes 
in javax.mail in my project unless I include mail.jar in the classpath, so 
I'm positive they don't exist anywhere else in my project).  But, if I 
remove mail.jar from the WEB-INF lib directory and try to do a 
Class.forName on, say, javax.mail.Address, it can't be found.

Anyone have any ideas why this works when I deploy it, but not when running 
within Eclipse?

Thanks,
Ryan

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/tCjp7_JZ5WAJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to