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

The package javax.xml is accessible from more than one module #330

Closed
slarse opened this issue Jan 15, 2021 · 14 comments · Fixed by #342
Closed

The package javax.xml is accessible from more than one module #330

slarse opened this issue Jan 15, 2021 · 14 comments · Fixed by #342
Labels
bug Something isn't working

Comments

@slarse
Copy link
Collaborator

slarse commented Jan 15, 2021

I get the error in the title in both Eclipse and VS Code (VS code uses an Eclipse backend for Java stuff), and the project refuses to compile. Apparently, a lot of stuff in javax.xml is distributed with the standard library (where it's in a module), but it appears as if dependencies that also have javax.xml in it. The dependency likely pre-dates Java 9, and so javax.xml is not in a module (it says "unknown module"), while it is in the standard library.

The only IDEA that I've found to work around this is IntelliJ, possibly due to better Maven integration than the others. Maven has no problem building the project.

@slarse slarse added the bug Something isn't working label Jan 15, 2021
@slarse
Copy link
Collaborator Author

slarse commented Jan 15, 2021

I've narrowed it down to these two dependencies:

        <dependency>
            <groupId>org.sonarsource.java</groupId>
            <artifactId>java-checks</artifactId>
            <version>6.9.0.23563</version>
        </dependency>
        <dependency>
            <groupId>org.sonarsource.java</groupId>
            <artifactId>sonar-java-plugin</artifactId>
            <version>6.9.0.23563</version>
        </dependency>

Now to figure out what to exclude.

@slarse
Copy link
Collaborator Author

slarse commented Jan 15, 2021

I've spent more than two hours on this now, and I can't solve it. If the two dependencies listed above are removed, all is fine and dandy. But we need those dependencies. I even went as far as to exclude all transitive dependencies from those two dependencies, and the same error message still appears. I give up.

@monperrus @khaes-kth @fermadeiral @nharrand anyone got an idea? Currently, the only tool that can be used to develop Sorald is IntelliJ IDEA, and that's a big problem for me as it crashes constantly on my machine (I had ~15 crashes yesterday).

@slarse
Copy link
Collaborator Author

slarse commented Jan 15, 2021

I can work around it for now (develop in VIM, build with Maven, debug with IDEA), but it would of course be preferable if we could solve the problem with Eclipse.

@khaes-kth
Copy link
Collaborator

@slarse what happens if you exclude ``javax.xml.*'' classes from those dependencies? It seems to be hard but possible to do so.

@slarse
Copy link
Collaborator Author

slarse commented Jan 15, 2021

Tried that. Even excluding every dependency (i.e. groupId and artifactId to *). No dice.

@khaes-kth
Copy link
Collaborator

Tried that. Even excluding every dependency (i.e. groupId and artifactId to *). No dice.

Sad! Maybe the best option is to make IntelliJ work on your PC.

@slarse
Copy link
Collaborator Author

slarse commented Jan 15, 2021

Tried that. Even excluding every dependency (i.e. groupId and artifactId to *). No dice.

Sad! Maybe the best option is to make IntelliJ work on your PC.

It works on and off. Some days are good, some days it crashes all the freaking time. And besides, we don't want the development of Sorald to be contingent on a specific IDE, that's not particularly good practice.

@khaes-kth
Copy link
Collaborator

we don't want the development of Sorald to be contingent on a specific IDE, that's not particularly good practice

Totally agree! We should find some solution.

@slarse
Copy link
Collaborator Author

slarse commented Jan 19, 2021

I just had this happen in IntelliJ IDEA as well! Cleaning the project and recompiling caused the error to disappear. It's probably got something to do with the order of... something.

On a side note, I downgraded IDEA to an earlier version yesterday, and haven't had a crash since. So it seems I'm good for the time being. But yaeh, we should still try to fix this, but we can put it off until after the paper is due as I can now work again :)

@slarse
Copy link
Collaborator Author

slarse commented Jan 25, 2021

Ok, I must fix this. Not only is IDEA still incredibly unstable for me (I'm suspecting an incompatibility somewhere with my new Ryzen 5900X), but it's also blocking #339 which in turn more or less blocks #205. To top it all off, I've had this issue occur in IDEA as well a few times.

I'll bang my head against this issue until I solve it, because it's a significant progress-blocker at this point.

@slarse
Copy link
Collaborator Author

slarse commented Jan 25, 2021

I've further narrowed this down to the xml-apis dependency in sonarl-xml-parsing, which in turn is a dependency of several of the sonar-java artifacts.

@slarse
Copy link
Collaborator Author

slarse commented Jan 25, 2021

I've figured out why excluding dependencies doesn't work: there are a bunch of javax.xml packages included in the sonar-java-plugin jarfile. That's a problem.

@slarse
Copy link
Collaborator Author

slarse commented Jan 25, 2021

So, there are basically two solutions to this problem that I can come up with:

  1. Don't use sonar-java-plugin. If we resort to that, I don't know how to support the @SuppressWarnings things. We'd have to implement that on our own. It may be a lot of work.
  2. Vendor the entire sonar-java project, and perform the minimal modifications necessary to the pom files to not include those darn javax.xml packages into the jarfiles. That is to say, include it as a sub-project of Sorald. A downside is that we then definitely must adopt the LGPL license. Perhaps we ought to do that anyway, though, as Sorald might be considered a derivative product of sonar-java.

I'm giving up for today, though.

@slarse
Copy link
Collaborator Author

slarse commented Jan 26, 2021

I've found another solution: packaging a jar-file for sonar-java-plugin without the xml-apis stuff, and then adding that as a system dependency in Maven. The only problem with that solution is that system dependencies are deprecated ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

2 participants