sbt/sbt-scalabuff

java.lang.NoClassDefFoundError: net/sandrogrzicic/scalabuff/compiler/ScalaBuff

Closed this issue · 5 comments

Not sure about the cause of this, so I call this issue by its main symptom. I see this error when sbt tries to compile my .proto files in a simple project. It is configured as per the readme. I am running Fedora 16 x64, OpenJDK 1.6 and sbt 0.12.3. To investigate the problem, I downloaded the source of sbt-scalabuff and made it print a list used as a second argument for Fork.java in scalabuff.ScalaBuffPlugin.process method. Then I packaged sbt-scalabuff, used it as an unmanaged dependency for my project's build definition and did sbt compile on my project (let X denote a sequence of actions described in this sentence). The classpath argument for java was empty. So I put scalabuff compiler jar from sbt cache into my project's lib and hardcoded classpath pointing to it into sbt-scalabuff. After that I did X and sbt found the scalabuff compiler main class, but could not find scala.Function1 class. So it seems likely that the cause of the problem is the empty classpath argument. Feel free to comment on this issue and request any details you need so that we can work together to resolve this.

I'd love to help, but I don't really think I can do much since this is directly related to the SBT plugin itself.

rssh commented

btw, can you add self-contained attaced as archive or as github project ?

rssh commented

I found error in you example:

  settings = Defaults.defaultSettings ++
            scalabuffSettings ++
            Seq(scalaVersion := "2.10.0",
                name := "scalabuff_test",
                libraryDependencies := Seq(
                   "net.databinder.dispatch" %% "dispatch-core" % "0.10.0"
                )
            )

here you set libraryDependencies after setting scalabuff default settings.
But scalabuff default settings modify libraryDependencies. Changing setting dependencies to

                ....
                libraryDependencies ++= Seq(
                   "net.databinder.dispatch" %% "dispatch-core" % "0.10.0"
                )
  

do the trick

(example at https://github.com/rssh/scala-training-materials/tree/master/protobuf-example )

I guess, sbt-scalabuff issue can be closed.

rssh is correct. Sorry for the stir-up.