java.lang.NoClassDefFoundError com.sun.mail.util.MessageRemovedIOException
The javaee.jar contains the JavaMail API. The mail.jar and activation.jar are no longer needed to compile the project. BUT: The javaee.jar does not contain all the implementation classes needed to run the application!
javaee.jar也实现了发送邮件的接口(好像只实现了部分接口),tocmat加载的classes文件的时候先把javaee.jar中的classes文件加载到jvm中,由ClassLoader的加载机制(双亲委托)可以知道,mail.jar中相应的classes文件是不能被加载进来的。所以会出现问题。
第一种解决方式
在mail.jar和 javaee.jar中其实都没有MessageRemovedIOException这个类;直接把javaee.jar删掉即可,这种方式我试过管用。
第二种解决方式
把mail.jar 放到javaee.jar的前面就可以了,前提是tomcat在eclipse或者Myeclipse里面启动。
MyEclipse--》properties--》 Java Build Patch--》 Order and Export ;
选中mail.jar 点击up按钮即可
但是如果tomcat在外面启动(不再eclipse或者Myeclipse里面启动)还会有问题。因为在web-inf/lib目录下javaee.jar还是在mail.jar前面。想办法把mail.jar放到javaee.jar前面即可。比如重命名一下....