davidB / scala-maven-plugin

The scala-maven-plugin (previously maven-scala-plugin) is used for compiling/testing/running/documenting scala code in maven.
https://davidb.github.io/scala-maven-plugin/
The Unlicense
560 stars 151 forks source link

mvn compile fails with InvocationTargetException #25

Closed riedelcastro closed 14 years ago

riedelcastro commented 14 years ago

When I run mvn compile on our scala project I get the error message attached below. Note that when compiled manually there are no problems.

This happens on Mac OS 10.5 with a MacBook and MacBook Pro. I haven't tested it on other architectures. I'm happy to provide a source package with pom file in order to reproduce this. One could also checkout

hg clone https://factorie.googlecode.com/hg/ factorie

and go to revision 246 (this is where it stopped working)

hg update -C -r 246; mvn clean compile

In revision 245 it works just fine.

I'm sorry I can't give a more condensed scenario for the error. The change from 245 to 246 involved several files, and the error message doesn't give much away in terms of which file causes the problem.

durer:factorie-0.8.1-SNAPSHOT riedel$ mvn clean compile [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building Unnamed - cc.factorie:factorie:jar:0.8.1-SNAPSHOT [INFO] task-segment: [clean, compile] [INFO] ------------------------------------------------------------------------ [INFO] [clean:clean {execution: default-clean}] [INFO] Deleting directory /private/tmp/factorie-0.8.1-SNAPSHOT/target [INFO] [resources:resources {execution: default-resources}] [WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /private/tmp/factorie-0.8.1-SNAPSHOT/src/main/resources [INFO] [compiler:compile {execution: default-compile}] [INFO] Compiling 2 source files to /private/tmp/factorie-0.8.1-SNAPSHOT/target/classes [INFO] [scala:compile {execution: default}] [INFO] Checking for multiple versions of scala [WARNING] Multiple versions of scala libraries detected! [INFO] includes = [*/.scala,*/.java,] [INFO] excludes = [] [INFO] /private/tmp/factorie-0.8.1-SNAPSHOT/src/main/java:-1: info: compiling

[INFO] /private/tmp/factorie-0.8.1-SNAPSHOT/src/main/scala:-1: info: compiling

[INFO] Compiling 91 source files to /private/tmp/factorie-0.8.1-SNAPSHOT/target/classes at 1262621758108 [INFO] java.lang.reflect.InvocationTargetException [INFO] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [INFO] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [INFO] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [INFO] at java.lang.reflect.Method.invoke(Method.java:592) [INFO] at org_scala_tools_maven_executions.MainHelper.runMain(MainHelper.java:151) [INFO] at org_scala_tools_maven_executions.MainWithArgsInFile.main(MainWithArgsInFile.java:26) [INFO] Caused by: java.lang.NullPointerException [INFO] at scala.tools.nsc.symtab.Types$ClassInfoType.scala$tools$nsc$symtab$Types$ClassInfoType$$getRefs(Types.scala:1245) [INFO] at scala.tools.nsc.symtab.Types$ClassInfoType$$anonfun$scala$tools$nsc$symtab$Types$ClassInfoType$$propagate$2$$anonfun$apply$4.apply(Types.scala:1319) [INFO] at scala.tools.nsc.symtab.Types$ClassInfoType$$anonfun$scala$tools$nsc$symtab$Types$ClassInfoType$$propagate$2$$anonfun$apply$4.apply(Types.scala:1317) [INFO] at scala.Iterator$class.foreach(Iterator.scala:414) [INFO] at scala.collection.mutable.ResizableArray$$anon$1.foreach(ResizableArray.scala:66) [INFO] at scala.Iterable$class.foreach(Iterable.scala:256) [INFO] at scala.collection.immutable.HashSet.foreach(HashSet.scala:39) [INFO] at scala.tools.nsc.symtab.Types$ClassInfoType$$anonfun$scala$tools$nsc$symtab$Types$ClassInfoType$$propagate$2.apply(Types.scala:1317) [INFO] at scala.tools.nsc.symtab.Types$ClassInfoType$$anonfun$scala$tools$nsc$symtab$Types$ClassInfoType$$propagate$2.apply(Types.scala:1316) [INFO] at scala.Iterator$class.foreach(Iterator.scala:414) [INFO] at scala.Iterator$$anon$7.foreach(Iterator.scala:36) [INFO] at scala.tools.nsc.symtab.Types$ClassInfoType.scala$tools$nsc$symtab$Types$ClassInfoType$$propagate(Types.scala:1316) [INFO] at scala.tools.nsc.symtab.Types$ClassInfoType$$anonfun$scala$tools$nsc$symtab$Types$ClassInfoType$$propagate$1$$anonfun$apply$3.apply(Types.scala:1312) [INFO] at scala.tools.nsc.symtab.Types$ClassInfoType$$anonfun$scala$tools$nsc$symtab$Types$ClassInfoType$$propagate$1$$anonfun$apply$3.apply(Types.scala:1309) [INFO] at scala.Iterator$class.foreach(Iterator.scala:414) [INFO] at scala.runtime.BoxedArray$AnyIterator.foreach(BoxedArray.scala:45) [INFO] at scala.Iterable$class.foreach(Iterable.scala:256) [INFO] at scala.collection.immutable.Set3.foreach(Set3.scala:20) [INFO] at scala.tools.nsc.symtab.Types$ClassInfoType$$anonfun$scala$tools$nsc$symtab$Types$ClassInfoType$$propagate$1.apply(Types.scala:1309) [INFO] at scala.tools.nsc.symtab.Types$ClassInfoType$$anonfun$scala$tools$nsc$symtab$Types$ClassInfoType$$propagate$1.apply(Types.scala:1308) [INFO] at scala.Iterator$class.foreach(Iterator.scala:414) [INFO] at scala.Iterator$$anon$7.foreach(Iterator.scala:36) [INFO] at scala.tools.nsc.symtab.Types$ClassInfoType.scala$tools$nsc$symtab$Types$ClassInfoType$$propagate(Types.scala:1308) [INFO] at scala.tools.nsc.symtab.Types$ClassInfoType$$anonfun$scala$tools$nsc$symtab$Types$ClassInfoType$$propagate$1$$anonfun$apply$3.apply(Types.scala:1312) [INFO] at scala.tools.nsc.symtab.Types$ClassInfoType$$anonfun$scala$tools$nsc$symtab$Types$ClassInfoType$$propagate$1$$anonfun$apply$3.apply(Types.scala:1309) [INFO] at scala.Iterator$class.foreach(Iterator.scala:414) [INFO] at scala.collection.mutable.ResizableArray$$anon$1.foreach(ResizableArray.scala:66) [INFO] at scala.Iterable$class.foreach(Iterable.scala:256) [INFO] at scala.collection.immutable.HashSet.foreach(HashSet.scala:39) [INFO] at scala.tools.nsc.symtab.Types$ClassInfoType$$anonfun$scala$tools$nsc$symtab$Types$ClassInfoType$$propagate$1.apply(Types.scala:1309) [INFO] at scala.tools.nsc.symtab.Types$ClassInfoType$$anonfun$scala$tools$nsc$symtab$Types$ClassInfoType$$propagate$1.apply(Types.scala:1308) [INFO] at scala.Iterator$class.foreach(Iterator.scala:414) [INFO] at scala.Iterator$$anon$7.foreach(Iterator.scala:36) [INFO] at scala.tools.nsc.symtab.Types$ClassInfoType.scala$tools$nsc$symtab$Types$ClassInfoType$$propagate(Types.scala:1308) [INFO] at scala.tools.nsc.symtab.Types$ClassInfoType.expansiveRefs(Types.scala:1223) [INFO] at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$checkFinitary$1.apply(Typers.scala:1059) [INFO] at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$checkFinitary$1.apply(Typers.scala:1058) [INFO] at scala.List.foreach(List.scala:841) [INFO] at scala.tools.nsc.typechecker.Typers$Typer.checkFinitary(Typers.scala:1058) [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1216) [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1090) [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3088) [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:3358) [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3106) [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:3358) [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:3395) [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:1598) [INFO] at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$19.apply(Typers.scala:1643) [INFO] at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$19.apply(Typers.scala:1643) [INFO] at scala.List$.loop$1(List.scala:300) [INFO] at scala.List$.mapConserve(List.scala:317) [INFO] at scala.List$.loop$1(List.scala:304) [INFO] at scala.List$.mapConserve(List.scala:317) [INFO] at scala.List$.loop$1(List.scala:304) [INFO] at scala.List$.mapConserve(List.scala:317) [INFO] at scala.List$.loop$1(List.scala:304) [INFO] at scala.List$.mapConserve(List.scala:317) [INFO] at scala.List$.loop$1(List.scala:304) [INFO] at scala.List$.mapConserve(List.scala:317) [INFO] at scala.List$.loop$1(List.scala:304) [INFO] at scala.List$.mapConserve(List.scala:317) [INFO] at scala.List$.loop$1(List.scala:304) [INFO] at scala.List$.mapConserve(List.scala:317) [INFO] at scala.List$.loop$1(List.scala:304) [INFO] at scala.List$.mapConserve(List.scala:317) [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:1643) [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3084) [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:3358) [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:3395) [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:1598) [INFO] at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$19.apply(Typers.scala:1643) [INFO] at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$19.apply(Typers.scala:1643) [INFO] at scala.List$.loop$1(List.scala:300) [INFO] at scala.List$.mapConserve(List.scala:317) [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:1643) [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3084) [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:3358) [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:3395) [INFO] at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$2.apply(Analyzer.scala:41) [INFO] at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:267) [INFO] at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:246) [INFO] at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:246) [INFO] at scala.Iterator$class.foreach(Iterator.scala:414) [INFO] at scala.collection.mutable.ListBuffer$$anon$1.foreach(ListBuffer.scala:266) [INFO] at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:246) [INFO] at scala.tools.nsc.Global$Run.compileSources(Global.scala:574) [INFO] at scala.tools.nsc.Global$Run.compile(Global.scala:667) [INFO] at scala.tools.nsc.Main$.process(Main.scala:73) [INFO] at scala.tools.nsc.Main$.main(Main.scala:87) [INFO] at scala.tools.nsc.Main.main(Main.scala) [INFO] ... 6 more [INFO] prepare-compile in 0 s [INFO] compile in 6 s [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 11 seconds [INFO] Finished at: Mon Jan 04 11:16:04 EST 2010 [INFO] Final Memory: 18M/33M [INFO] ------------------------------------------------------------------------

davidB commented 14 years ago

I'll take a look. But the error seems to come from scalac (NPE come from deep internal). Could you call maven with -Dmaven.scala.displayCmd=true and rerun the displayed command (and see if there is the same error).

Could you post the working command line used when compiling manually ?

riedelcastro commented 14 years ago

With -Dmaven.scala.displayCmd=true I get

[INFO] cmd: /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/bin/java -classpath /Users/riedel/.m2/repository/org/scala-lang/scala-compiler/2.7.7/scala-compiler-2.7.7.jar:/Users/riedel/.m2/repository/org/scala-lang/scala-library/2.7.7/scala-library-2.7.7.jar:/Users/riedel/.m2/repository/org/scala-tools/maven-scala-plugin/2.13.1/maven-scala-plugin-2.13.1.jar -Xbootclasspath/a:/Users/riedel/.m2/repository/org/scala-lang/scala-library/2.7.7/scala-library-2.7.7.jar -Xmx265m org_scala_tools_maven_executions.MainWithArgsInFile scala.tools.nsc.Main /private/var/folders/H7/H7mrfvChEVaw5cyLOm4OKU+++TM/-Tmp-/scala-maven-7903460368784389989.args

"Manual compiling" was with Intellij---I will try to extract the command line from that, or just make my own, and then get back to you. Thanks a lot!

riedelcastro commented 14 years ago

Ah, as you expected, this actually looks like a scala compiler bug! The problem is the order in which the files to compile are passed to the scalac compiler in the args file. It turned out that scalac produces the same error when called directly, and using the order of files that maven generated (sorted alphabetically).

After changing the relative order of some files it actually compiles fine! I think there is some cyclic dependency between some files that causes trouble for the type inference implementation.

Anyhow, this is not related to maven scala---sorry for posting it here. I will close this issue now.

jsuereth commented 14 years ago

Ok, I'm closing this now