tl; dr The SparkConsumer application behaves correctly on Tomcat, as well as Tomcat itself.
I am very surprised to read the question because your code is not something that I expect from working ever on Tomcat. Unfortunately.
Tomcat is a servlet container and as such requires servlets in a web application.
Even though you managed to create a WAR and deploy it to Tomcat, you did not βlaunchβ any of this web application to launch the Spark Streaming application (the code inside the main method).
The Spark Streaming application works fine when running sbt run , because the goal is sbt run , that is, to run a stand-alone application in a project managed by sbt.
Given that you only have one standalone application in your sbt project, sbt run managed to find SparkConsumer and execute its main input method. There is nothing surprising here.
However, it will not work on Tomcat. You will need to open the application as a POST or GET endpoint and use an HTTP client (browser or command line tool like curl, wget or httpie) to execute it.
Spark does not support Scala 2.12, so ... how did you manage to use the Scala version with Spark ?! Impossible!
source share