question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SBT plugin: Using custom source roots causes ClassNotFoundExceptions

See original GitHub issue

Changing the source root breaks gatling:test and gatling-it:test commands.

For example, a setting such as (documented by SBT plugin: Default settings):

scalaSource in Gatling := sourceDirectory.value / "gatling" / "scala"

Will cause gatling:test to fail with:

[error] Uncaught exception when running computerdatabase.BasicSimulation: java.lang.ClassNotFoundException: computerdatabase.BasicSimulation
[trace] Stack trace suppressed: run last gatling:test for the full output.
[info] Simulation(s) execution ended.
[error] Error during tests:
[error] 	computerdatabase.BasicSimulation
[error] (gatling:test) sbt.TestsFailedException: Tests unsuccessful

Everything works as expected with the scalaSource in Gatling left unchanged and simulation sources in src/test/scala.

Using Scala 2.11.4 (a different—but seemingly unrelated error—occurs with Scala 2.12), gatling-sbt 2.2.1, and gatling-test-framework 2.2.5.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
slandellecommented, Oct 13, 2017

I had a look, and behavior is super weird.

I tries changing sourceDirectory in Gatling := baseDirectory.value / "src" / "gatling" (sbt 0.13.16). Then, generated class files suddenly end up in target/gatling-classes instead of target/test-classes. Resources files are still copied in target/test-classes. And test framework keeps on having target/gatling-classes in its classpath, hence the ClassNotFoundException.

I’m pretty sure changing sourceDirectory used to work, but I have no idea when it stopped, and if it’s a bug on our side or in sbt. And we no longer have a sbt roxxor with us. If it’s an sbt bug, I’m afraid we’ll have to first upgrade our tooling to sbt 1.0, which we can’t do yet, see #3351.

It would be great if some community member with sbt skills could chime in. Maybe @xuwei-k?

0reactions
slandellecommented, Nov 24, 2017

@HugoTigre Thanks for your help! Actually, it seems this is enough:

scalaSource in Gatling := sourceDirectory.value / "gatling" / "scala"
lazy val root = (project in file(".")).settings(inConfig(Gatling)(Defaults.testSettings): _*)
Read more comments on GitHub >

github_iconTop Results From Across the Web

ClassNotFoundException trying to run my unit tests with SBT
I have a Java project that I'm building using SBT. I have a single JUnit test class. My build.sbt has the line:.
Read more >
sbt/sbt - Gitter
Hello. I'm seeking advice on building a custom plugin dedicated to one project. More precisely, I would like to replace a single file...
Read more >
sbt Reference Manual — Combined Pages
Supports testing with ScalaCheck, specs, and ScalaTest. JUnit is supported by a plugin. Starts the Scala REPL with project classes and dependencies on...
Read more >
Play 2.7 Migration Guide - Documentation
Update the Play version number in project/plugins.sbt to upgrade Play: ... If you use a custom body parser for a file upload you...
Read more >
SBT | Adventures of a space monkey
Posts about SBT written by nidkil. ... and reload a web app when a source file is changed by using the following command:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found