Play Framework is hiding the intial exception - scala

I'm getting this error from Play after implementing a controller. If I throw in a try to catch and println the error, I can see what exception was thrown by my code, but otherwise this information is missing and I get an error relating to files in SBT instead.
What is going on during the handling of my exception that is causing this other exception?
I'm running my application with sbt api/run.
[info] p.c.s.AkkaHttpServer - Listening for HTTP on /[0:0:0:0:0:0:0:0]:9000
(Server started, use Enter to stop and go back to the console...)
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/Users/dan/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/google/inject/guice/4.2.3/guice-4.2.3.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2020-10-15 00:55:32 INFO play.api.http.EnabledFilters Enabled Filters (see <https://www.playframework.com/documentation/latest/Filters>):
play.filters.csrf.CSRFFilter
play.filters.headers.SecurityHeadersFilter
play.filters.hosts.AllowedHostsFilter
play.filters.cors.CORSFilter
2020-10-15 00:55:32 INFO play.api.Play Application started (Dev) (no global state)
2020-10-15 00:55:32 ERROR p.api.http.DefaultHttpErrorHandler Error while handling error
java.lang.ClassCastException: class xsbti.BasicVirtualFileRef cannot be cast to class java.io.File (xsbti.BasicVirtualFileRef is in unnamed module of loader sbt.internal.MetaBuildLoader #6e75aa0d; java.io.File is in module java.base of loader 'bootstrap')
at play.sbt.run.PlayReload$.$anonfun$sourceMap$1(PlayReload.scala:69)
at scala.collection.MapLike$MappedValues.get(MapLike.scala:260)
at play.runsupport.Reloader.$anonfun$findSource$1(Reloader.scala:547)
at scala.Option.flatMap(Option.scala:271)
at play.runsupport.Reloader.findSource(Reloader.scala:546)
at play.core.server.DevServerStart$$anon$1$$anon$2.sourceOf(DevServerStart.scala:171)
at play.core.SourceMapper.$anonfun$sourceFor$1(ApplicationProvider.scala:21)
at play.core.SourceMapper.$anonfun$sourceFor$1$adapted(ApplicationProvider.scala:21)
at scala.collection.ArrayOps$.find$extension(ArrayOps.scala:684)
at play.core.SourceMapper.sourceFor(ApplicationProvider.scala:21)
at play.core.SourceMapper.sourceFor$(ApplicationProvider.scala:20)
at play.core.server.DevServerStart$$anon$1$$anon$2.sourceFor(DevServerStart.scala:169)
at play.api.http.HttpErrorHandlerExceptions$.$anonfun$throwableToUsefulException$1(HttpErrorHandler.scala:358)
at scala.Option.flatMap(Option.scala:283)
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:358)
at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:261)
at play.filters.cors.AbstractCORSPolicy$$anonfun$1.applyOrElse(AbstractCORSPolicy.scala:128)
at play.filters.cors.AbstractCORSPolicy$$anonfun$1.applyOrElse(AbstractCORSPolicy.scala:126)
at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:453)
at play.api.libs.streams.Execution$trampoline$.execute(Execution.scala:70)
at scala.concurrent.impl.Promise$Transformation.submitWithValue(Promise.scala:392)
at scala.concurrent.impl.Promise$DefaultPromise.submitWithValue(Promise.scala:302)
at scala.concurrent.impl.Promise$DefaultPromise.tryComplete0(Promise.scala:249)
at scala.concurrent.impl.Promise$Transformation.handleFailure(Promise.scala:407)
at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:469)
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:56)
at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:93)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:94)
at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:93)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:48)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:48)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)

It was an incompatibility between play and sbt, and has been fixed:
https://github.com/playframework/playframework/issues/10486

You end up with this error when an exception happens during handling the server error in the default or custom Play error handler. See play.api.http.HttpErrorHandler.

Related

Fatal Exception: java.lang.RuntimeException: Unable to destroy activity {com.example.app.MainActivity}: java.lang.IllegalArgumentException:

My flutter application keeps on crashing and logging this error on firebase crash analytics
Fatal Exception: java.lang.RuntimeException: Unable to destroy activity {com.aims.covidsurvey/com.example.app.MainActivity}: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter activity
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4463)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4482)
at android.app.ActivityThread.-wrap6(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1640)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6617)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
Have tried to debug the app, am not getting much information what is causing the error, anyone know what could be causing this and how to fix it? Have tried to research am not getting much information
the Kotlin code generated by the app
package com.example.app
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
And another crash error
Caused by java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter activity
at com.lyokone.location.FlutterLocationService.setActivity(FlutterLocationService.kt)
at com.lyokone.location.LocationPlugin.deinitialize(LocationPlugin.java:121)
at com.lyokone.location.LocationPlugin.detachActivity(LocationPlugin.java:56)
at com.lyokone.location.LocationPlugin.onDetachedFromActivity(LocationPlugin.java:69)
at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.detachFromActivity(FlutterEngineConnectionRegistry.java:389)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onDetach(FlutterActivityAndFragmentDelegate.java:556)
at io.flutter.embedding.android.FlutterActivity.release(FlutterActivity.java:587)
at io.flutter.embedding.android.FlutterActivity.onDestroy(FlutterActivity.java:608)
at android.app.Activity.performDestroy(Activity.java:7136)
at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1158)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4450)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4482)
at android.app.ActivityThread.-wrap6(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1640)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6617)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
My solution was to change the component location to geolocator
https://pub.dev/packages/geolocator

