Unable to run the main method - scala

I am currently working on a system where staff members in an organization can be informed regarding their pending tasks to be completed by their managers via devices. This is demonstrated via the following classes:
Staff
Manager (Extends Staff)
Device (Receives tasks and removes them once completed)
Task
System (Assigns tasks)
Main
I am currently stuck at a point where I am unable to determine why I cannot run my classes, as I receive a non-zero exit code of 1.
The problem currently seems to lie within the Main.scala file, at the moment:
object Main {
def main(args: Array[String]): Unit = {
var system = new System
var s1 = new Staff(1, "John", "johndoe#outlook.com", "Brazil")
system.addStaff(s1)
var s2 = new Manager(2, "Reese", "reesecups#gmail.com", "Japan")
system.addStaff(s2)
s2.assignTask(system, 1, "PLEASE WORK")
}
}
The code used to run as intended, however when I added the following line to the Main.scala file:
s2.assignTask(system, 1, "PLEASE WORK")
I received the following error:
[error] java.lang.RuntimeException: No main class detected.
[error] at scala.sys.package$.error(package.scala:30)
[error] at sbt.Defaults$.$anonfun$bgRunTask$4(Defaults.scala:1477)
[error] at scala.Option.getOrElse(Option.scala:189)
[error] at sbt.Defaults$.$anonfun$bgRunTask$3(Defaults.scala:1477)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] at sbt.std.Transform$$anon$4.work(Transform.scala:67)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:281)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19)
[error] at sbt.Execute.work(Execute.scala:290)
[error] at sbt.Execute.$anonfun$submit$1(Execute.scala:281)
[error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error] at java.util.concurrent.FutureTask.run(Unknown Source)
[error] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
[error] at java.util.concurrent.FutureTask.run(Unknown Source)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
[error] at java.lang.Thread.run(Unknown Source)
[error] (Compile / bgRun) No main class detected.
Is there any indication to what the problem may be?

Related

com.typesafe.config.ConfigException$WrongType: system properties: path has type OBJECT rather than STRING

when i try to sbt build :
sbt run -Dhttps.port=9443 -Dhttp.port=disabled -Dhttps.keyStore.type="JKS" -Dhttps.keyStore.password="password" -Dhttps.keyStore.path=/cert/https-example.jks
it shows error :
--- (Running the application, auto-reloading is enabled) ---
[error] p.c.s.AkkaHttpServer - Cannot load SSL context
java.lang.reflect.InvocationTargetException: null
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at play.core.server.ssl.ServerSSLEngine$.createScalaSSLEngineProvider(ServerSSLEngine.scala:116)
at play.core.server.ssl.ServerSSLEngine$.createSSLEngineProvider(ServerSSLEngine.scala:39)
at play.core.server.AkkaHttpServer.sslContext$lzycompute(AkkaHttpServer.scala:245)
at play.core.server.AkkaHttpServer.sslContext(AkkaHttpServer.scala:244)
at play.core.server.AkkaHttpServer.$anonfun$httpsServerBinding$1(AkkaHttpServer.scala:260)
at play.core.server.AkkaHttpServer.$anonfun$httpsServerBinding$1$adapted(AkkaHttpServer.scala:255)
Caused by: com.typesafe.config.ConfigException$WrongType: system properties: path has type OBJECT rather than STRING
at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:164)
at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:175)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:189)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:194)
at com.typesafe.config.impl.SimpleConfig.getString(SimpleConfig.java:251)
at play.core.server.ssl.DefaultSSLEngineProvider.createSSLContext(DefaultSSLEngineProvider.scala:37)
at play.core.server.ssl.DefaultSSLEngineProvider.<init>(DefaultSSLEngineProvider.scala:30)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[info] p.c.s.AkkaHttpServer - Listening for HTTPS on /0:0:0:0:0:0:0:0:9443
[error] com.typesafe.config.ConfigException$WrongType: system properties: path has type OBJECT rather than STRING
[error] at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:164)
[error] at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:175)
[error] at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:189)
[error] at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:194)
[error] at com.typesafe.config.impl.SimpleConfig.getString(SimpleConfig.java:251)
[error] at play.core.server.ssl.DefaultSSLEngineProvider.createSSLContext(DefaultSSLEngineProvider.scala:37)
[error] at play.core.server.ssl.DefaultSSLEngineProvider.<init>(DefaultSSLEngineProvider.scala:30)
[error] at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[error] at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[error] at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[error] at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
[error] at play.core.server.ssl.ServerSSLEngine$.createScalaSSLEngineProvider(ServerSSLEngine.scala:116)
[error] at play.core.server.ssl.ServerSSLEngine$.createSSLEngineProvider(ServerSSLEngine.scala:39)
[error] at play.core.server.AkkaHttpServer.sslContext$lzycompute(AkkaHttpServer.scala:245)
[error] at play.core.server.AkkaHttpServer.sslContext(AkkaHttpServer.scala:244)
[error] at play.core.server.AkkaHttpServer.$anonfun$Http1Encrypted$2(AkkaHttpServer.scala:530)
[error] at scala.Option.map(Option.scala:242)
[error] at play.core.server.AkkaHttpServer.Http1Encrypted$lzycompute(AkkaHttpServer.scala:522)
[error] at play.core.server.AkkaHttpServer.Http1Encrypted(AkkaHttpServer.scala:520)
[error] at play.core.server.AkkaHttpServer.<init>(AkkaHttpServer.scala:564)
[error] at play.core.server.AkkaHttpServerProvider.createServer(AkkaHttpServer.scala:665)
[error] at play.core.server.AkkaHttpServerProvider.createServer(AkkaHttpServer.scala:663)
[error] at play.core.server.DevServerStart$.$anonfun$mainDev$1(DevServerStart.scala:311)
[error] at play.utils.Threads$.withContextClassLoader(Threads.scala:22)
[error] at play.core.server.DevServerStart$.mainDev(DevServerStart.scala:76)
[error] at play.core.server.DevServerStart$.mainDevOnlyHttpsMode(DevServerStart.scala:40)
[error] at play.core.server.DevServerStart.mainDevOnlyHttpsMode(DevServerStart.scala)
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[error] at play.runsupport.Reloader$.startDevMode(Reloader.scala:311)
[error] at play.sbt.run.PlayRun$.devModeServer$lzycompute$1(PlayRun.scala:100)
[error] at play.sbt.run.PlayRun$.devModeServer$1(PlayRun.scala:83)
[error] at play.sbt.run.PlayRun$.$anonfun$playRunTask$3(PlayRun.scala:107)
[error] at play.sbt.run.PlayRun$.$anonfun$playRunTask$3$adapted(PlayRun.scala:67)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] stack trace is suppressed; run last Compile / run for the full output
[error] (Compile / run) java.lang.reflect.InvocationTargetException
[error] Total time: 5 s, completed 06-Apr-2022, 10:10:14 PM
[info] p.c.s.AkkaHttpServer - Stopping Akka HTTP server...
[info] p.c.s.AkkaHttpServer - Terminating server binding for /0:0:0:0:0:0:0:0:9443
[info] p.c.s.AkkaHttpServer - Running provided shutdown stop hooks
I tried what i know but i can't find the correct answer. if you know anything about it please help me..!. why it doesn't take the path? is I did anything wrong?
I've finally found the correct way to do this, i don't know why application.conf not working but adding the data in build.sbt helped me to solve this error.
PlayKeys.devSettings += "play.server.https.port" -> "9443"
PlayKeys.devSettings += "play.server.http.port" -> "disabled"
PlayKeys.devSettings += "play.server.https.keyStore.type" -> "JKS"
PlayKeys.devSettings += "play.server.https.keyStore.password" -> "password"
PlayKeys.devSettings += "play.server.https.keyStore.path" -> "https-example.jks"
The data added build.sbt so there is no need to add data in sbt run

java.lang.NoClassDefFoundError: org/vafer/jdeb/Console when starting intellij sbt project

Whenever I create a new simple project in Intellij, I always get stuck at this stage when the project loads the build.sbt file.
Here's the error:
/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java -Djline.terminal=jline.UnsupportedTerminal -Dsbt.log.noformat=true -Dfile.encoding=UTF-8 -Didea.managed=true -Dfile.encoding=UTF-8 -jar /home/giangvdq/.local/share/JetBrains/IdeaIC2020.2/Scala/launcher/sbt-launch.jar
[info] welcome to sbt 1.3.13 (Private Build Java 1.8.0_265)
[error] java.lang.NoClassDefFoundError: org/vafer/jdeb/Console
[error] Use 'last' for the full log.
Here's the build error message
Here's the full log file:
giangvdq#L0109-GiangVDQ:~/workspaces/fpt/untitled$ sbt compile
[info] welcome to sbt 1.3.13 (Ubuntu Java 11.0.8)
[error] java.lang.NoClassDefFoundError: org/vafer/jdeb/Console
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? r
[info] welcome to sbt 1.3.13 (Ubuntu Java 11.0.8)
[error] java.lang.NoClassDefFoundError: org/vafer/jdeb/Console
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? last
[debug] > Exec(reload, None, None)
[debug] > Exec(sbtStashOnFailure, None, None)
[debug] > Exec(onFailure loadFailed, None, None)
[debug] > Exec(loadp, None, None)
[info] welcome to sbt 1.3.13 (Ubuntu Java 11.0.8)
[error] java.lang.NoClassDefFoundError: org/vafer/jdeb/Console
[error] at java.base/java.lang.Class.forName0(Native Method)
[error] at java.base/java.lang.Class.forName(Class.java:398)
[error] at sbt.internal.inc.ModuleUtilities$.getObject(ModuleUtilities.scala:24)
[error] at sbt.internal.inc.ModuleUtilities$.getCheckedObject(ModuleUtilities.scala:32)
[error] at sbt.internal.inc.ModuleUtilities$.$anonfun$getCheckedObjects$1(ModuleUtilities.scala:37)
[error] at scala.collection.immutable.Stream.$anonfun$map$1(Stream.scala:418)
[error] at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1171)
[error] at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1161)
[error] at scala.collection.generic.Growable.loop$1(Growable.scala:57)
[error] at scala.collection.generic.Growable.$plus$plus$eq(Growable.scala:61)
[error] at scala.collection.generic.Growable.$plus$plus$eq$(Growable.scala:53)
[error] at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:184)
[error] at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:47)
[error] at scala.collection.TraversableLike.$plus$plus(TraversableLike.scala:151)
[error] at scala.collection.TraversableLike.$plus$plus$(TraversableLike.scala:147)
[error] at scala.collection.immutable.List.$plus$plus(List.scala:210)
[error] at sbt.internal.PluginDiscovery$.discoverAll(PluginDiscovery.scala:57)
[error] at sbt.internal.Load$.loadPlugins(Load.scala:1299)
[error] at sbt.internal.Load$.loadPluginDefinition(Load.scala:1244)
[error] at sbt.internal.Load$.noPlugins(Load.scala:1219)
[error] at sbt.internal.Load$.plugins(Load.scala:1204)
[error] at sbt.internal.Load$.$anonfun$loadUnit$2(Load.scala:688)
[error] at sbt.internal.Load$.timed(Load.scala:1376)
[error] at sbt.internal.Load$.$anonfun$loadUnit$1(Load.scala:688)
[error] at sbt.internal.Load$.timed(Load.scala:1376)
[error] at sbt.internal.Load$.loadUnit(Load.scala:682)
[error] at sbt.internal.Load$.$anonfun$builtinLoader$4(Load.scala:480)
[error] at sbt.internal.BuildLoader$.$anonfun$componentLoader$5(BuildLoader.scala:180)
[error] at sbt.internal.BuildLoader.apply(BuildLoader.scala:245)
[error] at sbt.internal.Load$.loadURI$1(Load.scala:542)
[error] at sbt.internal.Load$.loadAll(Load.scala:558)
[error] at sbt.internal.Load$.loadURI(Load.scala:488)
[error] at sbt.internal.Load$.load(Load.scala:467)
[error] at sbt.internal.Load$.$anonfun$apply$1(Load.scala:243)
[error] at sbt.internal.Load$.timed(Load.scala:1376)
[error] at sbt.internal.Load$.apply(Load.scala:243)
[error] at sbt.internal.GlobalPlugin$.build(GlobalPlugin.scala:59)
[error] at sbt.internal.GlobalPlugin$.load(GlobalPlugin.scala:64)
[error] at sbt.internal.Load$.loadGlobal(Load.scala:185)
[error] at sbt.internal.Load$.defaultWithGlobal(Load.scala:143)
[error] at sbt.internal.Load$.$anonfun$defaultLoad$1(Load.scala:50)
[error] at sbt.internal.Load$.timed(Load.scala:1376)
[error] at sbt.internal.Load$.defaultLoad(Load.scala:46)
[error] at sbt.BuiltinCommands$.liftedTree1$1(Main.scala:847)
[error] at sbt.BuiltinCommands$.doLoadProject(Main.scala:847)
[error] at sbt.BuiltinCommands$.$anonfun$loadProjectImpl$2(Main.scala:801)
[error] at sbt.Command$.$anonfun$applyEffect$4(Command.scala:149)
[error] at sbt.Command$.$anonfun$applyEffect$2(Command.scala:144)
[error] at sbt.Command$.process(Command.scala:187)
[error] at sbt.MainLoop$.process$1(MainLoop.scala:199)
[error] at sbt.MainLoop$.processCommand(MainLoop.scala:235)
[error] at sbt.MainLoop$.$anonfun$next$2(MainLoop.scala:147)
[error] at sbt.State$StateOpsImpl$.runCmd$1(State.scala:273)
[error] at sbt.State$StateOpsImpl$.process$extension(State.scala:277)
[error] at sbt.MainLoop$.$anonfun$next$1(MainLoop.scala:147)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19)
[error] at sbt.MainLoop$.next(MainLoop.scala:147)
[error] at sbt.MainLoop$.run(MainLoop.scala:138)
[error] at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:116)
[error] at sbt.io.Using.apply(Using.scala:27)
[error] at sbt.MainLoop$.runWithNewLog(MainLoop.scala:110)
[error] at sbt.MainLoop$.runAndClearLast(MainLoop.scala:65)
[error] at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:50)
[error] at sbt.MainLoop$.runLogged(MainLoop.scala:41)
[error] at sbt.StandardMain$.runManaged(Main.scala:132)
[error] at sbt.xMain$.run(Main.scala:67)
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[error] at sbt.internal.XMainConfiguration.run(XMainConfiguration.scala:45)
[error] at sbt.xMain.run(Main.scala:39)
[error] at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
[error] at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
[error] at xsbt.boot.Launch$.run(Launch.scala:109)
[error] at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error] at xsbt.boot.Launch$.launch(Launch.scala:117)
[error] at xsbt.boot.Launch$.apply(Launch.scala:18)
[error] at xsbt.boot.Boot$.runImpl(Boot.scala:56)
[error] at xsbt.boot.Boot$.main(Boot.scala:18)
[error] at xsbt.boot.Boot.main(Boot.scala)
[error] Caused by: java.lang.ClassNotFoundException: org.vafer.jdeb.Console
[error] at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
[error] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
[error] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
[error] at java.base/java.lang.Class.forName0(Native Method)
[error] at java.base/java.lang.Class.forName(Class.java:398)
[error] at sbt.internal.inc.ModuleUtilities$.getObject(ModuleUtilities.scala:24)
[error] at sbt.internal.inc.ModuleUtilities$.getCheckedObject(ModuleUtilities.scala:32)
[error] at sbt.internal.inc.ModuleUtilities$.$anonfun$getCheckedObjects$1(ModuleUtilities.scala:37)
[error] at scala.collection.immutable.Stream.$anonfun$map$1(Stream.scala:418)
[error] at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1171)
[error] at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1161)
[error] at scala.collection.generic.Growable.loop$1(Growable.scala:57)
[error] at scala.collection.generic.Growable.$plus$plus$eq(Growable.scala:61)
[error] at scala.collection.generic.Growable.$plus$plus$eq$(Growable.scala:53)
[error] at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:184)
[error] at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:47)
[error] at scala.collection.TraversableLike.$plus$plus(TraversableLike.scala:151)
[error] at scala.collection.TraversableLike.$plus$plus$(TraversableLike.scala:147)
[error] at scala.collection.immutable.List.$plus$plus(List.scala:210)
[error] at sbt.internal.PluginDiscovery$.discoverAll(PluginDiscovery.scala:57)
[error] at sbt.internal.Load$.loadPlugins(Load.scala:1299)
[error] at sbt.internal.Load$.loadPluginDefinition(Load.scala:1244)
[error] at sbt.internal.Load$.noPlugins(Load.scala:1219)
[error] at sbt.internal.Load$.plugins(Load.scala:1204)
[error] at sbt.internal.Load$.$anonfun$loadUnit$2(Load.scala:688)
[error] at sbt.internal.Load$.timed(Load.scala:1376)
[error] at sbt.internal.Load$.$anonfun$loadUnit$1(Load.scala:688)
[error] at sbt.internal.Load$.timed(Load.scala:1376)
[error] at sbt.internal.Load$.loadUnit(Load.scala:682)
[error] at sbt.internal.Load$.$anonfun$builtinLoader$4(Load.scala:480)
[error] at sbt.internal.BuildLoader$.$anonfun$componentLoader$5(BuildLoader.scala:180)
[error] at sbt.internal.BuildLoader.apply(BuildLoader.scala:245)
[error] at sbt.internal.Load$.loadURI$1(Load.scala:542)
[error] at sbt.internal.Load$.loadAll(Load.scala:558)
[error] at sbt.internal.Load$.loadURI(Load.scala:488)
[error] at sbt.internal.Load$.load(Load.scala:467)
[error] at sbt.internal.Load$.$anonfun$apply$1(Load.scala:243)
[error] at sbt.internal.Load$.timed(Load.scala:1376)
[error] at sbt.internal.Load$.apply(Load.scala:243)
[error] at sbt.internal.GlobalPlugin$.build(GlobalPlugin.scala:59)
[error] at sbt.internal.GlobalPlugin$.load(GlobalPlugin.scala:64)
[error] at sbt.internal.Load$.loadGlobal(Load.scala:185)
[error] at sbt.internal.Load$.defaultWithGlobal(Load.scala:143)
[error] at sbt.internal.Load$.$anonfun$defaultLoad$1(Load.scala:50)
[error] at sbt.internal.Load$.timed(Load.scala:1376)
[error] at sbt.internal.Load$.defaultLoad(Load.scala:46)
[error] at sbt.BuiltinCommands$.liftedTree1$1(Main.scala:847)
[error] at sbt.BuiltinCommands$.doLoadProject(Main.scala:847)
[error] at sbt.BuiltinCommands$.$anonfun$loadProjectImpl$2(Main.scala:801)
[error] at sbt.Command$.$anonfun$applyEffect$4(Command.scala:149)
[error] at sbt.Command$.$anonfun$applyEffect$2(Command.scala:144)
[error] at sbt.Command$.process(Command.scala:187)
[error] at sbt.MainLoop$.process$1(MainLoop.scala:199)
[error] at sbt.MainLoop$.processCommand(MainLoop.scala:235)
[error] at sbt.MainLoop$.$anonfun$next$2(MainLoop.scala:147)
[error] at sbt.State$StateOpsImpl$.runCmd$1(State.scala:273)
[error] at sbt.State$StateOpsImpl$.process$extension(State.scala:277)
[error] at sbt.MainLoop$.$anonfun$next$1(MainLoop.scala:147)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19)
[error] at sbt.MainLoop$.next(MainLoop.scala:147)
[error] at sbt.MainLoop$.run(MainLoop.scala:138)
[error] at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:116)
[error] at sbt.io.Using.apply(Using.scala:27)
[error] at sbt.MainLoop$.runWithNewLog(MainLoop.scala:110)
[error] at sbt.MainLoop$.runAndClearLast(MainLoop.scala:65)
[error] at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:50)
[error] at sbt.MainLoop$.runLogged(MainLoop.scala:41)
[error] at sbt.StandardMain$.runManaged(Main.scala:132)
[error] at sbt.xMain$.run(Main.scala:67)
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[error] at sbt.internal.XMainConfiguration.run(XMainConfiguration.scala:45)
[error] at sbt.xMain.run(Main.scala:39)
[error] at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
[error] at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
[error] at xsbt.boot.Launch$.run(Launch.scala:109)
[error] at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error] at xsbt.boot.Launch$.launch(Launch.scala:117)
[error] at xsbt.boot.Launch$.apply(Launch.scala:18)
[error] at xsbt.boot.Boot$.runImpl(Boot.scala:56)
[error] at xsbt.boot.Boot$.main(Boot.scala:18)
[error] at xsbt.boot.Boot.main(Boot.scala)
[error] java.lang.NoClassDefFoundError: org/vafer/jdeb/Console
[error] Use 'last' for the full log.
[debug] > Exec(loadFailed, None, None)
[debug] > Exec(last, None, None)
Before this I might have copied some .jar files from one project to another and this issue arose from then.
I've tried resetting Intellij to defaults, when that didn't work, I tried removing the Intellij installation and its related folders, excluding .ivy and .sbt folders. But nothing worked. I didn't try to delete any jar files though because I didn't wanna mess it up further.
Does anyone know how to solve this error?
Nevermind I found the solution.
I went into this directory /home/username/ and deleted the .sbt folder.
I also reinstalled Intellij and everything worked again

For loop over list while filtering

I have 2 DataFrames called df1 and df2, where they both have the same column names. I wish to run a for loop over unique dates, from df1 and apply the same date filter to df2. I created a list of unique dates and then tried to iterate through that. However what I have is throwing errors.
Here is what I have:
val unique_weeks = df1.select(df1("date")).distinct
for( week <- unique_weeks) {
val df1_filtered = df1.filter($"date" === week)
val df2_filtered = df2.filter($"date" === week)
/// will run a join here and more code
}
I think <- this part may be incorrect - but not sure how I can filter the DataFrames using another method.
Here is the error:
[error] (run-main-0) org.apache.spark.SparkException: Job aborted due to stage failure: Task 35 in stage 3.0 failed 1 times, most recent failure: Lost task 35.0 in stage 3.0 (TID 399, localhost, executor driver): java.lang.RuntimeException: Unsupported literal type class org.apache.spark.sql.catalyst.expressions.GenericRowWithSchema [1591772400000]
[error] at org.apache.spark.sql.catalyst.expressions.Literal$.apply(literals.scala:75)
[error] at org.apache.spark.sql.functions$.lit(functions.scala:101)
[error] at org.apache.spark.sql.Column.$eq$eq$eq(Column.scala:267)
[error] at spark_pkg.SparkMain$$anonfun$main$1.apply(SparkMain.scala:880)
[error] at spark_pkg.SparkMain$$anonfun$main$1.apply(SparkMain.scala:878)
[error] at scala.collection.Iterator$class.foreach(Iterator.scala:893)
[error] at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
[error] at org.apache.spark.rdd.RDD$$anonfun$foreach$1$$anonfun$apply$28.apply(RDD.scala:917)
[error] at org.apache.spark.rdd.RDD$$anonfun$foreach$1$$anonfun$apply$28.apply(RDD.scala:917)
[error] at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:1944)
[error] at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:1944)
[error] at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
[error] at org.apache.spark.scheduler.Task.run(Task.scala:99)
[error] at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:282)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
[error]
[error] Driver stacktrace:
[error] org.apache.spark.SparkException: Job aborted due to stage failure: Task 35 in stage 3.0 failed 1 times, most recent failure: Lost task 35.0 in stage 3.0 (TID 399, localhost, executor driver): java.lang.RuntimeException: Unsupported literal type class org.apache.spark.sql.catalyst.expressions.GenericRowWithSchema [1591772400000]
[error] at org.apache.spark.sql.catalyst.expressions.Literal$.apply(literals.scala:75)
[error] at org.apache.spark.sql.functions$.lit(functions.scala:101)
[error] at org.apache.spark.sql.Column.$eq$eq$eq(Column.scala:267)
[error] at spark_pkg.SparkMain$$anonfun$main$1.apply(SparkMain.scala:880)
[error] at spark_pkg.SparkMain$$anonfun$main$1.apply(SparkMain.scala:878)
[error] at scala.collection.Iterator$class.foreach(Iterator.scala:893)
[error] at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
[error] at org.apache.spark.rdd.RDD$$anonfun$foreach$1$$anonfun$apply$28.apply(RDD.scala:917)
[error] at org.apache.spark.rdd.RDD$$anonfun$foreach$1$$anonfun$apply$28.apply(RDD.scala:917)
[error] at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:1944)
[error] at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:1944)
[error] at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
[error] at org.apache.spark.scheduler.Task.run(Task.scala:99)
[error] at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:282)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
[error]
[error] Driver stacktrace:
[error] at org.apache.spark.scheduler.DAGScheduler.org$apache$spark$scheduler$DAGScheduler$$failJobAndIndependentStages(DAGScheduler.scala:1435)
[error] at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1423)
[error] at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1422)
[error] at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
[error] at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
[error] at org.apache.spark.scheduler.DAGScheduler.abortStage(DAGScheduler.scala:1422)
[error] at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:802)
[error] at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:802)
[error] at scala.Option.foreach(Option.scala:257)
[error] at org.apache.spark.scheduler.DAGScheduler.handleTaskSetFailed(DAGScheduler.scala:802)
[error] at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.doOnReceive(DAGScheduler.scala:1650)
[error] at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1605)
[error] at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1594)
[error] at org.apache.spark.util.EventLoop$$anon$1.run(EventLoop.scala:48)
[error] at org.apache.spark.scheduler.DAGScheduler.runJob(DAGScheduler.scala:628)
[error] at org.apache.spark.SparkContext.runJob(SparkContext.scala:1918)
[error] at org.apache.spark.SparkContext.runJob(SparkContext.scala:1931)
[error] at org.apache.spark.SparkContext.runJob(SparkContext.scala:1944)
[error] at org.apache.spark.SparkContext.runJob(SparkContext.scala:1958)
[error] at org.apache.spark.rdd.RDD$$anonfun$foreach$1.apply(RDD.scala:917)
[error] at org.apache.spark.rdd.RDD$$anonfun$foreach$1.apply(RDD.scala:915)
[error] at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
[error] at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
[error] at org.apache.spark.rdd.RDD.withScope(RDD.scala:362)
[error] at org.apache.spark.rdd.RDD.foreach(RDD.scala:915)
[error] at org.apache.spark.sql.Dataset$$anonfun$foreach$1.apply$mcV$sp(Dataset.scala:2286)
[error] at org.apache.spark.sql.Dataset$$anonfun$foreach$1.apply(Dataset.scala:2286)
[error] at org.apache.spark.sql.Dataset$$anonfun$foreach$1.apply(Dataset.scala:2286)
[error] at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:57)
[error] at org.apache.spark.sql.Dataset.withNewExecutionId(Dataset.scala:2765)
[error] at org.apache.spark.sql.Dataset.foreach(Dataset.scala:2285)
[error] at spark_pkg.SparkMain$.main(SparkMain.scala:878)
[error] at spark_pkg.SparkMain.main(SparkMain.scala)
[error] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] at java.lang.reflect.Method.invoke(Method.java:498)
[error] Caused by: java.lang.RuntimeException: Unsupported literal type class org.apache.spark.sql.catalyst.expressions.GenericRowWithSchema [1591772400000]
[error] at org.apache.spark.sql.catalyst.expressions.Literal$.apply(literals.scala:75)
[error] at org.apache.spark.sql.functions$.lit(functions.scala:101)
[error] at org.apache.spark.sql.Column.$eq$eq$eq(Column.scala:267)
[error] at spark_pkg.SparkMain$$anonfun$main$1.apply(SparkMain.scala:880)
[error] at spark_pkg.SparkMain$$anonfun$main$1.apply(SparkMain.scala:878)
[error] at scala.collection.Iterator$class.foreach(Iterator.scala:893)
[error] at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
[error] at org.apache.spark.rdd.RDD$$anonfun$foreach$1$$anonfun$apply$28.apply(RDD.scala:917)
[error] at org.apache.spark.rdd.RDD$$anonfun$foreach$1$$anonfun$apply$28.apply(RDD.scala:917)
[error] at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:1944)
[error] at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:1944)
[error] at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
[error] at org.apache.spark.scheduler.Task.run(Task.scala:99)
[error] at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:282)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
[error] stack trace is suppressed; run 'last Compile / bgRun' for the full output
[error] Nonzero exit code: 1
[error] (Compile / run) Nonzero exit code: 1
[error] Total time: 137 s (02:17), completed Aug 20, 2020 1:16:02 PM
A dataframe is not an iterator, and therefore, you cannot run a for loop over it. You can run something like this - but I don't think it will do what you're hoping to achieve based on your other code.
unique_weeks.foreachPartition{ weeks : Iterator[YourData] =>
for( week <- weeks) {
}
}
Your question suggests your mental model of what a dataframe is and how Spark works is not quite complete. Think of a Dataframe more as a List[List[YourData]], except each inner List[YourData] is located on an independent piece of a machine, and may not necessarily know or interact with any of the other Lists until you collect them back to the driver.

How to fix [ERROR] i.g.a.Gatling$ - Run crashed java.lang.IllegalArgumentException: requirement failed: No scenario set up?

I am trying to run my gatling tests via command gatling:test and I get this result:
[info] Simulation CheckPerformance successful.
13:08:30.196 [ERROR] i.g.a.Gatling$ - Run crashed
java.lang.IllegalArgumentException: requirement failed: No scenario set up
at scala.Predef$.require(Predef.scala:281)
at io.gatling.core.scenario.Simulation.params(Simulation.scala:129)
at io.gatling.app.Runner.run0(Runner.scala:76)
at io.gatling.app.Runner.run(Runner.scala:60)
at io.gatling.app.Gatling$.start(Gatling.scala:80)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:46)
at io.gatling.sbt.GatlingTask.liftedTree1$1(GatlingTask.scala:52)
at io.gatling.sbt.GatlingTask.execute(GatlingTask.scala:51)
at sbt.ForkMain$Run.lambda$runTest$1(ForkMain.java:304)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
[error] java.lang.IllegalArgumentException: requirement failed: No scenario set up
[error] at scala.Predef$.require(Predef.scala:281)
[error] at io.gatling.core.scenario.Simulation.params(Simulation.scala:129)
[error] at io.gatling.app.Runner.run0(Runner.scala:76)
[error] at io.gatling.app.Runner.run(Runner.scala:60)
[error] at io.gatling.app.Gatling$.start(Gatling.scala:80)
[error] at io.gatling.app.Gatling$.fromArgs(Gatling.scala:46)
[error] at io.gatling.sbt.GatlingTask.liftedTree1$1(GatlingTask.scala:52)
[error] at io.gatling.sbt.GatlingTask.execute(GatlingTask.scala:51)
[error] at sbt.ForkMain$Run.lambda$runTest$1(ForkMain.java:304)
[error] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error] at java.base/java.lang.Thread.run(Thread.java:834)
[error] Simulation BaseSimulation failed.
[info] Simulation(s) execution ended.
BaseSimulation scala class contains only baseURL
import io.gatling.core.Predef._
import io.gatling.http.Predef.http
class BaseSimulation extends Simulation {
val httpProtocol = http
.baseUrl("https://baseurl.com")
}
I tried to run only test using command gatling:testOnly package.TestClass. It works locally, but the same command in gitlab ci job leads to the same error even though all the tests passed successfully.
[info] Simulation CheckPerformance successful.
09:52:02.214 [ERROR] i.g.a.Gatling$ - Run crashed
java.lang.IllegalArgumentException: requirement failed: No scenario set up
at scala.Predef$.require(Predef.scala:281)
at io.gatling.core.scenario.Simulation.params(Simulation.scala:129)
at io.gatling.app.Runner.run0(Runner.scala:76)
at io.gatling.app.Runner.run(Runner.scala:60)
at io.gatling.app.Gatling$.start(Gatling.scala:80)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:46)
at io.gatling.sbt.GatlingTask.liftedTree1$1(GatlingTask.scala:52)
at io.gatling.sbt.GatlingTask.execute(GatlingTask.scala:51)
at sbt.ForkMain$Run.lambda$runTest$1(ForkMain.java:304)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
[error] java.lang.IllegalArgumentException: requirement failed: No scenario set up
[error] at scala.Predef$.require(Predef.scala:281)
[error] at io.gatling.core.scenario.Simulation.params(Simulation.scala:129)
[error] at io.gatling.app.Runner.run0(Runner.scala:76)
[error] at io.gatling.app.Runner.run(Runner.scala:60)
[error] at io.gatling.app.Gatling$.start(Gatling.scala:80)
[error] at io.gatling.app.Gatling$.fromArgs(Gatling.scala:46)
[error] at io.gatling.sbt.GatlingTask.liftedTree1$1(GatlingTask.scala:52)
[error] at io.gatling.sbt.GatlingTask.execute(GatlingTask.scala:51)
[error] at sbt.ForkMain$Run.lambda$runTest$1(ForkMain.java:304)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
[error] Simulation BaseSimulation failed.
[info] Simulation(s) execution ended.
[error] Failed tests:
[error] package.BaseSimulation
[error] (Gatling / testOnly) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 22 s, completed May 20, 2020 9:52:02 AM
Running after_script
Uploading artifacts for failed job
00:03
Uploading artifacts...
target/gatling/: found 42 matching files
Uploading artifacts to coordinator... ok id=833478 responseStatus=201 Created token=d3PcCfw5
ERROR: Job failed: exit code 1
What did I miss? I will be happy to hear any ideas!
Add setup annotation at the end
Sample Code
val headers_10 = Map("Content-Type" -> """application/json""")
val httpProtocol = http
.baseUrl("https://reqres.in")
val scn = scenario("BasicSimulation")
.exec(http("request_1")
.post("/api/users")
.headers(headers_10)
.body(StringBody("""{
"name": "morpheus",
"job": "leader"
} """)).asJson)
.pause(5)
setUp(
scn.inject(atOnceUsers(50)) // 12
).protocols(httpProtocol)
If you are trying to extend to a BaseSimulation that doesn't have any scenarios listed, you should add this to your pom.xml
<configuration>
<runMultipleSimulations>true</runMultipleSimulations>
<excludes>
<exclude>packageName.BaseSimulation</exclude>
</excludes>
</configuration>
Error is self explanatory: No scenario set up.
class BaseSimulation extends Simulation {
val httpProtocol = http
.baseUrl("https://baseurl.com")
}
This is not a valid Gatling simulation.
You don't define scenario(s) and a setUp.
Please have a look at the official documentation, in particular the tutorials.

Passing command line parameters in gatling sbt project

I am want to pass the ramp up users, throttle Duration, hold duration etc using command line parameters in a gatling sbt project.
for example:
val rampUpUserCount = Integer.parseInt(System.getProperty("rampUpUsers"))
val rampUpDuration = Integer.getInteger(System.getProperty("rampUpDuration"))
In the test I am doing
setUp(
test.homePageScenario.inject(
nothingFor(10 seconds),
rampUsers(rampUpUserCount) over (rampUpDurationInMins minutes)
))
and from command line when I pass
sbt gatling:testOnly simulations.test.gateway -DrampUpUsers=200 -DrampUpDuration=20
I am getting NumberFormatException
16:28:44.570 [INFO ] a.e.s.Slf4jLogger - Slf4jLogger started
[error] java.lang.NumberFormatException: null
[error] at java.lang.Integer.parseInt(Integer.java:542)
[error] at java.lang.Integer.parseInt(Integer.java:615)
[error] at simulations.SimulationConfig.$init$(SimulationConfig.scala:185)
[error] at simulations.engineGateway.GetRecsFromThinkGateway.<init>(GetRecsFromThinkGateway.scala:10)
[error] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[error] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[error] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[error] at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[error] at java.lang.Class.newInstance(Class.java:442)
[error] at io.gatling.app.Runner.run0(Runner.scala:79)
[error] at io.gatling.app.Runner.run(Runner.scala:64)
[error] at io.gatling.app.Gatling$.start(Gatling.scala:59)
[error] at io.gatling.app.Gatling$.fromArgs(Gatling.scala:43)
[error] at io.gatling.sbt.GatlingTask.liftedTree1$1(GatlingTask.scala:51)
[error] at io.gatling.sbt.GatlingTask.execute(GatlingTask.scala:50)
[error] at sbt.ForkMain$Run$2.call(ForkMain.java:296)
[error] at sbt.ForkMain$Run$2.call(ForkMain.java:286)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
Please can someone help me with this?
Thanks
You need to move the parameters before the task gatling:testOnly
sbt -DrampUpUsers=200 -DrampUpDuration=20 gatling:testOnly simulations.test.gateway