Wildfly 10.1.0 ClassNotFoundException:javax.mail.Authenticator
Wildfly 10.1.0 ClassNotFoundException: javax.mail.Authenticator
创建 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 存在且 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>
删除 <scope>provided</scope>
.
创建 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 存在且 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>
删除 <scope>provided</scope>
.