Duplicate Class Definition

716 views
Skip to first unread message

Dustin Barnes

unread,
Aug 24, 2012, 4:29:00 PM8/24/12
to gat...@googlegroups.com
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? 

Stéphane Landelle

unread,
Aug 25, 2012, 12:44:43 AM8/25/12
to gat...@googlegroups.com
Hello Dustin,

First time I see this one.

You say it happens randomly on your centos machine?

Stéphane

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

Dustin Barnes

unread,
Aug 25, 2012, 1:08:43 AM8/25/12
to gat...@googlegroups.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. 

Stéphane Landelle

unread,
Aug 25, 2012, 2:05:10 AM8/25/12
to gat...@googlegroups.com
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...@gmail.com>

Dustin Barnes

unread,
Aug 25, 2012, 2:30:11 AM8/25/12
to gat...@googlegroups.com
I'll try to get to it on Monday. Thanks!

Stéphane Landelle

unread,
Aug 25, 2012, 2:36:44 AM8/25/12
to gat...@googlegroups.com
Thanks for reporting and have a nice week-end!

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

Stéphane Landelle

unread,
Aug 28, 2012, 12:20:26 PM8/28/12
to gat...@googlegroups.com
Hi Dustin,

Did you get the chance to test the fix?

Cheers,

Steph

Dustin Barnes

unread,
Sep 4, 2012, 7:07:41 PM9/4/12
to gat...@googlegroups.com
Sorry for the delay. Yes, this seems to have fixed this issue. Thanks!
Reply all
Reply to author
Forward
0 new messages