java.lang.NoClassDefFoundError : com/sun/mail/util/MailLogger while trying to send e-mail from JAX-WS

标签 java eclipse web-services email

我正在 API 中发送 GET 请求(基于 JAX-WS,当前在 Eclipse 的 tomcat 服务器上运行),该请求应该使用 Gmail 发送电子邮件。 我遇到以下异常:

org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: com/sun/mail/util/MailLogger

我做了什么?

  1. 将 javax.mail 依赖项添加到 pom.xml

    <dependency>
        <groupId>com.sun.mail</groupId>
        <artifactId>javax.mail</artifactId>
        <version>1.6.0</version>
        <scope>test</scope>
    </dependency>
    
  2. 添加了 javax.mail-1.6.0.jar 到构建路径

  3. 将 javax.mail-1.6.0.jar 复制到 C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext

以上均未解决问题,
请指教, 谢谢!

最佳答案

根据mvnrepository.com你所需要的就是这个

<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.0</version>
</dependency>

添加到您的 pom.xml

此外,在对 pom.xml 进行更改后,右键单击您的项目并运行 Maven clean、maven install 和 maven update 项目。

关于java.lang.NoClassDefFoundError : com/sun/mail/util/MailLogger while trying to send e-mail from JAX-WS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46506858/

相关文章:

android - 生成apk文件时报错 "No DEX File Found"

eclipse - 如何在 Subclipse 中查找锁定的文件

java - 生成 SOAP Web 服务示例会引发错误

java - JPA 一对一关系未被识别

java - 在 Android 上从 Java 设置 splitActionBarWhenNarrow

eclipse - 警告 : System can't support ConditionalFeature. SCENE3D - VMWare,Ubuntu

web-services - 定期消费网络服务而不是频繁消费

java - 在服务器启动时加载 spring 配置

java - Vaadin ComboBox 文本颜色扩展

android - KSoap soapEnvelope bodyIn 和 getResponse() 问题