2

I am working on a jetty service, and when starting it, I get a lot of:

SomeClass scanned from multiple locations: jar: jar1!Someclass.class, jar2!Someclass.class

So a single class is provided by two jars, and which I get on runtime is undefined, which is not good. Looking at other issues I found that tattletale can help diagnosing the problem. The report, in the Multiple Jar files section lists the same classes as jetty upon startup and which jars they were in. A subset of the conflicts are:

tattletale_conflicts

And looking at

mvn dependency:tree -D verbose

I get:

+- ca.uhn.hapi.fhir:hapi-fhir-jpaserver-base:jar:3.7.0:compile
|  |                   ...
|  +- org.jscience:jscience:jar:4.3.1:compile
|  |  \- org.javolution:javolution:jar:5.2.3:compile

And so it seems that my fhir-base-jpaserver-base dependency pulls jscience that pulls javolution. But jscience and javolution supply some of the same classes. No other dependency to javolution exists.

My question is then, how do I go about solving this?

I could do some stuff in pom.xml but I suppose jscience needs javolution, and might break?

  • Look at the contents of those 2 jars, if jscience has the javolution classes in it, then it shouldn't also need the javolution.jar file. – Joakim Erdfelt Oct 09 '20 at 09:21
  • @JoakimErdfelt: It seems that all of javolution is also in the jscience jar. It does not make any sense to me to depend on something and then also include it. The dependency can be seen here: https://mvnrepository.com/artifact/org.jscience/jscience/4.3.1 Are you suggesting that I should try to use some mvn magic to exclude javolution? – alex-jesper Oct 09 '20 at 10:59

1 Answers1

0

Sounds like a bug in jscience with how they packaged their jar, might want to file an issue with them.

They should either ...

  • have a proper/focused jar and dependencies.
  • or a standalone uber jar with no dependencies.

Not mixing the two concepts.

Meanwhile, just use the <dependency>/<exclusions> to exclude specific transitive dependencies that are causing you duplicate classes.

Also, you might want to run any of the various duplicate class/resource checker maven plugins to find any other cases you might have present on your project.

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136