Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninformative exception when head called on empty list #46

Closed
schmmd opened this issue Oct 4, 2013 · 7 comments
Closed

Uninformative exception when head called on empty list #46

schmmd opened this issue Oct 4, 2013 · 7 comments

Comments

@schmmd
Copy link
Contributor

schmmd commented Oct 4, 2013

https://github.com/sbt/sbt-native-packager/blob/master/src/main/scala/com/typesafe/sbt/packager/universal/Archives.scala#L126

I'm not sure what the cause is. We probably want a .headOption.getOrElse(throw)

java.util.NoSuchElementException: next on empty iterator
    at scala.collection.Iterator$$anon$2.next(Iterator.scala:39)
    at scala.collection.Iterator$$anon$2.next(Iterator.scala:37)
    at scala.collection.IndexedSeqLike$Elements.next(IndexedSeqLike.scala:64)
    at scala.collection.IterableLike$class.head(IterableLike.scala:91)
    at scala.collection.mutable.ArrayOps$ofRef.scala$collection$IndexedSeqOptimized$$super$head(ArrayOps.scala:108)
    at scala.collection.IndexedSeqOptimized$class.head(IndexedSeqOptimized.scala:120)
    at scala.collection.mutable.ArrayOps$ofRef.head(ArrayOps.scala:108)
    at com.typesafe.sbt.packager.universal.Archives$$anonfun$makeTarball$1.apply(Archives.scala:126)
    at com.typesafe.sbt.packager.universal.Archives$$anonfun$makeTarball$1.apply(Archives.scala:116)
    at sbt.IO$.withTemporaryDirectory(IO.scala:285)
    at com.typesafe.sbt.packager.universal.Archives$.makeTarball(Archives.scala:116)
    at com.typesafe.sbt.packager.universal.Archives$$anonfun$10.apply(Archives.scala:109)
    at com.typesafe.sbt.packager.universal.Archives$$anonfun$10.apply(Archives.scala:109)
    at scala.Function3$$anonfun$tupled$1.apply(Function3.scala:35)
    at scala.Function3$$anonfun$tupled$1.apply(Function3.scala:34)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
    at sbt.std.Transform$$anon$4.work(System.scala:64)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
    at sbt.Execute.work(Execute.scala:244)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    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:724)
[error] (universal:packageZipTarball) java.util.NoSuchElementException: next on empty iterator
@jsuereth
Copy link
Member

jsuereth commented Oct 7, 2013

BTW - I'm not 100% certain why you saw this. It means for some reason the tar file was not created, but the process returned success. After the next release of sbt-native-packager, I'd love to here feedback on what the new error message states.

@schmmd
Copy link
Contributor Author

schmmd commented Oct 7, 2013

Sure. I'm not sure either. I was trying to create my first sbt packager package and I was having a lot of trouble. I was going to get it to work and improve the documentation, but then I ran into this.

@jsuereth
Copy link
Member

jsuereth commented Oct 7, 2013

Anything I can do to help, please let me know. Perhaps if you had an example project with the problem, so I can try it out?

@schmmd
Copy link
Contributor Author

schmmd commented Oct 7, 2013

Josh, I can give you a GitHub url to sample projects. Beware it has a test case with significant memory resources (this is a pain point for me). I'm probably doing a lot wrong, but I spent some time earlier with the available documentation.

> sbt clean compile
...
/home/michael/hack/github/knowitall/openie/build.sbt:78: error: not found: value archetypes
archetypes.java_application
^

If I remove the problematic line, the next error I get is:

> sbt clean compile
...
/home/michael/hack/github/knowitall/openie/build.sbt:49: error: not found: value packageSummary
packageSummary in Linux := "The name you want displayed in package summaries"
^
[error] Type error in expression
  • If I remove everything beneath packagerSettings, I get an exception like before. Note that this time I'm running this on an entirely different machine (personal machine at home vs work machine at work).

https://github.com/knowitall/openie/tree/package1

> sbt clean compile universal:package-zip-tarball
java.util.NoSuchElementException: next on empty iterator
    at scala.collection.Iterator$$anon$3.next(Iterator.scala:27)
    at scala.collection.Iterator$$anon$3.next(Iterator.scala:25)
    at scala.collection.IndexedSeqLike$Elements.next(IndexedSeqLike.scala:63)
    at scala.collection.IterableLike$class.head(IterableLike.scala:90)
    at scala.collection.mutable.ArrayOps.scala$collection$IndexedSeqOptimized$$super$head(ArrayOps.scala:38)
    at scala.collection.IndexedSeqOptimized$class.head(IndexedSeqOptimized.scala:121)
    at scala.collection.mutable.ArrayOps.head(ArrayOps.scala:38)
    at com.typesafe.sbt.packager.universal.Archives$$anonfun$makeTarball$1.apply(Archives.scala:126)
    at com.typesafe.sbt.packager.universal.Archives$$anonfun$makeTarball$1.apply(Archives.scala:116)
    at sbt.IO$.withTemporaryDirectory(IO.scala:262)
    at com.typesafe.sbt.packager.universal.Archives$.makeTarball(Archives.scala:116)
    at com.typesafe.sbt.packager.universal.Archives$$anonfun$10.apply(Archives.scala:109)
    at com.typesafe.sbt.packager.universal.Archives$$anonfun$10.apply(Archives.scala:109)
    at sbt.Scoped$$anonfun$hf3$1.apply(Structure.scala:579)
    at sbt.Scoped$$anonfun$hf3$1.apply(Structure.scala:579)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:49)
    at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
    at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:41)
    at sbt.std.Transform$$anon$5.work(System.scala:71)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
    at sbt.Execute.work(Execute.scala:238)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:232)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:232)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    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:724)
[error] (universal:package-zip-tarball) java.util.NoSuchElementException: next on empty iterator
[error] Total time: 0 s, completed Oct 7, 2013 3:15:52 PM

@jsuereth
Copy link
Member

Ah, so this is definitely a "documentation is poor" error. Specifically, here's a build.sbt that will work for you:

import AssemblyKeys._
import NativePackagerKeys._

assemblySettings

name := "openie"

organization := "edu.washington.cs.knowitall.openie"

version := "4.1.1-SNAPSHOT"

crossScalaVersions := Seq("2.10.2")

scalaVersion <<= crossScalaVersions { (vs: Seq[String]) => vs.head }

resolvers += "Sonatype SNAPSHOTS" at "https://oss.sonatype.org/content/repositories/snapshots/"

libraryDependencies ++= Seq(
  // extractor components
  "edu.washington.cs.knowitall.srlie" %% "srlie" % "1.0.1",
  "edu.washington.cs.knowitall.chunkedextractor" %% "chunkedextractor" % "1.0.6",
  // for splitting sentences
  "edu.washington.cs.knowitall.nlptools" %% "nlptools-sentence-opennlp" % "2.4.3",
  // for remote components
  "net.databinder.dispatch" %% "dispatch-core" % "0.11.0",
  // resource management
  "com.jsuereth" %% "scala-arm" % "1.3",
  // logging
  "org.slf4j" % "slf4j-api" % "1.7.5",
  "ch.qos.logback" % "logback-core" % "1.0.13",
  "ch.qos.logback" % "logback-classic" % "1.0.13",
  "org.scalatest" % "scalatest_2.10" % "2.0.RC1" % "test")

mainClass in assembly := Some("edu.knowitall.openie.OpenIECli")

scalacOptions ++= Seq("-unchecked", "-deprecation")

// custom options for high memory usage

javaOptions += "-Xmx4G"

javaOptions += "-XX:+UseConcMarkSweepGC"

fork in run := true

fork in Test := true

connectInput in run := true // forward stdin/out to fork

licenses := Seq("Open IE Software License Agreement" -> url("https://raw.github.com/knowitall/openie/master/LICENSE"))

homepage := Some(url("https://github.com/knowitall/openie"))

publishMavenStyle := true

publishTo <<= version { (v: String) =>
  val nexus = "https://oss.sonatype.org/"
  if (v.trim.endsWith("SNAPSHOT"))
    Some("snapshots" at nexus + "content/repositories/snapshots")
  else
    Some("releases"  at nexus + "service/local/staging/deploy/maven2")
}

pomExtra := (
  <scm>
    <url>https://github.com/knowitall/openie</url>
    <connection>scm:git://github.com/knowitall/openie.git</connection>
    <developerConnection>scm:git:git@github.com:knowitall/openie.git</developerConnection>
    <tag>HEAD</tag>
  </scm>
  <developers>
   <developer>
      <name>Michael Schmitz</name>
    </developer>
  </developers>)

packageArchetype.java_application

packageSummary in Linux := "The name you want displayed in package summaries"

packageDescription := " A description of your project"

The changes are:

+import NativePackagerKeys._

- archetypes.java_application
+ packageArchetype.java_application

I'm updating the docs now!

@schmmd
Copy link
Contributor Author

schmmd commented Oct 15, 2013

Cool. I saw both archetypes.java_application and packageArchetype.java_application in the docs--so clarifying will definitely help!

@jsuereth
Copy link
Member

Yep. One is a carry-over from a rename. Updated the README.md with need-to-know info for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants