When I try to compile my project I get the following exception:
! Internal server error, for request [GET /] ->
play.api.UnexpectedException: Unexpected exception [StackOverflowError: null]
at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$4$$anonfun$apply$12.apply(PlayReloader.scala:233) ~[na:na]
at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$4$$anonfun$apply$12.apply(PlayReloader.scala:226) ~[na:na]
at scala.Option.map(Option.scala:133) ~[scala-library.jar:0.11.3]
at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$4.apply(PlayReloader.scala:226) ~[na:na]
at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$4.apply(PlayReloader.scala:224) ~[na:na]
at scala.Either$LeftProjection.map(Either.scala:183) ~[scala-library.jar:0.11.3]
java.lang.StackOverflowError: null
at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:731) ~[scala-compiler.jar:na]
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4271) ~[scala-compiler.jar:na]
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4138) ~[scala-compiler.jar:na]
at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:731) ~[scala-compiler.jar:na]
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4271) ~[scala-compiler.jar:na]
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$typedApply$1$1.apply(Typers.scala:3353) ~[scala-compiler.jar:na]
I found the same issue in the Play 2 issue tracker and they said that when the routes file grows it makes that exception.
Is there a solution to this exception because my project doesn't compile anymore ?
I'm using Play 2.0.3 for scala(my routes file is about 150 line)
I had the same issue with Play 2.0.6. Upgraded to Play 2.0.8 and it didn't help. I then modified the $play_dir/framework/build script so it builds with -Xss2M instead of -Xss1M and the problem disappeared (I can compile normally now).
There is a bug with play 2.0 having to do with the size of the routes file, not in terms of the number of routes but rather the physical size of the file (32768 bytes). It seems that this cieling has increased for 2.0.4 and is eliminated with 2.1.
https://groups.google.com/forum/?fromgroups=#!topic/play-framework/fZvgWJoCPLc
So, first, I would take a look at the physical size of the routes file. It may be possible cut out comments and/or eliminate commented-out lines. Next, I would try upgrading to version 2.0.4. That is a fairly easy process. You just need to download 2.0.4, point play to this new path, and update the /project/plugins.sbt of the project to read:
// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.0.4")
A more long-term fix may be to upgrade your project to 2.1 once it becomes stable.
Related
SBT:
[error] download error: Caught java.net.SocketException: Connection reset (Connection reset) while downloading
for example on **sbt-plugin**
https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.typesafe.play/sbt-plugi
n/scala_2.12/sbt_1.0/2.8.2/ivys/ivy.xml
But ivy.xml exists.
It happens for example on play-samples-2.8.x, with Scala 2.13.1, Play 2.8.2, SBT 1.3.8
Tkank you in advance, Marcin
I think this not a Scala, sbt or play framework related problem, but probably what the Java runtime reports. A glitch in the connection, somehow a change in your ip-address etc. Certainly Java runtime environment, connection or hardware.
Proszę dziękuję.
I have created a new play framework app in SCALA. If i run the application it runs as expected and i am able to open the URL localhost:9000, but after i created a lib folder and added some jars(spark jars) in that when i tries to run the application using the command play run, it shows the message
[error] p.nettyException - Exception caught in Netty
java.lang.NoSuchMethodError: scala.collection.immutable.HashSet$.empty()Lscala/collection/immutable/HashSet;
at akka.actor.ActorCell$.<init>(ActorCell.scala:305) ~[akka-actor_2.10.jar:2.2.0]
at akka.actor.ActorCell$.<clinit>(ActorCell.scala) ~[akka-actor_2.10.jar:2.2.0]
at akka.actor.RootActorPath.$div(ActorPath.scala:152) ~[akka-actor_2.10.jar:2.2.0]
at akka.actor.LocalActorRefProvider.<init>(ActorRefProvider.scala:465) ~[akka-actor_2.10.jar:2.2.0]
at akka.actor.LocalActorRefProvider.<init>(ActorRefProvider.scala:453) ~[akka-actor_2.10.jar:2.2.0]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_91]
[error] p.nettyException - Exception caught in Netty
java.lang.NoClassDefFoundError: Could not initialize class play.api.libs.concurrent.Execution$
when i tries to open the URL localhost:9000 it shows "localhost page is not working".
Spark Version 2.0
Scala Version 2.10 and also i have tested with scala 2.11 and 2.12 same error reproducing.
Play framework version - 2.2.6
First, if you created a new Play! project, why use version 2.2? The newest one is 2.5 and that may already fix your issue.
Second, to ensure you don't have any other version conflicts I suggest you use managed dependencies instead of putting them manually into the lib folder.
For Apache Spark, you would add this line to your build.sbt file:
libraryDependencies += "org.apache.spark" %% "spark-core" % "2.1.0"
as described in Spark's Quick Start Guide. You need to use Scala 2.10 or 2.11 (suggested) in your project.
If that doesn't resolve your issue, please post the contents of your build.sbt and the controller code. Thanks.
I'm having some problems getting my Scala tests running via the Intelli-J Run/Debug configuration. The tests are working if I run them directly in the SBT console.
My configuration looks like this:
I'm getting this error in the Run console panel:
java.lang.IllegalArgumentException: ERROR: -r has been deprecated for a very long time and is no longer supported, to prepare for reusing it for a different purpose in the near future. Please change all uses of -r to -C.
at org.scalatest.tools.ArgsParser$.checkArgsForValidity(ArgsParser.scala:41)
at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:857)
at org.scalatest.tools.Runner$.run(Runner.scala:850)
at org.scalatest.tools.Runner.run(Runner.scala)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2(ScalaTestRunner.java:141)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
I've checked my plugins are all up-to-date. Do I need to use a particular version of Scala? Or is there some additional setup I'm missing?
For anyone who has this problem even with newer version of IntelliJ, here is how I went about figuring out where the issue was. I pulled in the scalatest dependency at the top of the pom for the module I was trying to run tests in. Then an individual test would run without this error. I moved the dependency down the pom until the problem recurred to figure out which dependency was causing the problem. Then I found that the dependency had some really old dependencies including an older version of scalatest that weren't showing up in my dependency tree. Also, this jar dependency had scalatest as a dependency not marked with scope test.
It appears to have been a problem with the Scala plugin under Intelli-J 13.
I fixed this by upgrading to Intelli-J 2016.3, which I presume has been changed to pass the newer -C switch to ScalaTestRunner.
#JasonF pointed out in his comment below that a project dependency can also cause a problem with the scalatest plugin (this was the case for him). It's worth attempting to run the tests of a fresh sample Scala project to test for this scenario before upgrading the IDE.
I am currently building a Play Framework application in Scala that requires the use of the Gephi Java library.
I tried adding Gephi as a managed dependency in SBT, but SBT cannot resolve all of Gephi's dependencies. This is a known issue. I then simply tried to add the whole Gephi JAR in my lib/ folder as an unmanaged dependency. IntelliJ detects the library just fine and I can compile my application perfectly fine. The problem is an exception occurs immediately upon starting the application, and it seems to be related to dependency injection:
play.api.UnexpectedException: Unexpected exception[NoSuchMethodError: com.google.common.base.Objects.firstNonNull(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;]
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:174)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:126)
at scala.Option.map(Option.scala:146)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:126)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:124)
at scala.util.Success.flatMap(Try.scala:231)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:124)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:116)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
Caused by: java.lang.NoSuchMethodError: com.google.common.base.Objects.firstNonNull(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
at com.google.common.cache.CacheBuilder.getKeyStrength(CacheBuilder.java:529)
at com.google.common.cache.LocalCache.<init>(LocalCache.java:242)
at com.google.common.cache.LocalCache$LocalManualCache.<init>(LocalCache.java:4718)
at com.google.common.cache.CacheBuilder.build(CacheBuilder.java:807)
at com.google.inject.internal.WeakKeySet.<init>(WeakKeySet.java:55)
at com.google.inject.internal.InheritingState.<init>(InheritingState.java:67)
at com.google.inject.internal.InjectorShell$Builder.getState(InjectorShell.java:209)
at com.google.inject.internal.InjectorShell$Builder.lock(InjectorShell.java:115)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
at com.google.inject.Guice.createInjector(Guice.java:96)
I tried removing all mention of Gephi in the code, while still having the JAR sitting in my lib/ folder, but it results in the same exception.
Gephi is really important for this project, so I can't just move on to another library. Any ideas?
Remove that jar fom lib, add those two additional resolvers (in build.sbt)
resolvers += "NetBeans" at "http://bits.netbeans.org/nexus/content/groups/netbeans/"
resolvers += "gephi" at "https://raw.github.com/gephi/gephi/mvn-thirdparty-repo/"
and run activator update
I'm trying to run tests for an sbt-based Scala application in intellij. But I get the following error which I'm not sure how to fix:
Testing started at 21:07 ...
java.lang.IncompatibleClassChangeError: Found class scala.collection.mutable.ArrayOps, but interface was expected
at org.scalatest.tools.Runner$.checkArgsForValidity(Runner.scala:895)
at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:729)
at org.scalatest.tools.Runner$.run(Runner.scala:711)
at org.scalatest.tools.Runner.run(Runner.scala)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2(ScalaTestRunner.java:144)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
When I decorate my classes with the Junit runner attribute they work fine (and it's actually a much better run in terms of the visuals):
#RunWith(classOf[JUnitRunner])
I got the same error when trying to run tests for my Play Framework app. Drilling down into the stack trace, I found that the problem class was FakeRequest, which is in the play-test library. I had two different versions of the library, one for Play 2.4 and one for 2.3. I was able to resolve this issue by removing the play-test version for Play 2.3 (open Module Settings -> Libraries -> find and delete the bad dependency).
Your issue is probably with some other problematic dependency, but following the same steps as above may help fix it.
This seems to be a problem with scala test runner framework. I had come across the same problem; eventually like you suggested end up using junit test runner to make it work. But the problem in my case was it was pulling in a transitive dependency and no such class error.
Make sure the libraries what you are using for the JUnitRunner are same. Most of the times “Incompatible Class Change Error” occurs because of backward compatibility. And also have a look at scala library jar at the time of compiling and running.