2

So I ran into a problem with a project. Where Eclipse would say that java.util.* has an import error The package java.util is accessible from more than one module: <unnamed>, java.base

I dug around a lot it appears that for some reason no one else is really having this issue. Everyone in our office was. They have told me though that a RC version of Eclipse from 2018 I think Sept works, but that is the only one they can get it to work in. I'll try to post the real version later. So I searched a lot and then started playing with the gradle file for includes. And found that the problem only exists if I include the Cassandra-unit-spring testCompile requirement and because of that it only causes a problem on the test case side.

My assumption is that this is somehow a bug with eclipse as gradle itself has no problem with it. As well as intelij. Let me know what else I can provide here to narrow this down further.

Eclipse Build id: 20190917-1200
Eclipse with Lombok Lombok v1.18.10
Gradle 5.6.4
Oracle JDK 11.0.5
tried cassadnra-unit-spring versions 3.5.0.1 - 3.11.x
Also using spring boot 2.1.3.release

Thanks.

zooppoop
  • 171
  • 1
  • 1
  • 9
  • I don't know anything about Eclipse but the error message suggests that ended up with java.util classes on the class path. The Eclispe compiler should ignore them of course but it's very strange that you've ended up in this scenario in the first place. – Alan Bateman Dec 02 '19 at 10:01
  • I've got the same problem with this dependency and the most recent Eclipse version for a Gradle project. @zooppoop Did you fix the problem? – Sincostan Jul 02 '20 at 20:39
  • Nope. That is unrelated. I found many posts elsewhere referencing that. There is definiltely a Bug between Eclipse and Cassandra Unit test library. all 5 of our devs that have to work with this has the same problem. Either you use Ecplise from Dec 2018 or you deal with this. I was going to submit a but to the eclipse bug tracker but find it too exhausting to deal with. so would rather deal with the stupid bug. – zooppoop Jul 07 '20 at 05:31

2 Answers2

1

I have excluded all (transitive) dependencies of cassandra-unit and re-included them one by one. Eventually, I found out that the library com.boundary:high-scale-lib, i.e., a transitive dependency included by org.apache.cassandra:cassandra-all, is responsible for the import errors.

The library is not Java 9+ ready, since it uses a java.base package name, i.e., java.util. This is not allowed. Unfortunately, you cannot exclude this transtive dependency, since it is required.

I found out that the release version of Eclipse 4.10 does not indicate errors in projects using the library. This is probably a UI bug in newer Eclipse versions, since I can compile and build my application with Gradle without any errors.

You can try this Eclipse version.

Sincostan
  • 361
  • 2
  • 11
0

Thank you very much for your hard work Sincostan

So with the information you provided, if you put into your build.gradle file the inclusion of the cassandra unit test like this

  testImplementation ('org.cassandraunit:cassandra-unit-spring:3.11.2.0') {
    exclude module: 'high-scale-lib'
  }

This allowed it to work in my case. you would of course need to use your own version etc. This is with Gradle 6.3 at this time.

zooppoop
  • 171
  • 1
  • 1
  • 9
  • Can you include your Eclipse version in your answer? Excluding this dependency failed my Unit tests. Do they work in your side? – Sincostan Jul 15 '20 at 08:57
  • Sorry yes using this with 2020.06 and the previous version. Yea you are correct, Sorry I only do this uncommented, then right click on the project -> gradle -> refresh gradle project. Let it work out the dependancies. Then comment it out again. I generally don't use much of the gradle tooling inside of eclipse so it works well enough for me. Sorry about the confusion. – zooppoop Sep 09 '20 at 00:00