Duplicate Class Definition

Every so often, I run into a compile error:

[INFO] Collecting simulations…
[INFO] Exception in thread “main” java.lang.LinkageError: loader (instance of scala/tools/nsc/interpreter/AbstractFileClassLoader): attempted duplicate class definition for name: “com/mypackage/AbstractParentSimulation”
[INFO] at java.lang.ClassLoader.defineClass1(Native Method)
[INFO] at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
[INFO] at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
[INFO] at scala.tools.nsc.interpreter.AbstractFileClassLoader.findClass(AbstractFileClassLoader.scala:52)
[INFO] at com.excilys.ebi.gatling.app.Gatling$$anonfun$loadSimulationClasses$4.apply(Gatling.scala:205)
[INFO] at com.excilys.ebi.gatling.app.Gatling$$anonfun$loadSimulationClasses$4.apply(Gatling.scala:205)
[INFO] at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:233)
[INFO] at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:233)
[INFO] at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
[INFO] at scala.collection.immutable.List.foreach(List.scala:76)
[INFO] at scala.collection.TraversableLike$class.map(TraversableLike.scala:233)
[INFO] at scala.collection.immutable.List.map(List.scala:76)
[INFO] at com.excilys.ebi.gatling.app.Gatling.loadSimulationClasses(Gatling.scala:205)
[INFO] at com.excilys.ebi.gatling.app.Gatling.start(Gatling.scala:105)
[INFO] at com.excilys.ebi.gatling.app.Gatling$.main(Gatling.scala:69)
[INFO] at com.excilys.ebi.gatling.app.Gatling.main(Gatling.scala)

This is while running through the maven plugin. Basically, there are a bunch of simulation classes that extend a base simulation.

This setup works on my windows machine and my ubuntu machine, but on the centos machine(s), it fails. Any tips on getting around this?

Hello Dustin,

First time I see this one.

You say it happens randomly on your centos machine?


2012/8/24 Dustin Barnes <dustin.barnes@gmail.com>

Yeah. I ended up getting around it by removing the inheritance and using some includes. But I had identical versions of maven, and the java difference was 1.7.0_3 vs 1.7.0_6, all the rest of the dependencies the same.

I think I pinned it: I was using ClassLoader.findClass instead of ClassLoader.loadClass. Once again, an example of poorly named java API, and my fault not reading the javadoc…


Do you think you could build from sources and give it a try?

2012/8/25 Dustin Barnes <dustin.barnes@gmail.com>

I’ll try to get to it on Monday. Thanks!

Thanks for reporting and have a nice week-end!

2012/8/25 Dustin Barnes <dustin.barnes@gmail.com>

Hi Dustin,

Did you get the chance to test the fix?



Sorry for the delay. Yes, this seems to have fixed this issue. Thanks!