-
Apr 14th, 2010, 12:11 PM
#1
endorsed jars for SMTP
We are deploying an application that sends email using javax.mail.
We bundle in java-mail-1.4.jar in our war file. I have also found that CF provides the gnu implementation of SMTP.
Sending emails failed. catalina.out showed an exception something like NoProviderException for SMTP.
We changed our configuration to upload the java-mail jar as an endorsed jar. CF puts it in common/endorsed. When we run under that configuration, sending emails also fails because it load s the GNU email jar whichh for some reason is not compatible with the way that we are using javax.mail.
Two questions:
1. Why can Tomcat not find an SMTP implementation in the first case, when the GNU implementation is pre-loaded in Tomcat and the java-mail implementation is in the war?
2. Why does Tomcat load the GNU implementation when the sun implementation is present in endorsed?
-Robert
-
Apr 14th, 2010, 12:19 PM
#2
This sounds like a mail.jar version problem that a few Cloud Foundry users have encountered.
The solution has been to run this command:
rm /var/lib/tomcat5/common/lib/[javamail].jar
You can do this in an app container pre-startup script.
-
Apr 17th, 2010, 12:04 PM
#3
We added a script to remove the [javamail].jar file.
The first time I tested this it worked ok.
The second time I tested it, email was not working and I found a message in the log file that it was using the gnu.smtp provider. I verified that the script had run and the [javamail] file had been removed.
Tomcat apparently had loaded a jar file that was not present on the file system. I thought that perhaps the server had started before the script ran? Or before the script completed?
I tested my hypothesis by killing the server, waiting for CF to restart it, and running the page that sends email. This time it loaded the correct smtp jar file and email was delivered.
I am proposing the hypothesis that there is some indeterminacy between when the container initialization script runs and when the Tomcat server is started. In the first case, the script won. In the second case, Tomcat won and loaded the [javamail] file which was eventually removed after Tomcat started it, but the class loader had already loaded it.
Could this be the case?
-Robert
-
Oct 14th, 2010, 03:11 PM
#4
This script fixed this problem for me
#!/bin/sh
#remove the default GNU JavaMail JAR because it does not support SMTP
#
if [ -f "/var/lib/tomcat5/common/lib/[javamail].jar" ]
then
rm /var/lib/tomcat5/common/lib/[javamail].jar
echo "file removed"
else
echo "no file to remove"
fi
notes:
1) you need to return success from this script or the deployment / redeployment will fail.
2) This is only necessary on the tomcat 5.5 application tier instances as the tcServer ones have a different set of JARS (not sure about other variants as I've only tried these two)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules