org.apache.commons.mail.MultiPartEmail的創建實例的以下問題occures:Wildfly 10.1.0的ClassNotFoundException:javax.mail.Authenticator
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>
哪個版本的Wildfly?也許這有幫助? http://stackoverflow.com/questions/31650024/wildfly-9-javax-mail-is-not-working – ozOli
你不應該在jboss-deployment-structure.xml中包含所有這些路徑。此外,'javax.activation.api'模塊應該已經作爲依賴於您的部署的'javaee.api'模塊。你在'jboss-deployment-structure.xml'中有模塊排除嗎? –
@jamesr使用Wildfly 10.1.0。 jboss-deployment-structure.xml中沒有模塊排除。感謝讀完它後的答案,我再次研究了[部署的隱式模塊依賴關係](https://docs.jboss.org/author/display/WFLY10/Implicit+module+dependencies+for+deployments)和modules \ system \ layers \ base \ javax \ api \ main \ module.xml,並理解爲什麼不需要在jboss-deployment-structure.xml中包含那些javax/*路徑。 –