jeudi 13 août 2020

java.lang.reflect.InvocationTargetException: null in Scala

java.lang.reflect.InvocationTargetException: null
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.$anonfun$compile$11(ToolBoxFactory.scala:290)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl.eval(ToolBoxFactory.scala:459)
"org.scala-lang" % "scala-compiler" % "2.12.8",
scalaVersion := "2.12.8"
sbt.version = 1.2.8
import scala.reflect.runtime.currentMirror
import scala.tools.reflect.ToolBox

Can anyone please help me on that

ConfigValueGet = "x+4"
evenvalue = 85.1

eventValue is like Some(85.1) but at this time it become 85.1

val evaluate: Double = toolbox.eval(toolbox.parse(configValueGet.toLowerCase.replac‌​eAll("x", eventValue.get.toString))).toString.toDouble
//Caused by: java.lang.AbstractMethodError: 'java.lang.Object __wrapper$1$f572036f23d646a2b29c6cf5679c65e2.__wrapper$1$f572036f23d646a2b29c6cf5679c65e2$.wrapper()'

val eventValue = (event \ "event" \ "value").extractOpt[Double]
var value: JValue = event
val configValue = (event \ "sensor" \ "configFunction").extractOpt[String]
if (configValue.toString.length >= 1 && !(configValue.toString.contains("None"))) {
  val configValueGet = configValue.get
  val toolbox = currentMirror.mkToolBox()
  val evaluate:Double = toolbox.eval(toolbox.parse(configValueGet.toLowerCase.replaceAll("x", eventValue.get.toString))).toString.toDouble
  value = "event" -> ("value" -> evaluate.toDouble)
}





Aucun commentaire:

Enregistrer un commentaire