创建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>
答案 0 :(得分:1)
删除<scope>provided</scope>
。