Wildfly 10.1.0 ClassNotFoundException:javax.mail.Authenticator

时间:2016-09-13 20:13:10

标签: maven jboss javamail wildfly-10 classnotfound

创建org.apache.commons.mail.MultiPartEmail实例时会出现以下问题:

java.lang.NoClassDefFoundError: javax/mail/Authenticator
    at mypackage.MyClass.sendMail(MyClass.java:123)
...
Caused by: java.lang.ClassNotFoundException: javax.mail.Authenticator from [Module "org.apache.commons:main" from local module loader @5a4041cc (finder: local module finder @15b3e5b (roots: C:\wildfly-10.1.0.Final\modules,C:\wildfly-10.1.0.Final\modules\system\layers\base))]

pom.xml包含:

<dependency>
  <groupId>org.apache.commons</groupId>
  <artifactId>commons-email</artifactId>
  <version>1.3.3</version>
  <scope>provided</scope>
</dependency>

wildfly-10.1.0.Final \ modules \ org \ apache \ commons \ main \ commons-email-1.3.3.jar \ org \ apache \ commons \ mail \ MultiPartEmail.class exists and jboss-deployment-structure。 xml包含:

<module name="org.apache.commons" />
<system export="true">
  <paths>
    <path name="javax/api"/>
    <path name="javax/activation/api"/>
    <path name="javax/mail/api"/>
  </paths>
</system>

1 个答案:

答案 0 :(得分:1)

删除<scope>provided</scope>