How to fix "Exception in thread "main" java.lang.ExceptionInInitializerError" [duplicate]

This question already has answers here:
Apache Spark and Java error - Caused by: java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length 2
(3 answers)
Closed 3 years ago.
I'm using Intellij to develop my Spark app using the Scala language. While running the code this error is throwing in the terminal.
My Scala version in built.sbt is 2.11.8.
My Java version is 1.8.0_231
I tried downgrading my Java version from 13 to Java 8.
19/11/02 09:31:25 INFO SparkContext: Running Spark version 2.2.0
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.hadoop.security.authentication.util.KerberosUtil (file:/C:/Users/iraja/AppData/Local/Coursier/cache/v1/https/repo1.maven.org/maven2/org/apache/hadoop/hadoop-auth/2.6.5/hadoop-auth-2.6.5.jar) to method sun.security.krb5.Config.getInstance()
WARNING: Please consider reporting this to the maintainers of org.apache.hadoop.security.authentication.util.KerberosUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
19/11/02 09:31:26 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.apache.hadoop.util.StringUtils.<clinit>(StringUtils.java:79)
at org.apache.hadoop.security.Groups.parseStaticMapping(Groups.java:116)
at org.apache.hadoop.security.Groups.<init>(Groups.java:93)
at org.apache.hadoop.security.Groups.<init>(Groups.java:73)
at org.apache.hadoop.security.Groups.getUserToGroupsMappingService(Groups.java:293)
at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:283)
at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:260)
at org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:789)
at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:774)
at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:647)
at org.apache.spark.util.Utils$$anonfun$getCurrentUserName$1.apply(Utils.scala:2430)
at org.apache.spark.util.Utils$$anonfun$getCurrentUserName$1.apply(Utils.scala:2430)
at scala.Option.getOrElse(Option.scala:121)
at org.apache.spark.util.Utils$.getCurrentUserName(Utils.scala:2430)
at org.apache.spark.SparkContext.<init>(SparkContext.scala:295)
at sparkrdd.RDDTempData$.main(RDDTempData.scala:9)
at sparkrdd.RDDTempData.main(RDDTempData.scala)
Caused by: java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length 2
at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3720)
at java.base/java.lang.String.substring(String.java:1909)
at org.apache.hadoop.util.Shell.<clinit>(Shell.java:50)
... 17 more
Process finished with exit code 1
This is a Hadoop issue that fails to parse some java.version. It has been fixed from Hadoop-2.7.4
https://issues.apache.org/jira/browse/SPARK-26134

Scala Play Framework: Header doesn't exists

I am trying to run play application and it runs correctly. However, while serving to few APIs, I get following error:
[error] play - Cannot invoke the action, eventually got an error: java.lang.RuntimeException: Header doesn't exist
[error] application -
! #714mk098l - Internal server error, for (POST) [/ivi/customer/login/] ->
play.api.Application$$anon$1: Execution exception[[RuntimeException: Header doesn't exist]]
at play.api.Application$class.handleError(Application.scala:296) ~[play_2.10-2.3.9.jar:2.3.9]
at play.api.DefaultApplication.handleError(Application.scala:402) [play_2.10-2.3.9.jar:2.3.9]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.10-2.3.9.jar:2.3.9]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.10-2.3.9.jar:2.3.9]
at scala.Option.map(Option.scala:145) [scala-library-2.10.5.jar:na]
Caused by: java.lang.RuntimeException: Header doesn't exist
at scala.sys.package$.error(package.scala:27) ~[scala-library-2.10.5.jar:na]
at play.api.mvc.Headers$$anonfun$apply$10.apply(Http.scala:338) ~[play_2.10-2.3.9.jar:2.3.9]
at play.api.mvc.Headers$$anonfun$apply$10.apply(Http.scala:338) ~[play_2.10-2.3.9.jar:2.3.9]
at scala.Option.getOrElse(Option.scala:120) [scala-library-2.10.5.jar:na]
at play.api.mvc.Headers$class.apply(Http.scala:338) ~[play_2.10-2.3.9.jar:2.3.9]
I feel like this should related to configuration rather than code issue. Can someone please guide here?

Eclipse: com.google.maps.android.utils.demo linking fails

