Action Not Found For request 'GET /' These routes have been tried, in this order: Play Framework - scala

Migrating from sbt 0.13.0 to 1.3.0,scala 2.10.3 to 2.12.3 and play Version from 2.2.6 to 2.6.6
Below is the description of my problem
Caused by: java.lang.RuntimeException: java.io.IOException: resource not found on classpath: conf/application.conf #6507
I got the above error so I understood that application.conf file is missing so added application.conf an empty file in conf directory in project root directory . Actually my project has application.conf file under : project/modules/core/conf folder.
After adding a conf file under root directory I am getting the below error:
http://localhost:9000 - Action Not Found
For request 'GET /'
These routes have been tried, in this order:
In sbt console :
[warn] p.db.DBModule - Configuration not found for database: No configuration setting found for key 'db'
[info] p.a.h.EnabledFilters - Enabled Filters (see https://www.playframework.com/documentation/latest/Filters):
play.filters.csrf.CSRFFilter
play.filters.headers.SecurityHeadersFilter
play.filters.hosts.AllowedHostsFilter
[info] play.api.Play - Application started (Dev) (no global state)

Try starting sbt with the flags which point it to the correct application.conf.
Include the flag -Dconfig.resource="path/application.conf" when starting the project.
That should sort the DB errors if your config is correct...
https://www.playframework.com/documentation/2.8.x/ConfigFile?

This works for me
play.filters.hosts.allowed += "."

Related

PlayFramework - Creating Scala seed template with sbt

I am attempting to create the PlayFramework Scala seed project.
So far I've used sbt new playframework/play-scala-seed.g8 command and it has created the necessary files within my root directory movie-app.
From this point, PlayFramework says to run sbt run, so I tried that, but I get the following error:
[info] Updated file *omitting personal directories*/Movie-App/project/build.properties: set sbt.version to 1.4.7
[info] welcome to sbt 1.4.7 (Ubuntu Java 11.0.10)
[info] loading project definition from *omitting personal directories*/Movie-App/project
[info] set current project to movie-app (in build file:*omitting personal directories*/Movie-App/)
[error] java.lang.RuntimeException: No main class detected.
[error] at scala.sys.package$.error(package.scala:30)
[error] stack trace is suppressed; run last Compile / bgRun for the full output
[error] (Compile / bgRun) No main class detected.
[error] Total time: 0 s, completed Jul 2, 2021, 11:27:33 PM
I haven't found anything helpful online yet.
Do I need to set the current project to "movie-app" like the error says? If so what do I need to write in the build.properties file?
If not, can anyone please explain the issue?
Thanks
$> sbt new playframework/play-scala-seed.g8
This template generates a Play Scala project.
Give it a name when asked. Skip rest by pressing enter.
name [play-scala-seed]: movie-app
$> cd movie-app
$> sbt run

Data proc job is failing with Class not found exception

I just started learning GCP and IntelliJ SBT for the first time.Please bear with me for any basic question.
My project structure:
Here is my SBT.Build
name := "MySBTproject"
version := "0.1"
scalaVersion := "2.11.12"
val moutlingyaml = "net.jcazevedo" %% "moultingyaml" % "0.4.2"
lazy val root = (project in file("."))
  .settings(
    name := "MySBTproject",
    libraryDependencies += moutlingyaml
  )
Then i ran SBT package from Terminal to create a jar as shown below
C:\Users\xyz\IdeaProjects\MySBTproject>SBT Package
After deploying this jar on to GCP bucket,i tried running the job using data proc
gcloud dataproc jobs submit spark \
--cluster my-cluster \
--region europe-north1 \
--jars gs://test-my-bucket-01/spark-jobs/mysbtproject_2.11-0.1.jar \
--class com.test.processing.jobs.mytestmain
I am getting below error once i run the job
Job failed with message [java.lang.ClassNotFoundException: com.test.processing.jobs.mytestmain]
Is it because of my custom project directory structure and build.sbt are not in sync?
Are any changes required, or do i need to create a jar from project sub-directory as shown below?
C:\Users\xyz\IdeaProjects\MySBTproject\ProcessDataDataProcessingJobs>SBT Package
src directory should be in directory pointed by project.in(directory). In your case project directory is ProcessData, while your src is in ProcessData/DataProcessingJobs. So I'm guessing that sbt doesn't see your code at all, doesn't compile it, and doesn't package it.
You can check it by opening JAR (after all it's just a ZIP file with classes in directories!) and by calling show sourceDirectories to see where sbt is looking for you code.
Since i do not have privilege to edit the question i am attaching the details as an answer.Once i get the proper answer i will delete my answer.
Below is the error i am getting when i am running from "run" on the IntelliJ window panel
Also i have verified the Jar file and found that no classes were there,And below is the contnets of jar and manifest file.
Manifest-Version: 1.0
Implementation-Title: MySBTproject
Implementation-Version: 0.1.0-SNAPSHOT
Specification-Vendor: default
Specification-Title: MySBTproject
Implementation-Vendor-Id: default
Specification-Version: 0.1.0-SNAPSHOT
Implementation-Vendor: default
and JAR file contents are in below image
request you to advise on what further needs to be done.
When i ran show directories command in sbt shell below are the outputs
MySBTproject> show sourceDirectories
[info] root / Compile / sourceDirectories
[info] List(C:\Users\XXXXX\IdeaProjects\MySBTproject\DataProcessingjobs\src\main\scala-2.11, C:\Users\XXXXXXXXX\IdeaProjects\MySBTproject\DataProcessingjobs\src\main\scala, C:\Users\XXXXXXXXX\IdeaProjects\MySBTproject\DataProcessingjobs\src\main\java, C:\Users\XXXXXXXXX\IdeaProjects\MySBTproject\DataProcessingjobs\target\scala-2.11\src_managed\main)
[info] Compile / sourceDirectories
[info] List(C:\Users\XXXXXX\IdeaProjects\MySBTproject\src\scala-2.12, C:\Users\XXXXXXXXX\IdeaProjects\MySBTproject\src\scala, C:\Users\XXXXXXXXX\IdeaProjects\MySBTproject\src\java, C:\Users\XXXXXXXXX\IdeaProjects\MySBTproject\target\scala-2.12\src_managed\main
[info] List(C:\Users\XXXXXX\IdeaProjects\MySBTproject\src\scala-2.12, C:\Users\XXXXXXXXX\IdeaProjects\MySBTproject\src\scala, C:\Users\XXXXXXXXX\IdeaProjects\MySBTproject\src\java, C:\Users\XXXXXXXXX\IdeaProjects\MySBTproject\target\scala-2.12\src_managed\main)
[IJ]sbt:MySBTproject>
I recently received the same error when executing a jar on Google Cloud DataProc. I'm not sure if this is the same issue you are having, but please give it a try if you are still having this issue and have not resolved it.
My setup is:
Scala 2.11.12
sbt 1.3.13
Spark SQL 2.3.2
For me, the issue was related to the removal of the system property io.grpc.internal.DnsNameResolverProvider.enable_grpclb in grpc v1.29.0. You can read more about it at the googleapis/java-logging issue on github from Oct 8, 2020. Look for the comment by user athakor.
The resolution was to add the dependencies:
libraryDependencies += "com.google.cloud" % "google-cloud-logging" % "1.102.0" exclude("io.grpc", "grpc-alts")
libraryDependencies += "io.grpc" % "grpc-alts" % "1.29.0"

Setting up IntelliJ with Scala and SBT

I am trying to setup intellij with scala and sbt for development. I have already installed scala and SBT plugins on the IDE. However, when I try to create a new scala and sbt project, the build.sbt file shows the following errors:
Cannot resolve symbol :=
Cannot resolve symbol name
Cannot resolve symbol version
Cannot resolve symbol scalaVersion
Here is my build.sbt file which was created by the IDE itself:
name := "setup"
version := "1.0"
scalaVersion := "2.12.2"
The following are the steps I followed for creating the project:
Step One: File -> New Project
Step Two: Choose Scala from the left hand side panel and choose SBT on the right hand side panel (i.e SBT-based Scala project) and click Next.
Step Three: Fill in the project details and click Finish. ( Scala version -> 2.12.2, SBT version -> 0.13.13)
IntelliJ version - IntelliJ IDEA 2017.1.3
Edit:
Whenever I am trying to create a new project, I get the following error :
Error:Error while importing SBT project:<br/>...<br/><pre> https://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.11/jansi-1.11.jar
::::::::::::::::::::::::::::::::::::::::::::::
:: UNRESOLVED DEPENDENCIES ::
::::::::::::::::::::::::::::::::::::::::::::::
:: org.fusesource.jansi#jansi;1.11: not found
::::::::::::::::::::::::::::::::::::::::::::::
:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
unresolved dependency: org.fusesource.jansi#jansi;1.11: not found
Error during sbt execution: Error retrieving required libraries
(see C:\Users\xxxxxx\.sbt\boot\update.log for complete log)
Error: Could not retrieve jansi 1.11
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=384M; support was removed in 8.0</pre><br/>See complete log in C:\Users\xxxxx\.IntelliJIdea2016.2\system\log\sbt.last.log
the Log file has the following content:
Getting org.fusesource.jansi jansi 1.11 ...
You probably access the destination server through a proxy server that is not well configured.
You probably access the destination server through a proxy server that is not well configured.
You probably access the destination server through a proxy server that is not well configured.
You probably access the destination server through a proxy server that is not well configured.
You probably access the destination server through a proxy server that is not well configured.
:: problems summary ::
:::: WARNINGS
Host jcenter.bintray.com not found. url=https://jcenter.bintray.com/org/fusesource/jansi/jansi/1.11/jansi-1.11.pom
Host jcenter.bintray.com not found. url=https://jcenter.bintray.com/org/fusesource/jansi/jansi/1.11/jansi-1.11.jar
Host repo.typesafe.com not found. url=https://repo.typesafe.com/typesafe/ivy-releases/org.fusesource.jansi/jansi/1.11/ivys/ivy.xml
Host repo1.maven.org not found. url=https://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.11/
**
So I think this is an issue with my proxy settings and I definitely need to use the proxy. Is there a way to solve this??
Any help would be appreciated. Thank you.

How to set up wro4j for sbt with the latest versions of sbt and plugins on windows?

I have downloaded this example and made some changes to resolve errors. Particularly, I have changed sbt.version to 0.13.5 in the build.properties file, and changed both scalatra-sbt and xsbt-wro4j-pluginversions to 0.3.5 in the project/plugins.sbt.
This modified example does not work even after creating wro4j folder manually - command wro4j does nothing and after container:start http://localhost:8080/compiled/scripts.js results in 404.
What else does the plugin need to work with newer versions of sbt and plugins? What is the working version combination for wro4j?
The failing example is in https://github.com/Odomontois/scalatra-coffeescript.
UPDATE
Just checked it on linux machine. All have been produced properly. So it looks like windows-only problem.
UPDATE 2
After lots of different checks i have investigated that problem somehow is related to path finding. If you keep files at they are in the master branch generating wont even start.
But if you change your path pattern in wro.xml replacing path separators from unix to windows style i.e. change '/' to '\' as it done in the windows-separator branch, you'll receieve following log messages:
[info] Using relative Context: /compiled/scripts.css
[info] Processing Group: [scripts] with type [CSS]
[info] Using relative Context: /compiled/scripts.js
[info] Processing Group: [scripts] with type [JS]
[trace] Stack trace suppressed: run last compile:wro4j for the full output.
[error] (compile:wro4j) ro.isdc.wro.WroRuntimeException: No locator is capable of handling uri: \coffee\*.coffee

SBT publishing via SSH key auth not working

My question is: Why can't I publish from SBT to my server via SSH?
Context:
I am developing a scala library and I want to publish it to a remote repository with SBT v0.12.3 over SSH (using an SFTP resolver). The relevant portion of my project/Build.scala SBT settings file is configured as prescribed by https://github.com/harrah/xsbt/wiki/Resolvers:
publishTo <<= version { v =>
Some(Resolver.sftp(
"My Repository",
"example.com",
"/var/www/public_html/repositories/" + (
if (v.trim.endsWith("SNAPSHOT")) { "snapshots" } else { "releases" }
)
))
},
resolvers ++= Seq(
{
import java.io.File
val privateKeyFile: File = new File(sys.env("HOME") + "/.ssh/id_rsa")
Resolver.ssh("scala-sh", "example.com") as("my-username", privateKeyFile) withPermissions("0644")
},
...
),
When I run sbt publish, things go fine until the authorization, where it still attempts to prompt me for login/password. When I run it locally, it brings up the username/password prompt, and when I try to publish remotely while SSH'd in to a machine it fails with a java.awt.HeadlessException. The result appears to be that the desired private-key type of authentication is not being attempted.
Here is a log of the remote session publish attempt:
> sbt-version
[info] 0.12.3
> publish
[info] Packaging /home/me/my-lib/target/scala-2.10.1/my-lib_2.10.1-SNAPSHOT-sources.jar ...
[info] Done packaging.
[info] Wrote /home/me/my-lib/target/scala-2.10.1/my-lib_2.10.1-SNAPSHOT.pom
[info] :: delivering :: org.example#my-lib_2.10.1;SNAPSHOT :: SNAPSHOT :: release :: Sun Apr 21 12:48:59 PDT 2013
[info] delivering ivy file to /home/me/my-lib/target/scala-2.10.1/ivy-SNAPSHOT.xml
[info] Generating API documentation for main sources...
model contains 75 documentable templates
[info] API documentation generation successful.
[info] Packaging /home/me/my-lib/target/scala-2.10.1/my-lib_2.10.1-SNAPSHOT-javadoc.jar ...
[info] Done packaging.
[info] Packaging my-lib-SNAPSHOT.jar ...
[info] Done packaging.
[trace] Stack trace suppressed: run last *:publish for the full output.
[error] (*:publish) java.awt.HeadlessException:
[error] No X11 DISPLAY variable was set, but this program performed an operation which requires it.
[error] Total time: 35 s, completed Apr 21, 2013 12:49:33 PM
It fails because there is no X11 display. This is unexpected behavior because the SBT project configuration is set to use private key authentication (see resolvers above).
So far I can think of 2 possible causes for the problem, detailed below.
Possible cause #1: Misconfiguration of SBT
Is there a problem in my configuration above?
Possible cause #2: Hitting an Ivy bug from an old version
At time of writing, I am using the latest SBT, 0.12.3. Maybe the version of Ivy being used by SBT is old. The more I think about it, the less likely this seems, but I haven't been able to rule it out yet.
How can I find out what version of Ivy SBT is using?
and then..
IF it is old, is there a way to get SBT to use a newer version of ivy?
There is another relevant question, see ivy ssh publisher, which references[0] an Old Ivy bug which caused java.awt.HeadlessExceptions.
[0] ivy ssh publisher
"Which version of Ivy are you using? There is a Jira Bug for Version 2.0 : issues.apache.org/jira/browse/IVY-783 which should be fixed now."
"Seems like if I upgrade to ivy 2.3 rc-2. SSH publish works."
It may after all be an Ivy version related bug. I am using SBT 0.12.2, which AFAIK is using Ivy 2.0. I am looking at the Ivy cache, located in ~/.ivy2/cache/, where Ivy creates a bunch of XML log files for the dependencies it has resolved, and I can see Ivy module version 2.0 in every XML file generated.
I don't know of a way to update the Ivy version used by SBT, but judging by the default SBT documentation, a possible solution is to manually upgrade Ivy and make sure the default machine wide path points to the right Ivy version.
Then run sbt clean or sbt update to re-fetch dependencies and allow Ivy to regenerate XML config files, etc. for the new Ivy version. More on SBT dependency management HERE:
Ivy Home Directory
By default, sbt uses the standard Ivy home directory location
${user.home}/.ivy2/. This can be configured machine-wide, for use by
both the sbt launcher and by projects, by setting the system property
sbt.ivy.home in the sbt startup script (described in Setup).
For example:
java -Dsbt.ivy.home=/tmp/.ivy2/ ...
Update
By checking the SBT Scala source code for the latest version, the version issue is confirmed again. Even SBT 0.13 appears to be using Ivy version 2.0.0, not 2.3. Have a look at the SBT source code, specifically the last few lines of THIS file.