---
title: "在Spring中使用javaMail的项目发布问题解决"
author: "andy136566"
date: "2011-02-15T14:00:27Z"
tags: []
categories: ["企业架构"]
slug: "spring-javamail"
draft: false
lastmod: "2011-02-15T14:00:50Z"
id: 906783
url: "https://andy136566.iteye.com/blog/906783"
---

org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'javaMailSender' defined in ServletContext resource \[/WEB-INF/applicationContext.xml]: Class that bean class \[org.springframework.mail.javamail.JavaMailSenderImpl] depends on not found; nested exception is java.lang.NoClassDefFoundError: javax/mail/MessagingException  
java.lang.NoClassDefFoundError: javax/mail/MessagingException

搞了很久都不明白是什么回事,因为在测试时都没有问题,而且提示中的包在项目里都有.最后通过网上搜索把问题解决了，

原来在使用Spring这样的框架的一些丰富功能时，都要在完整的J2EE容器下运行，因为Spring只不过提供J2EE容器功能的又一种调用方式罢了，所以把j2ee中的activation.jar,和mail.jar包复制到Tomcat中的common/lib目录下就发布成功了．

 

转：[http://carter.zhmy.com/archives/2007/113041.html](http://carter.zhmy.com/archives/2007/113041.html)