bbottema / simple-java-mail

Simple API, Complex Emails (Jakarta Mail smtp wrapper)
http://www.simplejavamail.org
Apache License 2.0
1.23k stars 270 forks source link

Bug: package org.simplejavamail.internal.modules causes split package problem in Java9+ #378

Closed quimodotcom closed 2 years ago

quimodotcom commented 2 years ago

quimo@Evans-Air sendemailaction % mvn clean package [INFO] Scanning for projects... [INFO] [INFO] -------------------< com.stream-pi:sendemailaction >-------------------- [INFO] Building sendemailaction 1.0.0 [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ sendemailaction --- [INFO] Deleting /Users/quimo/Documents/GitHub/essential-actions/sendemailaction/target [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ sendemailaction --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/quimo/Documents/GitHub/essential-actions/sendemailaction/src/main/resources [INFO] [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ sendemailaction --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 2 source files to /Users/quimo/Documents/GitHub/essential-actions/sendemailaction/target/classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] the unnamed module reads package org.simplejavamail.internal.modules from both org.simplejavamail.core and org.simplejavamail [ERROR] module org.simplejavamail.core reads package org.simplejavamail.internal.modules from both org.simplejavamail and org.simplejavamail.core [ERROR] module org.simplejavamail reads package org.simplejavamail.internal.modules from both org.simplejavamail.core and org.simplejavamail [ERROR] /Users/quimo/Documents/GitHub/essential-actions/sendemailaction/src/main/java/module-info.java:[1,1] module com.quimodotcom.sendemailaction reads package org.simplejavamail.internal.modules from both org.simplejavamail and org.simplejavamail.core [INFO] 4 errors [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5.316 s [INFO] Finished at: 2022-01-20T11:14:49Z [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sendemailaction: Compilation failure: Compilation failure: [ERROR] the unnamed module reads package org.simplejavamail.internal.modules from both org.simplejavamail.core and org.simplejavamail [ERROR] module org.simplejavamail.core reads package org.simplejavamail.internal.modules from both org.simplejavamail and org.simplejavamail.core [ERROR] module org.simplejavamail reads package org.simplejavamail.internal.modules from both org.simplejavamail.core and org.simplejavamail [ERROR] /Users/quimo/Documents/GitHub/essential-actions/sendemailaction/src/main/java/module-info.java:[1,1] module com.quimodotcom.sendemailaction reads package org.simplejavamail.internal.modules from both org.simplejavamail and org.simplejavamail.core [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

bbottema commented 2 years ago

What is the situation, context and how do I fix this?

quimodotcom commented 2 years ago

What is the situation, context and how do I fix this?

situation is said in the code and the title, context is in the code. idk how to fix it that's why I'm asking you.

bbottema commented 2 years ago

You're not giving me much to go on here, friend. What version of maven and Simple Java Mail are you on. What dependencies do you have if you do mvn dependency:tree what JDK are you using, what Simple Java Mail modules have you included etc., Windows, Linux.

I suspect you are using JDK 11 or above, but I don't know much about modules. There have been issues about this before, which are still open, but frankly I don't get many bug reports about this so I'm not sure.

quimodotcom commented 2 years ago

apache version: Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) Maven home: /usr/local/Cellar/maven/3.8.4/libexec Java version: 17, vendor: Oracle Corporation, runtime: /Users/quimo/jdk-17.jdk/Contents/Home Default locale: en_GB, platform encoding: UTF-8 OS name: "mac os x", version: "12.1", arch: "x86_64", family: "Mac"

SimpleJavaMail: 7.0.0

man dependency:tree: quimo@Evans-MacBook-Air sendemailaction % mvn dependency:tree [INFO] Scanning for projects... [INFO] [INFO] -------------------< com.stream-pi:sendemailaction >-------------------- [INFO] Building sendemailaction 1.0.0 [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ sendemailaction --- [WARNING] The artifact xml-apis:xml-apis:jar:2.0.2 has been relocated to xml-apis:xml-apis:jar:1.0.b2 [INFO] com.stream-pi:sendemailaction:jar:1.0.0 [INFO] +- com.stream-pi:action-api:jar:1.0.0-SNAPSHOT:compile [INFO] | +- com.stream-pi:util:jar:1.0.0-SNAPSHOT:compile [INFO] | | +- org.openjfx:javafx-controls:jar:17.0.0.1:compile [INFO] | | | +- org.openjfx:javafx-controls:jar:mac:17.0.0.1:compile [INFO] | | | - org.openjfx:javafx-graphics:jar:17.0.0.1:compile [INFO] | | | +- org.openjfx:javafx-graphics:jar:mac:17.0.0.1:compile [INFO] | | | - org.openjfx:javafx-base:jar:17.0.0.1:compile [INFO] | | | - org.openjfx:javafx-base:jar:mac:17.0.0.1:compile [INFO] | | +- org.kordamp.ikonli:ikonli-javafx:jar:12.2.0:compile [INFO] | | | - org.kordamp.ikonli:ikonli-core:jar:12.2.0:compile [INFO] | | +- org.kordamp.ikonli:ikonli-fontawesome5-pack:jar:12.2.0:compile [INFO] | | - com.google.code.gson:gson:jar:2.8.8:compile [INFO] | - eu.hansolo:Medusa:jar:11.7:compile [INFO] - org.simplejavamail:simple-java-mail:jar:7.0.0:compile [INFO] +- org.simplejavamail:core-module:jar:7.0.0:compile [INFO] | +- com.sun.mail:jakarta.mail:jar:2.0.1:compile [INFO] | +- com.sun.activation:jakarta.activation:jar:2.0.1:compile [INFO] | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.2:compile [INFO] | | - jakarta.activation:jakarta.activation-api:jar:1.2.1:compile [INFO] | +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile [INFO] | +- com.sanctionco.jmail:jmail:jar:1.2.1:compile [INFO] | - com.github.tony19:named-regexp:jar:0.2.6:compile [INFO] +- com.github.bbottema:jetbrains-runtime-annotations:jar:1.0.1:compile [INFO] - org.slf4j:slf4j-api:jar:1.7.32:compile [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5.527 s [INFO] Finished at: 2022-01-20T15:23:34Z [INFO] ------------------------------------------------------------------------

bbottema commented 2 years ago

So I just did a mvn clean package with SJM 7.0.0 and Oracle JDK 17 and I'm not able to reproduce this. Can you share your code with me?

quimodotcom commented 2 years ago

sendemailaction.zip

bbottema commented 2 years ago

I finally get it, it's the split package problem caused by the same package occurring in multiple modules.

bbottema commented 2 years ago

Thank you for the example, that was very helpful. I released a fix in 7.0.2.

quimodotcom commented 2 years ago

Thank you for the example, that was very helpful. I released a fix in 7.0.2.

absolute legend!