Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.w3c.dom is accessible from more than one module: <unnamed>, java.xml during building #2829

Closed
1 of 7 tasks
bobshie opened this issue Nov 9, 2022 · 10 comments
Closed
1 of 7 tasks
Milestone

Comments

@bobshie
Copy link
Contributor

bobshie commented Nov 9, 2022

TestNG Version

testng-7.6.2-20221104.005911-6.jar
openjdk 17.0.1 2021-10-19
Apache Maven 3.6.3

Expected behavior

No error

Actual behavior

mvn --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\Program Files\apache-maven-3.6.3\bin\..
Java version: 17.0.1, vendor: Oracle Corporation, runtime: C:\Program Files (x86)\Java\jdk-17.0.1
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
[ERROR] Failed to execute goal dev.aspectj:aspectj-maven-plugin:1.13.1:compile (compile_with_aspectj) on project: AJC compiler errors:

[ERROR] error at import javax.xml.parsers.DocumentBuilder;
[ERROR]        ^^^^^^^^^^^^^^^^
[ERROR] /src/main/java/com/LogHandler.java:7:0::0 The package javax.xml.parsers is accessible from more than one module: <unnamed>, java.xml
[ERROR] error at import javax.xml.parsers.DocumentBuilderFactory;
[ERROR]        ^^^^^^^^^^^^^^^^
[ERROR] /src/main/java/com/LogHandler.java:8:0::0 The package javax.xml.parsers is accessible from more than one module: <unnamed>, java.xml
[ERROR] error at import org.w3c.dom.Document;
[ERROR]        ^^^^^^^^^^

Is the issue reproducible on runner?

  • Shell
  • Maven
  • Gradle
  • Ant
  • Eclipse
  • IntelliJ
  • NetBeans

Test case sample

Please, share the test case (as small as possible) which shows the issue
None

Contribution guidelines

Incase you plan to raise a pull request to fix this issue, please make sure you refer our Contributing section for detailed set of steps.

####
new testng involved com.github.spotbugs:spotbugs:jar:4.7.1:compile that dependent on jaxen and saxon, that depend on xml-apis

      jaxen:jaxen:jar:1.2.0:test
         xml-apis:xml-apis:jar:1.3.02:provided
      net.sf.saxon:Saxon-HE:jar:11.3:provided
          org.xmlresolver:xmlresolver:jar:4.2.0:provided
          org.xmlresolver:xmlresolver:jar:data:4.2.0:provided

in xml-apis, there are org.w3c and javax.xml in jar file. so there is conflict:

image

ref:
https://support.tibco.com/s/article/Upgrading-Streaming-projects-to-use-Java-11-package-is-accessible-from-more-than-one-module
https://stackoverflow.com/questions/68839894/java-11-migration-package-is-accessible-from-more-than-one-module-issue
https://stackoverflow.com/questions/57286825/the-package-org-w3c-dom-is-accessible-from-more-than-one-module-unnamed-java

@bobshie
Copy link
Contributor Author

bobshie commented Nov 9, 2022

com.github.spotbugs.spotbugs replace com.google.code.findbugs.jsr305 in

eb31064

@krmahadevan
Copy link
Member

@bobshie - Couple of things.

  1. I noticed that you are on JDK17. Officially we haven't certified TestNG to be JDK17 compliant. So can you please retry this using JDK11 and see if the problem persists ?
  2. If (1) is true, please share a sample project that I can use to reproduce the problem. It would be easier to fix it with that.

Alternatively if you are already aware of the root cause, maybe you can help raise a PR and we can help you get it merged.

@martinaldrin
Copy link

We have used JDK 17 for long time with previous TestNg version without any issues.
The problem as I understand it is that spotbugs is part of testng jar, spotbug should not be delivered with testng jar.

@krmahadevan
Copy link
Member

We have used JDK 17 for long time with previous TestNg version without any issues. The problem as I understand it is that spotbugs is part of testng jar, spotbug should not be delivered with testng jar.

Spotbugs was part of earlier releases of TestNG as well, please see here Maybe there's something peculiar here that needs to be checked on.

@krmahadevan
Copy link
Member

Also can we check if the problem goes away if we add an exclusion to this dependency ?

@juherr
Copy link
Member

juherr commented Nov 9, 2022

@krmahadevan spotbugs is a dev dependency. Maybe we can try to make it optional or provided in the generated pom.xml?

@martinaldrin
Copy link

Spotbugs was part of earlier releases of TestNG as well, please see here Maybe there's something peculiar here that needs to be checked on.

Yes I can see that Findbugs was part of the pom in earlier version of TestNg, but Findbugs/Spotbug is a code checker that is used for checking your code, should not be added as a dependency or have I misunderstood how it is used in TestNg?
Spotbug should be part of your build, but never part of the delivery. I guess you can change it to "compileOnly"
https://repo1.maven.org/maven2/org/testng/testng/7.6.1/testng-7.6.1.pom

@krmahadevan
Copy link
Member

@martinaldrin - Would you like to raise a PR for this ?

@juherr - agreed!

@bobshie
Copy link
Contributor Author

bobshie commented Nov 9, 2022

@krmahadevan , I can try to fix it in next week.

bobshie added a commit to bobshie/testng that referenced this issue Nov 14, 2022
 org.w3c.dom is accessible from more than one module: <unnamed>, java.xml during building testng-team#2829
bobshie added a commit to bobshie/testng that referenced this issue Nov 14, 2022
org.w3c.dom is accessible from more than one module: <unnamed>, java.xml during building cbeust#2829

Signed-off-by: Bob Shi <bob.shi@ericsson.com>
krmahadevan pushed a commit that referenced this issue Nov 14, 2022
org.w3c.dom is accessible from more than one module: <unnamed>, java.xml during building cbeust#2829

Signed-off-by: Bob Shi <bob.shi@ericsson.com>
@krmahadevan
Copy link
Member

Closed via #2833

@krmahadevan krmahadevan added this to the 7.6.2 milestone Nov 14, 2022
@krmahadevan krmahadevan modified the milestones: 7.6.2, 7.7.0 Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants