Play 2.3 RjsKeys.mainModule causes Error: paths fallback not supported in optimizer - playframework-2.3

On build.sbt, if I use these configs for rjs,
RjsKeys.mainConfig := "build",
RjsKeys.mainModule := "mainAccount",
RjsKeys.modules += WebJs.JS.Object("name" -> "mainSFCanvas")
it gives me this error:
[info] Error: Error: paths fallback not supported in optimizer. Please provide a build config path override for angular
I have to make 'build' as mainModule to solve the above warning. Is this correct workaround?
RjsKeys.mainConfig := "build",
RjsKeys.mainModule := "build",
RjsKeys.modules := Seq(
WebJs.JS.Object("name" -> "mainAccount"),
WebJs.JS.Object("name" -> "mainSFCanvas")
)

Related

Error on importing go-sql-driver/sql from github repository

As the title says, I have an error when importing go-mysql-driver package. I have installed the go-my-sql driver in my machine but the error still persists. I use XAMPP for local hosting and here’s the block of program.
package model
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
)
type Table interface {
Name() string
Field() ([]string, []interface{})
}
func Connect(username string, password string, host string, database string) (*sql.DB, error) {
conn := fmt.Sprintf("%s:%s#tcp(%s:3306)/%s", username, password, host, database)
db, err := sql.Open("mysql", conn)
return db, err
}
func CreateDB(db *sql.DB, name string) error {
query := fmt.Sprintf("CREATE DATABASE %v", name)
_, err := db.Exec(query)
return err
}
func CreateTable(db *sql.DB, query string) error {
_, err := db.Exec(query)
return err
}
func DropDB(db *sql.DB, name string) error {
query := fmt.Sprintf("DROP DATABASE %v", name)
_, err := db.Exec(query)
return err
}
could not import github.com/go-sql-driver/mysql (no required modules provides package "github.com/go-sql-driver/mysql")
screenshot of what's happening
It seems that you read the tutorial for an older go version.
Go 1.17 requires dependencies must be explicitly in go.mod.
Maybe you could try go module first (https://go.dev/blog/using-go-modules)
Your IDE is not showing you the whole picture. By running go run main.go (or whatever main file you have) on the command line, you can see the same error as you're seeing on your IDE with some extra:
$ go run main.go
main.go:7:5: no required module provides package github.com/go-sql-driver/mysql; to add it:
go get github.com/go-sql-driver/mysql
By issuing the suggested command go get github.com/go-sql-driver/mysql, you'll get the dependency added to your go.mod file and the contents of the package will be downloaded to your machine.
Your next execution will work:
$ go run main.go
Hello world
I've made some small modifications to your code to work, I'll add them here for completeness:
I've used the same source, but changed the package name to main.
I've added a main function to the bottom of the file:
func main() {
fmt.Println("Hello world")
_, err := Connect("username", "password", "localhost", "db")
if err != nil {
panic(err)
}
}
I've saved to a file named main.go
I've initialized the go.mod file by running go mod init test and go mod tidy, then I took the steps described on the beginning of the answer.

Play framework: Unable to Inject Database object

I am trying to connect to mysql using play framework. I am new to play and unable to figure out the exact problem. Any help will be highly appreciated.
The configuration in conf\application.conf is as follows:
config = "db"
default = "default"
db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost/ng_play"
db.default.username=root
db.default.password="****"
ebean.default = ["models.*"]
build.sbt
name := """play-scala-tutorial-one"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.7"
libraryDependencies ++= Seq(
jdbc,
cache,
ws,
"mysql" % "mysql-connector-java" % "5.1.36",
"org.scalatestplus.play" %% "scalatestplus-play" % "1.5.1" % Test
)
resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"
Mysql version and database-connector version was mismatch. and also adding db.default.hikaricp.connectionTestQuery="SELECT TRUE" this to application.conf helped to mitigate one issue.
Thanks #silentprogrammer and #salem for help.

play 2.3 sbt-concat not working in prod

I want to use this plugin
addSbtPlugin("net.ground5hark.sbt" % "sbt-concat" % "0.1.8")
To concatenate my assets.
I have 3 groups :
Concat.groups := Seq(
"concat_main.css" -> group(Seq(
"stylesheets/bootstrap.min.css",
"stylesheets/font-awesome.css",
"stylesheets/totem/sidebar/component.css",
"stylesheets/main.min.css"
)),
"concat_main.js" -> group(Seq(
"javascripts/jquery-2.1.0.min.js",
"javascripts/bootstrap.min.js",
"javascripts/totemPage/sidebar/modernizr.custom.js",
"javascripts/totemPage/respond.min.js",
"javascripts/totemPage/html5shiv.js",
"javascripts/totemPage/sidebar/classie.js",
"javascripts/main.js"
)),
"concat_noel.js" -> group(Seq(
"javascripts/totemPage/ouibounce-modal.js",
"javascripts/ouibounce_modal.js",
"javascripts/homePage.js",
"javascripts/totemPage/jquery.cookie.js",
"javascripts/embed.js"
))
)
Concat.parentDir := "public/main/javascripts"
pipelineStages in Assets := Seq(concat, uglify, digest, gzip)
Files are generated in dev, I can access
<link rel="stylesheet" href="#routes.Assets.versioned("javascripts/concat_main.css")">
<script src="#routes.Assets.versioned("javascripts/concat_main.js")" type="text/javascript"></script>
But with activator start I have a 404.
At the sbt-web documentation you can read that:
If you have some need for the assets produced by the pipelineStages in
your development environment (during play run), then you can scope the
pipelineStages to the Assets config.
pipelineStages in Assets := Seq(myPipelineTask)
And this is what you have done which is setting the pipelineStages key scoped to the Assets configuration. However, this works only for the development mode. In order to run the pipeline in the production mode you have to set the pipelineStages key scoped to the Global configuration. In your case this will look like this:
pipelineStages := Seq(concat, uglify, digest, gzip)

How to connect to Amazon RDS using go-sql-driver

I can connect to the RDS instance using mysql -h ... command so I know it's not a security group problem.
I've tried to use:
sql.Open("mysql", "id:password#tcp(your-amazonaws-uri.com:3306)/dbname")
in the readme file of go-sql-driver(https://github.com/go-sql-driver/mysql), but it doesn't seem to work.
I'm using my username under the RDS instance instead of id here though.
Edit:
The error returned is: panic runtime error: invalid memory address or nil pointer deference [signal 0xb code=0x1 addr=0x20 pc=0x5b551e]
goroutine 16 [running]
runtime.panic(0x7d4fc0, 0xa6ca73)...database/sql.(*Rows).Next...
It works fine with my local DB.
The connection string for sql.Open() is in DSN format.
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
)
db, err := sql.Open("mysql", "<username>:<password>#tcp(<AWSConnectionEndpoint >:<port>)/<dbname>")
if err != nil {
fmt.Print(err.Error())
}
defer db.Close()
Make sure the actual error isn't related to an import issue (as in issues 266)
Check (to be sure you are using the latest versions, as in this issue):
your Go-MySQL-Driver version (or git SHA)
your Go version (run go version in your console)
If the error isn't directly in the Open step, but when accessing the Rows, check this comment out:
Use either a for loop (for rows.Next() { ... }) or something like this:
if rows.Next() {
// whatever
} else {
// catch error with rows.Err()
}
rows.Close() // <- don't forget this if you are not iterating over ALL results

Can't publish HTML to server using org-mode ox-publish

The relevant code from my .emacs is:
(require 'ox-publish)
(require 'ox-html)
(setq org-publish-project-alist
'(("org-html"
:base-directory "~/org/"
:base-extension "org"
:publishing-directory "/ssh:user#server:/public_html/"
:recursive t
:publishing-function org-html-publish-to-html
:table-of-contents: nil
:auto-postamble nil
)
("org-static"
:base-directory "~/org/"
:base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
:publishing-directory "/ssh:user#server:/public_html/"
:recursive t
:publishing-function org-publish-attachment
)
("org" :components ("org-html" "org-static"))
)
)
I get an error message which states the following:
byte-code: Couldn't find exit status of `test -e /public_html/'
It exports fine if I publish to a directory on my local machine and it was working for a minute but then stopped. Any clues?
I've the impression the problem is coming from Tramp, due to your ssh: spec for the remote file location.
Try first, maybe, to use Tramp against that remote dir, and check if everything's running fine.