How to build a jar for the Basel-face-pipeline

48 views
Skip to first unread message

Shreya Kapoor

unread,
Oct 24, 2023, 10:21:16 AM10/24/23
to scalismo-faces
  1. Here is the build.sbt which I used to create the basel-face-pipeline jar file:

name := "basel-face-pipeline"

version := "0.1"

scalaVersion := "2.11.8"

// Define compiler options
scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")

// Define resolvers for external dependencies
resolvers += Resolver.jcenterRepo
resolvers += Resolver.bintrayRepo("unibas-gravis", "maven")

// Define library dependencies
libraryDependencies += "ch.unibas.cs.gravis" %% "scalismo-faces" % "0.5.0"
libraryDependencies += "ch.unibas.cs.gravis" %% "scalismo-ui" % "0.11.+"
libraryDependencies += "ch.unibas.cs.gravis" %% "scalismo" % "0.15.0"
libraryDependencies += "com.github.tototoshi" %% "scala-csv" % "1.3.3"
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.5.0"
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.7"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.8" % "test"
libraryDependencies += "org.rogach" %% "scallop" % "2.1.3"

// Exclude slf4j-nop from all dependencies
libraryDependencies ~= { _.map(_.exclude("org.slf4j", "slf4j-nop")) }

// Define the main class for assembly
assembly / mainClass := Some("ch.fitting.experiments.RecognitionMultiPiePose")
mainClass in Compile := Some("ch.fitting.experiments.RecognitionMultiPiePose")
// Define a main class for the "packageConfig" configuration
mainClass := Some("ch.fitting.experiments.RecognitionMultiPiePose")
Compile / packageBin / mainClass := Some("ch.fitting.experiments.MultiPiePose")

// Define merge strategies for assembly
assembly / assemblyMergeStrategy := {
case PathList("META-INF", xs @ _*) =>
(xs map { _.toLowerCase }) match {
case ("manifest.mf" :: Nil) | ("index.list" :: Nil) | ("dependencies" :: Nil) =>
MergeStrategy.discard
case ps @ (x :: xs) if ps.last.endsWith(".sf") || ps.last.endsWith(".dsa") =>
MergeStrategy.discard
case "services" :: xs =>
MergeStrategy.filterDistinctLines
case _ => MergeStrategy.first
}
case _ => MergeStrategy.first
}


And when I run the build.sbt and use the jar then I get the following error:


java -jar basel-face-pipeline.jar
Error: Unable to initialize main class fitting.experiments.RecognitionMultiPiePose
Caused by: java.lang.NoClassDefFoundError: scalismo/utils/Random

I think this should be handled by buid.sbt but it is not.

I am running into an error, I am on Mac OSx

Best regards,
Shreya Kapoor



Shreya Kapoor

unread,
Oct 24, 2023, 11:08:10 AM10/24/23
to scalismo-faces
I am using the following java version 

java 19.0.1 2022-10-18
Java(TM) SE Runtime Environment (build 19.0.1+10-21)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)

Marcel Luethi

unread,
Oct 25, 2023, 12:31:01 AM10/25/23
to Shreya Kapoor, scalismo-faces
Dear Shreya

Your build.sbt looks correct. Did you run sbt assembly to build the jar? Do you get a warning message when you build the jar?  

If not, a problem could be that you run the wrong jar file. Sbt assembly generates a few different jar files. Make sure you take the one in target/YOUR_SCALA_VERSION . It should be a relatively large file.

Best regards,

Marcel

--
You received this message because you are subscribed to the Google Groups "scalismo-faces" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalismo-face...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalismo-faces/25dba9e4-a89a-442e-9ed1-249f4543da11n%40googlegroups.com.

Shreya Kapoor

unread,
Oct 25, 2023, 3:41:28 AM10/25/23
to scalismo-faces
Dear Marcel, 

Thanks for your reply. Yes I ran sbt assembly to build the jar and I did get a warning message 

[info] set current project to basel-face-pipeline (in build file:/Users/shreya/Documents/basel-face-pipeline/)
[warn] there's a key that's not used by any other settings/tasks:
[warn]  
[warn] * basel-face-pipeline / mainClass
[warn]   +- /Users/shreya/Documents/basel-face-pipeline/build.sbt:30
[warn]  
[warn] note: a setting might still be used by a command; to exclude a key from this `lintUnused` check
[warn] either append it to `Global / excludeLintKeys` or call .withRank(KeyRanks.Invisible) on the key
[info] Strategy 'discard' was applied to a file (Run the task at debug level to see details)
[warn] Ignored unknown package option FixedTimestamp(Some(1262304000000))

Yes, I am indeed running the jar file under target/scala-version
I am running this with Java 8 on Mac OS X Ventura 13.0.01

Best regards,
Shreya Kapoor

Shreya Kapoor

unread,
Oct 25, 2023, 6:58:37 AM10/25/23
to scalismo-faces
Dear all, 

I managed to resolve the error. 
I changed the system version to java 8 
I realised that the sbt was building the jar with java 19 and hence I was getting the error
It runs now

Best regards
Shreya Kapoor



--
skapoor@gmail

Marcel Luethi

unread,
Oct 25, 2023, 7:43:00 AM10/25/23
to Shreya Kapoor, scalismo-faces
Great to hear that you could fix the error. And thanks for reporting back. I will add a note to the readme that java 8 is required.

Best regards,

Marcel

Reply all
Reply to author
Forward
Message has been deleted
0 new messages