Skip to content

Instantly share code, notes, and snippets.

@aniketbhatnagar
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aniketbhatnagar/74aae4d9e3a6afb3fea2 to your computer and use it in GitHub Desktop.
Save aniketbhatnagar/74aae4d9e3a6afb3fea2 to your computer and use it in GitHub Desktop.
SBT | NPE if any of the dependencies of a project are null
If any of the libraryDependencies is null, you will get a following exception. This can also happen if you have used lazy vals and have used dependendencies out of order. For example:
val combinedDeps = Seq(d1, d2)
val d1 = "..." %% ".." % "."
val d2 = "..." %% ".." % "."
Will always give the following NPE because d1 is referred before it is declared. Solution to this is to always use lazy vals.
java.lang.NullPointerException
at sbt.CacheIvy$L3$$anonfun$moduleToHL$1.apply(CacheIvy.scala:156)
at sbt.CacheIvy$L3$$anonfun$moduleToHL$1.apply(CacheIvy.scala:156)
at sbt.BasicCacheImplicits$$anon$13.convert(Cache.scala:145)
at sbt.BasicCacheImplicits$$anon$12$$anonfun$convert$2.apply(Cache.scala
:114)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike
.scala:244)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike
.scala:244)
at scala.collection.immutable.List.foreach(List.scala:318)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
at scala.collection.AbstractTraversable.map(Traversable.scala:105)
at sbt.BasicCacheImplicits$$anon$12.convert(Cache.scala:114)
at sbt.BasicCacheImplicits$$anon$12.convert(Cache.scala:112)
at sbt.Tracked$CacheHelp.convert(Tracked.scala:65)
at sbt.Tracked$$anonfun$inputChanged$1.apply(Tracked.scala:43)
at sbt.Classpaths$$anonfun$dependencyPositionsTask$1.apply(Defaults.scal
a:1360)
at sbt.Classpaths$$anonfun$dependencyPositionsTask$1.apply(Defaults.scal
a:1328)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:22
6)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:22
6)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:235)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestric
tions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:47
1)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:615)
at java.lang.Thread.run(Thread.java:745)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment