(Julien Perret) #1

I have a model in a scala project that throws a ClassNotFoundException when run from openmole.
The task is defined in my jar (built with sbt osgiBundle) like that:

object hmmmatcher {
def run(…)

Then, my workflow uses that task:

val hmmmatcherTask = ScalaTask(“val m =…)”) set (
libraries += workDirectory / “nm_2.12-1.0-SNAPSHOT.jar”,


The error thrown is:
org.openmole.core.exception.InternalProcessingError: Error for context values in$@4b77d812 {fileNetwork1=/home/julien/.openmole/michele-julien-1/webui/projects/nm/snapshot_1825.0_1836.0_edges.shp, fileNetwork2=/home/julien/.openmole/michele-julien-1/webui/projects/nm/snapshot_1784.0_1791.0_edges.shp, idAttribute1=ID, idAttribute2=ID, lpsolving=0.0, openmole$seed=-7076074100557766095, resampling=0.0, selection=10.0, stroke_length=10.0}
Caused by: java.lang.NoClassDefFoundError: fr/ign/nm/hmmmatcher$
at $line3.$read$$iw$$iw$$anonfun$1.apply(:25)
… 32 more
Caused by: java.lang.ClassNotFoundException: fr.ign.nm.hmmmatcher$
at scala.reflect.internal.util.AbstractFileClassLoader.findClass(AbstractFileClassLoader.scala:62)
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
… 33 more

I checked in the jar and the class is there (and in the MANIFEST too as exported).
Any idea?



Do you use the version 2.12 of scala for your model?

(Julien Perret) #3

Yes, why?


Just like that… and did you brush your teeth? :slight_smile:

It is hard to guess why it is not working. If your courageous you could inspect the classPath generated by the ScalaTask using println to check what’s going wrong.

(Julien Perret) #5

Ok, how do I do that?


You add some println in the code of the ScalaTask in OpenMOLE to try to guess what’s going wrong. I think the first thing is to make sure that your jar is in the class path of the scala compilator of the task.

(Julien Perret) #7

So I changed my script to:
val hmmmatcherTask = ScalaTask("""
|val matches = fr.ign.nm.hmmmatcher.runFromDouble(…)""".stripMargin) set (
libraries += workDirectory / “nm_2.12-1.0-SNAPSHOT.jar”,


and the classpath is:

so it does not contain the library…


This is the class path of the jvm no the one of the ScalaTask. In the ScalaTask you have this code:

 def compile(implicit newFile: NewFile, fileService: FileService) = {
    implicit def m = manifest[java.util.Map[String, Any]]
      libraries = libraries,
      plugins = plugins

This scala compilation object is what will handle the class path. If you feel courageous you might want to dig into it to check what is going wrong…

(Julien Perret) #9

How do I get the classpath used by the scalaTask?


I don’t remember exactly, you’ll have to inspect how the ScalaCompilation object works…