I have been strugling with integration of google maps utiliy
https://developers.google.com/maps/documentation/android/utility/marker-clustering.
I use ADT (Eclipse) and is able to compile and 'almost' launch it as an Android application. But crashes during startup.
This is what I get from LogCat
02-22 09:49:05.386: I/dalvikvm(13953): Failed resolving Lcom/google/maps/android/utils/demo/CustomMarkerClusteringDemoActivity; interface 2305 'Lcom/google/maps/android/clustering/ClusterManager$OnClusterClickListener;'
02-22 09:49:05.386: W/dalvikvm(13953): Link of class 'Lcom/google/maps/android/utils/demo/CustomMarkerClusteringDemoActivity;' failed
02-22 09:49:05.386: E/dalvikvm(13953): Could not find class 'com.google.maps.android.utils.demo.CustomMarkerClusteringDemoActivity', referenced from method com.google.maps.android.utils.demo.MainActivity.onCreate
02-22 09:49:05.386: W/dalvikvm(13953): VFY: unable to resolve const-class 2324 (Lcom/google/maps/android/utils/demo/CustomMarkerClusteringDemoActivity;) in Lcom/google/maps/android/utils/demo/MainActivity;
02-22 09:49:05.386: D/dalvikvm(13953): VFY: replacing opcode 0x1c at 0x001d
02-22 09:49:05.486: D/AndroidRuntime(13953): Shutting down VM
02-22 09:49:05.486: W/dalvikvm(13953): threadid=1: thread exiting with uncaught exception (group=0x41926898)
02-22 09:49:05.486: E/AndroidRuntime(13953): FATAL EXCEPTION: main
02-22 09:49:05.486: E/AndroidRuntime(13953): java.lang.NoClassDefFoundError: com.google.maps.android.utils.demo.CustomMarkerClusteringDemoActivity
02-22 09:49:05.486: E/AndroidRuntime(13953): at com.google.maps.android.utils.demo.MainActivity.onCreate(MainActivity.java:21)
Anybody have experienced similar problem?
Regards OFK

What is a Boxed Error in Scala?

When I run my application, the browser shows
[ExecutionException: Boxed Error]
It doesn't say anything about the line number, etc.
In the console, I have the following
! #6elaah0c8 - Internal server error, for (GET) [/testlearn] ->
play.api.Application$$anon$1: Execution exception[[ExecutionException: Boxed Error]]
at play.api.Application$class.handleError(Application.scala:289) ~[play_2.10.jar:2.1.1]
at play.api.DefaultApplication.handleError(Application.scala:383) [play_2.10.jar:2.1.1]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$17$$anonfun$apply$24.apply(PlayDefaultUpstreamHandler.scala:326) [play_2.10.jar:2.1.1]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$17$$anonfun$apply$24.apply(PlayDefaultUpstreamHandler.scala:324) [play_2.10.jar:2.1.1]
at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10.jar:2.1.1]
at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10.jar:2.1.1]
java.util.concurrent.ExecutionException: Boxed Error
at scala.concurrent.impl.Promise$.resolver(Promise.scala:52) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
at scala.concurrent.impl.Promise$.scala$concurrent$impl$Promise$$resolveTry(Promise.scala:44) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:116) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
at scala.concurrent.Promise$class.complete(Promise.scala:55) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
at scala.concurrent.impl.Promise$DefaultPromise.complete(Promise.scala:58) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:23) [factorie-1.0.0-M4-jar-with-dependencies.jar:na]
Caused by: java.lang.AssertionError: assertion failed
at scala.Predef$.assert(Predef.scala:165) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
at cc.factorie.util.TraversableExtras$class.max2ByDouble(TraversableExtras.scala:95) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
at cc.factorie.package$$anon$2.max2ByDouble(package.scala:148) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
at cc.factorie.optimize.SampleRankExample.accumulateExampleInto(SampleRank.scala:31) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
at cc.factorie.optimize.OnlineTrainer$$anonfun$processExamples$3.apply(Trainer.scala:72) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
at cc.factorie.optimize.OnlineTrainer$$anonfun$processExamples$3.apply(Trainer.scala:63) ~[factorie-1.0.0-M4-jar-with-dependencies.jar:na]
"Boxed Error" is Scala's response to an Error being thrown within a Future. In Java, and hence Scala, subclasses of type Error have a special meaning as Fatal errors. See Differences between Exception and Error. In short, the javadoc says:
An Error is a subclass of Throwable that indicates serious problems
that a reasonable application should not try to catch. Most such
errors are abnormal conditions.
Unlike throwing other Throwables within a future, when a subclass of Error is thrown, the default Scala resolver will wrap up the Error in a java.util.concurrent.ExecutionException, with the message string "Boxed Error", and complete your promise with a failure.
To quote the futures documentation http://docs.scala-lang.org/overviews/core/futures.html w.r.t. Error being thrown:
[Error] exceptions are rethrown in the thread executing the failed
asynchronous computation. The rationale behind this is to prevent
propagation of critical and control-flow related exceptions normally
not handled by the client code and at the same time inform the client
in which future the computation failed.
If you want to do something special with the Failure, the original Error that was thrown can be extracted (but not in a way particularly amenable to pattern matching), by ExecutionException#getCause()
I don't know that's a Boxed Error, but according to your stacktrace, the root problem comes from the factorie lib, from the max2Double method at line 95.
Extract from the source code:
/**Returns both the maximum element and the second-to-max element */
def max2ByDouble(extractor: A => Double): (A, A) = {
val s1 = t.toSeq
assert(s1.length > 1) // <<<== HERE
var best1 = Double.NegativeInfinity
...
It seems that your Traversable is empty.