Play Framework 2.3 no resources after migration - resources

I have a play framework 2.1 application. This app worked. Then I migrated to 2.2, tested it and it worked. Now I am migrating to 2.3 and I got an error like:
[debug] application - Unforseen error for favicon.svg at /public
java.lang.RuntimeException: no resource
at controllers.Assets$$anonfun$controllers$Assets$$assetInfoFromResource$1$$anonfun$13.apply(Assets.scala:237) ~[na:na]
at controllers.Assets$$anonfun$controllers$Assets$$assetInfoFromResource$1$$anonfun$13.apply(Assets.scala:237) ~[na:na]
at scala.Option.getOrElse(Option.scala:120) [na:na]
at controllers.Assets$$anonfun$controllers$Assets$$assetInfoFromResource$1.apply(Assets.scala:237) ~[na:na]
at controllers.Assets$$anonfun$controllers$Assets$$assetInfoFromResource$1.apply(Assets.scala:236) ~[na:na]
There is a /public folder, but all resources are resulting in above error. The app serves such resources as 404 Not Found.
Any help would be great. Some cleaning procecese, cached files I can delete, redownload dependencies or maybe I have a wrong configuration.
Here are some config files I have for better understanding:
build.sbt:
import com.typesafe.sbt.less.Import.LessKeys import play.PlayJava
name := """blabla-de"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.11.1"
libraryDependencies ++= Seq( filters, cache, javaCore, javaWs, javaJdbc, javaEbean, "org.webjars" % "bootstrap" % "3.0.0", "org.webjars" % "rjs" % "2.1.11-1-trireme" % "test", "org.webjars" % "squirejs" % "0.1.0" % "test", "junit" % "junit" % "4.11" % "test" )
testOptions += Tests.Argument(TestFrameworks.JUnit, "-v")
LessKeys.compress in Assets := true
includeFilter in (Assets, LessKeys.less) := "*.less"
excludeFilter in (Assets, LessKeys.less) := "_*.less"
pipelineStages := Seq(rjs, digest, gzip)
conf/routes:
# Home page
GET / controllers.Index.index()
GET /about controllers.About.index()
## Contact Page
GET /contact controllers.Contact.index()
POST /contact controllers.Contact.newContact()
## Gallery List
GET /portfolio controllers.Portfolio.index()
## Text(HTML) Page
GET /impressum controllers.Impressum.index()
#GET /legal
GET /privacy controllers.Privacy.index()
# Map static resources from the /public folder to the / URL path
GET /*file controllers.Assets.at(path="/public", file)
project/build.properties:
sbt.version=0.13.5
project/plugins.sbt:
// Comment to get more information during initialization
logLevel := Level.Warn
// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.1")
// web plugins
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.0.0")
Thank You in Advance.

The key is in the migration guide: https://www.playframework.com/documentation/2.4.x/Migration23
The largest new feature for Play 2.3 is the introduction of sbt-web.
In summary sbt-web allows Html, CSS and JavaScript functionality to be
factored out of Play’s core into a family of pure sbt plugins.
Unavailability of public resources must be caused by improper configuration of sbt-web.
What I can see immediately is that you forgot to enable SbtWeb plugins. Here is another quote from the migration guide:
declaring addSbtPlugin may not be sufficient for plugins that now
utilize to the auto plugin functionality.
So you need to fix the following line in your build.sbt:
lazy val root = (project in file(".")).enablePlugins(PlayJava, SbtWeb)

Related

Application crash with TERMINATED

I have one application made in QT, and sometimes when I start it, occurre an inexpected TERMINATED error.
But If I retry sometimes, the application open normally.
ebonomo#ICCSW-044681NB /usr/local/app/bin$ ./myapp
Terminado
ebonomo#ICCSW-044681NB /usr/local/app/bin$ ./myapp
Terminado
ebonomo#ICCSW-044681NB /usr/local/app/bin$ ./myapp
"Iniciando ...
.....
I created a lib folder in app/lib with all libs detected in lddtree. I changed too in .bashrc to set LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/app/lib/
But I can't get why this error. Could you help me? How can I get the cause? Is there any command to check it?
I already tried remove all in main method keeping only a debug message, and the error occurred yet.
I don't know more what can I do. :(
My environment is:
Ubuntu 20.04
Qt 5.15.2
Qt Creator 7.0.1
Based on Qt 6.2.3 (GCC 10.3.1 20210422 (Red Hat 10.3.1-1), 64 bit)
Built on Apr 26 2022 01:18:11
From revision da16d778d5
OBS: I can reproduce the error with this code:
int main(int argc, char *argv[])
{
qFatal("Starting application");
}
My .pro is it:
#-------------------------------------------------
#
# Project created by QtCreator 2020-09-24T10:15:43
#
#-------------------------------------------------
QT += core gui network svg
QT += multimedia
QT += multimediawidgets
QT += 3drender
QT += printsupport
CONFIG += ccache use_gold_linker precompile_header # Improve Build Speed
PRECOMPILED_HEADER = precompiled_header.h
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets quick
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH = $$PWD/ui/imports
TARGET = myapp
TEMPLATE = app
INCLUDEPATH += $$PWD/libs
INCLUDEPATH += $$PWD/libs/qtmqtt
INCLUDEPATH += /usr/include/opencv4
INCLUDEPATH += $$PWD/imagerender/src
INCLUDEPATH += $$PWD/libs/fingerprint/Futronic/header
#Include static lib QT MQTT
equals(QT_VERSION, "5.15.2") {
#message("Loading lib libQt5Mqtt for 5.15.2")
LIBS += -L$$PWD/libs/qtmqtt/5.15.2 -lQt5Mqtt
QMAKE_LFLAGS += -Wl,--rpath=$$PWD/libs/qtmqtt/5.15.2
}
equals(QT_VERSION, "5.15.1") {
#message("Loading lib libQt5Mqtt for 5.15.1")
LIBS += -L$$PWD/libs/qtmqtt/5.15.1 -lQt5Mqtt
QMAKE_LFLAGS += -Wl,--rpath=$$PWD/libs/qtmqtt/5.15.1
}
LIBS += -L$$PWD/libs/fingerprint/Futronic -lScanAPI
QMAKE_LFLAGS += -Wl,--rpath=$$PWD/libs/fingerprint/Futronic
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
LIBS += -lopencv_core
LIBS += -lopencv_highgui
LIBS += -lopencv_imgproc
LIBS += -lopencv_features2d
LIBS += -lopencv_calib3d
LIBS += -lopencv_videoio
LIBS += -lopencv_imgcodecs
LIBS += -lrt
SOURCES += \
main.cpp
# a lot of .cpp here
HEADERS += \
constants.h
# a lot of .h here
FORMS +=
DISTFILES += \
settings.ini
RESOURCES += \
resources.qrc \
images/logos/logo.png
TRANSLATIONS += i18n/en.ts \
i18n/es.ts \
i18n/pt.ts
# From here https://stackoverflow.com/a/36438618
copydata.commands = $(COPY_DIR) $$PWD/settings.ini $$OUT_PWD
first.depends = $(first) copydata
export(first.depends)
export(copydata.commands)
QMAKE_CXXFLAGS += -Wno-unknown-pragmas # Ignore pragma region warnings
QMAKE_EXTRA_TARGETS += first copydata

Python output is not redirected in order

I am trying to format output from the following Python 3.x script. Here is the function that I'm calling:
def daily_backup():
# Header for /var/log/me/rsync_backup.log
print(" ")
print("#" * 75)
print(get_dt())
print("#" * 75)
print(" ")
# Update timestamp on backup file, notify user that backup has started
Path("/var/log/me/rsync_backup_ran").touch()
notify_send("Daily backup started","%s" % get_dt(),"info")
# Every week, start over with current files
if today_name != "Sunday":
rsync_command = "rsync -avbH --stats --exclude-from=/home/me/bin/rsync_backup.ecl"
else:
rsync_command = "rsync -avH --stats --exclude-from=/home/me/bin/rsync_backup.ecl " \
"--delete --delete-excluded"
# System configs, crontabs, installed software lists
INSTALLED = "/home/me/.config/installed"
if not os.path.isdir(INSTALLED):
os.mkdir(INSTALLED)
os.system("dpkg --get-selections > %s/installed-software" % INSTALLED)
os.system("ls /home/me/.local/share/flatpak/app > %s/installed-flatpaks" % INSTALLED)
os.system("rsync -avb /etc/apt/sources.list.d %s" % INSTALLED)
os.system("rsync -avb /var/spool/cron %s" % INSTALLED)
os.system("rsync -avb /etc/libvirt/qemu %s" % INSTALLED)
# My data
for i in range(3):
cmd_format = "%s %s %s/%s/daily"
cmd_info = (rsync_command, backup_paths[i], backup_root, backup_folders[i])
os.system(cmd_format % cmd_info)
notify_send("Daily backup ended","%s" % get_dt(),"info")
daily_backup()
The script works, except for that the header I create (at the top of the function) doesn't get printed until after all of the os.system calls. Is this normal behavior? How can I correct this?
It's probably a problem with the stdout.
Try to force it following this SO previous post

Play WSClient Nosuchmethod error with Spark 2.2 Snapshot

I'm using a Play WsClient to send requests to a Spray server endpoint that fronts a Spark driver program. The problematic call is here:
def serializeDataset(requestUrl: String, recipe: Recipe): Future[(Option[String], String, Int)] = {
ws.url(requestUrl).post(Json.toJson(recipe)).map { response =>
val code = (response.json \ "code").as[Int]
code match {
case OK => ((response.json \ "uuid").asOpt[String], (response.json \ "schema").as[String], code)
case _ => ((response.json \ "message").asOpt[String], "", code)
}
}
}
When executed, I get this error
Caused by: java.lang.NoSuchMethodError: io.netty.util.internal.PlatformDependent.newAtomicIntegerFieldUpdater(Ljava/lang/Class;Ljava/lang/String;)Ljava/util/concurrent/atomic/AtomicIntegerFieldUpdater;
at org.asynchttpclient.netty.NettyResponseFuture.<clinit>(NettyResponseFuture.java:52)
at org.asynchttpclient.netty.request.NettyRequestSender.newNettyResponseFuture(NettyRequestSender.java:311)
at org.asynchttpclient.netty.request.NettyRequestSender.newNettyRequestAndResponseFuture(NettyRequestSender.java:193)
at org.asynchttpclient.netty.request.NettyRequestSender.sendRequestWithCertainForceConnect(NettyRequestSender.java:129)
at org.asynchttpclient.netty.request.NettyRequestSender.sendRequest(NettyRequestSender.java:107)
at org.asynchttpclient.DefaultAsyncHttpClient.execute(DefaultAsyncHttpClient.java:216)
at org.asynchttpclient.DefaultAsyncHttpClient.executeRequest(DefaultAsyncHttpClient.java:184)
at play.api.libs.ws.ahc.AhcWSClient.executeRequest(AhcWS.scala:45)
at play.api.libs.ws.ahc.AhcWSRequest$.execute(AhcWS.scala:90)
at play.api.libs.ws.ahc.AhcWSRequest$$anon$2.execute(AhcWS.scala:166)
at play.api.libs.ws.ahc.AhcWSRequest.execute(AhcWS.scala:168)
at play.api.libs.ws.WSRequest$class.post(WS.scala:510)
at play.api.libs.ws.ahc.AhcWSRequest.post(AhcWS.scala:107)
at webservices.DataFrameService.serializeDataset(DataFrameService.scala:36)
It looks like the WSClient is picking up a version of Netty that doesn't include the relevant function.
This issue occurs when I compile the application with the 2.2-SNAPSHOT version of Spark, but not when I compile with the 2.1 version. I don't have an idea as to why this change would make a difference. The Spark driver program is a separate project in my sbt build.
My suspicion is that this has something to do with the packaging of the application and its dependencies. Here is what I have tried in sbt to recitify:
Added an explicit ("io.netty" % "netty-all" % "4.0.43.Final") to my dependencies
Added exclude statements to the spark imports like so:
"org.apache.spark" %% "spark-sql" % sparkV exclude("org.jboss.netty","netty") exclude("io.netty","netty")
"org.apache.spark" %% "spark-core" % sparkV exclude("org.jboss.netty","netty") exclude("io.netty","netty")
"org.apache.spark" %% "spark-mllib" % sparkV exclude("org.scalamacros", "quasiquotes") exclude("org.jboss.netty","netty") exclude("io.netty","netty")
"org.apache.spark" %% "spark-hive" % sparkV exclude("org.scalamacros", "quasiquotes") exclude("org.jboss.netty","netty") exclude("io.netty","netty")
Changed the order in which the play-ws module is added to the project dependencies (moved it to the end, moved it to the beginning)
Any help much appreciated.
On further review, I found that there was a lingering dependency to the Spark libraries within the Play project. I removed this and it seems to be working.

ClassNotFoundException while building jar in SBT

Hi all,
I'm using SBT to build my project, and here is the structure of my project.
HiveGenerator
├── build.sbt
├---lib
├── project
│ ├──
│ ├── assembly.sbt
│ └── plugins.sbt
├──
├──
└── src
└── main
└── scala
└── Main.scala
But i'm facing this error "java.lang.ClassNotFoundException: package.classname", no matter how many times i build it.
I have used,
sbt clean package
sbt clean assembly,but with no luck.My class is always missing from the jar.
Here is my build.sbt
lazy val root = (project in file(".")).
settings(
name := "kafkaToMaprfs",
version := "1.0",
scalaVersion := "2.10.5",
mainClass in Compile := Some("classname")
)
libraryDependencies ++= Seq(
"org.apache.spark" % "spark-hive_2.10" % "1.6.1",
"org.apache.spark" % "spark-core_2.10" % "1.6.1",
"org.apache.spark" % "spark-sql_2.10" % "1.6.1",
"com.databricks" % "spark-avro_2.10" % "2.0.1",
"org.apache.avro" % "avro" % "1.8.1",
"org.apache.avro" % "avro-mapred" % "1.8.1",
"org.apache.avro" % "avro-tools" % "1.8.1",
"org.apache.spark" % "spark-streaming_2.10" % "1.6.1",
"org.apache.spark" % "spark-streaming-kafka_2.10" % "1.6.1",
"org.codehaus.jackson" % "jackson-mapper-asl" % "1.9.13",
"org.openrdf.sesame" % "sesame-rio-api" % "2.7.2",
"log4j" % "log4j" % "1.2.17",
"com.twitter" % "bijection-avro_2.10" % "0.7.0"
)
mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
{
case PathList("META-INF", xs # _*) => MergeStrategy.discard
case x => MergeStrategy.first
}
}
Here is my assembly.sbt
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.3")
plugins.sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.7.0")
resolvers += Resolver.url("bintray-sbt-plugins", url("http://dl.bintray.com/sbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
resolvers += "OSS Sonatype" at "https://repo1.maven.org/maven2/"
However, im not able to build a fat jar or you can say jar-with-dependencies.jar like in maven.
In maven we have
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
Which helped me to accomplish this.
My question is,
*1. why am i not building a jar with all the classes in it?
2.Which commands should i use to create a jar with dependencies in sbt?
3.To we have anything equivalent to "descriptorRefs" in sbt to do the magic?*
Last question , which i didnt find answer to,
can't we achieve a proper output with sbt should we always use spark-submit to make it happen(not considering local or cluster modes)?
Thanks in advance.
Try deleting your ~/.ivy2/ or moving it out of the way and rebuild, letting everything reload from the net. Of course, you'll have to rebuild all of your local builds that contribute to your assembly as well.
I found your post because I had the same problem, this fixed it. It may not solve your issue, but it does solve some issues of this nature (I've seen it quite a bit).

How to avoid having version numbers in .so file name

I'm trying to build a dynamic library on Linux using qmake. Here is my .pro file:
TEMPLATE = lib
TARGET = sqxUiBase
QT += core gui
CONFIG += dll
INCLUDEPATH += ../../public/include
DEPENDPATH += .
UI_DIR += ../GeneratedFiles
RCC_DIR += ../GeneratedFiles
CONFIG(release, debug|release) {
DESTDIR = ../lib/release
LIBS += -L"../lib/release"
MOC_DIR += ../GeneratedFiles/release
OBJECTS_DIR += release
} else {
DESTDIR = ../lib/debug
LIBS += -L"../lib/debug"
MOC_DIR += ../GeneratedFiles/debug
OBJECTS_DIR += debug
}
include(sqxUiBase.pri)
The sqxUiBase.pri file contains the list of files that need to be built.
Now, the problem is that whatever I do, the resulting file is always named sqxUiBase.so.1.0.0, with a bunch of symlinks (sqxUiBase.so, sqxUiBase.so.1 and sqxUiBase.so.1.0) pointing to it. How can I make it so that there's only a sqxUiBase.so file and no links?
What you are looking for is making a plugin.
Add CONFIG += plugin to your project file, and qmake will generate a Makefile that builds a libFoo.so file, without the numbered links
After looking at the qmake source I found CONFIG += unversioned_libname for nix and CONFIG += skip_target_version_ext for windows.

Resources