I am trying to develop with Play Framework version 2.5, and I cannot get the database connection right. I am using H2 database with Ebean plugin 3.0.2 as an ORM. I tried several options for the entries in application.conf, based on the information found on Play Framework website and many of your posts. Please find below the entries to my configuration files and the error trace and help me :
**Application.conf**
play.db {
# The combination of these two settings results in "db.default" as the
#default JDBC pool:
config = "db"
default = "default"
prototype {
# Sets a fixed JDBC connection pool size of 50
#hikaricp.minimumIdle = 50
#hikaricp.maximumPoolSize = 50
}
}
db {
default.hikaricp.dataSourceClassName = org.h2.jdbcx.JdbcDataSource
default.driver = org.h2.Driver
default.url = "jdbc:h2:mem:play"
default.username = sa
default.password = ""
ebean.default = ["models.*"]
#play.ebean.default.dataSource = default
default.logSql=true
}
**Plugins.sbt**
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.10")
// Web plugins
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.4")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.8")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")
addSbtPlugin("org.irundaia.sbt" % "sbt-sassify" % "1.4.6")
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")
enablePlugins(PlayEbean).
addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "3.0.2")
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" %
"5.0.1")
**Build.sbt**
name := """Institut"""
version := "1.0-SNAPSHOT"
lazy val Institut = (project in
file(".")).enablePlugins(PlayJava,PlayEbean)
scalaVersion := "2.11.7"
libraryDependencies ++= Seq(
javaJdbc,
cache,
javaWs,
evolutions
)
**Console output**
[info] application - Creating Pool for datasource 'ebean'
[error] c.z.h.HikariConfig - HikariPool-1 - dataSource or
dataSourceClassName
or jdbcUrl is required.
[info] application - Creating Pool for datasource 'ebean'
[error] c.z.h.HikariConfig - HikariPool-2 - dataSource or
dataSourceClassName
or jdbcUrl is required.
[info] application - Creating Pool for datasource 'ebean'
[error] c.z.h.HikariConfig - HikariPool-3 - dataSource or
dataSourceClassName
or jdbcUrl is required.
[info] application - Creating Pool for datasource 'ebean'
[error] c.z.h.HikariConfig - HikariPool-4 - dataSource or
dataSourceClassName
or jdbcUrl is required.
[error] application -
! #736eodoo7 - Internal server error, for (GET) [/] ->
play.api.Configuration$$anon$1: Configuration error[Cannot connect to
database [ebean]]
at play.api.Configuration$.configError(Configuration.scala:154)
at play.api.Configuration.reportError(Configuration.scala:806)
at
play.api.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:48)
at playi.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:42)
at scala.collection.immutable.List.foreach(List.scala:381)
at play.api.db.DefaultDBApi.connect(DefaultDBApi.scala:42)
at play.api.db.DBApiProvider.get$lzycompute(DBModule.scala:72)
at play.api.db.DBApiProvider.get(DBModule.scala:62)
at play.api.db.DBApiProvider.get(DBModule.scala:58)
at
Caused by: play.api.Configuration$$anon$1: Configuration
error[dataSource or
dataSourceClassName or jdbcUrl is required.]
at play.api.Configuration$.configError(Configuration.scala:154)
at play.api.PlayConfig.reportError(Configuration.scala:996)
at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:70)
at play.api.db.PooledDatabase.createDataSource(Databases.scala:199)
at
play.api.db.DefaultDatabase.dataSource$lzycompute(Databases.scala:123)
at play.api.db.DefaultDatabase.dataSource(Databases.scala:121)
at play.api.db.DefaultDatabase.getConnection(Databases.scala:142)
at play.api.db.DefaultDatabase.getConnection(Databases.scala:138)
at
play.api.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:44)
at
play.api.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:42)
Caused by: java.lang.IllegalArgumentException: dataSource or
dataSourceClassName or jdbcUrl is required.
at com.zaxxer.hikari.HikariConfig.validate(HikariConfig.java:786)
at play.api.db.HikariCPConfig.toHikariConfig(HikariCPModule.scala:141)
at
at scala.util.Try$.apply(Try.scala:192)
at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:54)
at play.api.db.PooledDatabase.createDataSource(Databases.scala:199)
at
play.api.db.DefaultDatabase.dataSource$lazycompute(Databases.scala:123)
at play.api.db.DefaultDatabase.dataSource(Databases.scala:121)
at play.api.db.DefaultDatabase.getConnection(Databases.scala:142)
I had the same error message with H2 configuration , which was resolved be adding the dataSourceClassName, however I have tried to use default as datasource for Ebean without success.
Thank you !
ebean.default = ["models.*"] is not a member of the key db.default you have to place it outside of db.
According to your log ebean thinks that this key is another database
play.api.Configuration$$anon$1: Configuration error[Cannot connect to
database [ebean]]
More info here:
https://www.playframework.com/documentation/2.5.x/JavaDatabase#H2-database-engine-connection-properties
Related
I am following the NiFi 1.10 stateless guildeline to create a simple process group of executing a sql in mysql db. I have put necessary parm of db controller service to parameter context.
it works well in nifi canvas. Then i add it to registry and prepare a json parm file: stateless-simpledb.json
{
"registryUrl": "http://localhost:18080",
"bucketId": "cac8f127-e328-45c1-a4cb-0e03dc837ceb",
"flowId": "cc2753f2-78f3-4449-a2fd-343dfeaafe15",
"flowVersion": "3",
"parameters": {
"lastIngestId" : "20000",
"mysql-jdbc-driver-name" : "com.mysql.jdbc.Driver",
"db-user" : "root",
"db-password" : "password",
"db-con-url" : "jdbc:mysql://localhost:3306/mms",
"jdbc-jar-path" : "/program/jdbc/mysql-connector-java.jar"
}
}
and run the one-off command:
/program/nifi/bin/nifi.sh stateless RunFromRegistry Once --file /app/poc/nifi-stateless/conf/stateless-simpledb.json
It raise error:
=== FlowFileRepository Type ===
org.apache.nifi.controller.repository.RocksDBFlowFileRepository
org.apache.nifi:nifi-framework-nar:1.10.0 || /program/nifi-1.10.0/work/stateless-nars/nifi-framework-nar-1.10.0.nar-unpacked
org.apache.nifi.controller.repository.WriteAheadFlowFileRepository
org.apache.nifi:nifi-framework-nar:1.10.0 || /program/nifi-1.10.0/work/stateless-nars/nifi-framework-nar-1.10.0.nar-unpacked
org.apache.nifi.controller.repository.VolatileFlowFileRepository
org.apache.nifi:nifi-framework-nar:1.10.0 || /program/nifi-1.10.0/work/stateless-nars/nifi-framework-nar-1.10.0.nar-unpacked
=== End FlowFileRepository types ===
23:32:32.626 [main] INFO org.apache.nifi.stateless.bootstrap.ExtensionDiscovery - Successfully discovered extensions in 4411 milliseconds
23:32:32.633 [main] DEBUG org.apache.nifi.stateless.core.ComponentFactory - Setting context class loader to org.apache.nifi.nar.InstanceClassLoader#50fa5938 (parent = org.apache.nifi.nar.NarClassLoader[/program/nifi-1.10.0/work/stateless-nars/nifi-dbcp-service-nar-1.10.0.nar-unpacked]) to create org.apache.nifi.dbcp.DBCPConnectionPool
23:32:32.647 [main] DEBUG org.apache.nifi.parameter.ExpressionLanguageAwareParameterParser - For input #{jdbc-jar-path} found 1 Parameter references: [org.apache.nifi.parameter.StandardParameterReference#2d3eecda]
23:32:32.650 [main] DEBUG org.apache.nifi.parameter.ExpressionLanguageAwareParameterParser - For input /program/jdbc/mysql-connector-java.jar found 0 Parameter references: []
23:32:32.651 [main] DEBUG org.apache.nifi.parameter.ExpressionLanguageAwareParameterParser - For input 500 millis found 0 Parameter references: []
23:32:32.651 [main] DEBUG org.apache.nifi.parameter.ExpressionLanguageAwareParameterParser - For input 8 found 0 Parameter references: []
23:32:32.651 [main] DEBUG org.apache.nifi.parameter.ExpressionLanguageAwareParameterParser - For input 0 found 0 Parameter references: []
23:32:32.651 [main] DEBUG org.apache.nifi.parameter.ExpressionLanguageAwareParameterParser - For input 8 found 0 Parameter references: []
23:32:32.651 [main] DEBUG org.apache.nifi.parameter.ExpressionLanguageAwareParameterParser - For input -1 found 0 Parameter references: []
23:32:32.651 [main] DEBUG org.apache.nifi.parameter.ExpressionLanguageAwareParameterParser - For input -1 found 0 Parameter references: []
23:32:32.651 [main] DEBUG org.apache.nifi.parameter.ExpressionLanguageAwareParameterParser - For input 30 mins found 0 Parameter references: []
23:32:32.651 [main] DEBUG org.apache.nifi.parameter.ExpressionLanguageAwareParameterParser - For input -1 found 0 Parameter references: []
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.nifi.bootstrap.RunStatelessNiFi.main(RunStatelessNiFi.java:69)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.nifi.StatelessNiFi.main(StatelessNiFi.java:103)
... 5 more
Caused by: java.lang.RuntimeException: Failed to enable Controller Service {id=691ecc97-ff46-3a5e-8aad-37dc568bc247, name=MYSQL-MMS-stateless-test, type=class org.apache.nifi.dbcp.DBCPConnectionPool} because validation failed: ['Database Connection URL' is invalid because Database Connection URL is required, 'Database Driver Class Name' is invalid because Database Driver Class Name is required]
at org.apache.nifi.stateless.core.StatelessControllerServiceLookup.enableControllerServices(StatelessControllerServiceLookup.java:133)
at org.apache.nifi.stateless.core.StatelessFlow.<init>(StatelessFlow.java:153)
at org.apache.nifi.stateless.core.StatelessFlow.createAndEnqueueFromJSON(StatelessFlow.java:469)
at org.apache.nifi.stateless.runtimes.Program.runLocal(Program.java:133)
at org.apache.nifi.stateless.runtimes.Program.launch(Program.java:67)
... 10 more
Seems the apache nifi stateless function failed to set controller service even it's in "process group" scope.
Would anyone has any advice?
As mentioned in the comments, this appears to be a known problem with the validation of controller services.
This can be avoided by using Nifi 1.12 and above as it got fixed in the following jira: https://issues.apache.org/jira/plugins/servlet/mobile#issue/NIFI-7380
Though I am not entirely sure of this, it may also be possible that this simply indicates that your controller service is not configured correctly. This would be worth double checking.
I'm tried to set up playframe work on OSX and bumped into some troubles.
Download Typesafe Activator and set up as this procedure. https://www.playframework.com/documentation/2.4.x/
"activator new test" -> "cd test" -> "activator run"
Access localhost:9000 with Safari to get a message Failed to open page
Some error messages are there as below.
Is there any idea to solve the problem?
% activator run +[master]
[info] Loading project definition from /Users/w256/Library/Mobile Documents/com~apple~CloudDocs/000.now/vo/scala-getting-started/project
[info] Updating {file:/Users/w256/Library/Mobile%20Documents/com~apple~CloudDocs/000.now/vo/scala-getting-started/project/}scala-getting-started-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to play-getting-started (in build file:/Users/w256/Library/Mobile%20Documents/com~apple~CloudDocs/000.now/vo/scala-getting-started/)
[info] Updating {file:/Users/w256/Library/Mobile%20Documents/com~apple~CloudDocs/000.now/vo/scala-getting-started/}root...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies.
[warn] Here are some of the libraries that were evicted:
[warn] * io.netty:netty:3.10.1.Final -> 3.10.4.Final
[warn] Run 'evicted' to see detailed eviction warnings
--- (Running the application, auto-reloading is enabled) ---
[info] p.c.s.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
(Server started, use Ctrl+D to stop and go back to the console...)
[error] p.c.s.n.PlayDefaultUpstreamHandler - Exception caught in Netty
java.lang.NoSuchMethodError: org.jboss.netty.handler.codec.http.HttpRequest.headers()Lorg/jboss/netty/handler/codec/http/HttpHeaders;
at play.core.server.netty.PlayDefaultUpstreamHandler.getHeaders(PlayDefaultUpstreamHandler.scala:320) ~[play-netty-server_2.11-2.4.3.jar:2.4.3]
at play.core.server.netty.PlayDefaultUpstreamHandler.messageReceived(PlayDefaultUpstreamHandler.scala:90) ~[play-netty-server_2.11-2.4.3.jar:2.4.3]
at com.typesafe.netty.http.pipelining.HttpPipeliningHandler.messageReceived(HttpPipeliningHandler.java:62) ~[netty-http-pipelining.jar:na]
at org.jboss.netty.handler.codec.http.HttpContentDecoder.messageReceived(HttpContentDecoder.java:104) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:455) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:538) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:437) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255) ~[netty-3.5.7.Final.jar:na]
[error] p.c.s.n.PlayDefaultUpstreamHandler - Exception caught in Netty
java.lang.NoSuchMethodError: org.jboss.netty.handler.codec.http.HttpRequest.headers()Lorg/jboss/netty/handler/codec/http/HttpHeaders;
at play.core.server.netty.PlayDefaultUpstreamHandler.getHeaders(PlayDefaultUpstreamHandler.scala:320) ~[play-netty-server_2.11-2.4.3.jar:2.4.3]
at play.core.server.netty.PlayDefaultUpstreamHandler.messageReceived(PlayDefaultUpstreamHandler.scala:90) ~[play-netty-server_2.11-2.4.3.jar:2.4.3]
at com.typesafe.netty.http.pipelining.HttpPipeliningHandler.messageReceived(HttpPipeliningHandler.java:62) ~[netty-http-pipelining.jar:na]
at org.jboss.netty.handler.codec.http.HttpContentDecoder.messageReceived(HttpContentDecoder.java:104) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:455) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:538) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:437) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255) ~[netty-3.5.7.Final.jar:na]
[error] p.c.s.n.PlayDefaultUpstreamHandler - Exception caught in Netty
java.lang.NoSuchMethodError: org.jboss.netty.handler.codec.http.HttpRequest.headers()Lorg/jboss/netty/handler/codec/http/HttpHeaders;
at play.core.server.netty.PlayDefaultUpstreamHandler.getHeaders(PlayDefaultUpstreamHandler.scala:320) ~[play-netty-server_2.11-2.4.3.jar:2.4.3]
at play.core.server.netty.PlayDefaultUpstreamHandler.messageReceived(PlayDefaultUpstreamHandler.scala:90) ~[play-netty-server_2.11-2.4.3.jar:2.4.3]
at com.typesafe.netty.http.pipelining.HttpPipeliningHandler.messageReceived(HttpPipeliningHandler.java:62) ~[netty-http-pipelining.jar:na]
at org.jboss.netty.handler.codec.http.HttpContentDecoder.messageReceived(HttpContentDecoder.java:104) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:455) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:538) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:437) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255) ~[netty-3.5.7.Final.jar:na]
"activator ui" makes similar errors as below.
% activator ui +[master]
Found previous process id: 9525
Local repository: activator-launcher-local # file:/usr/local/Cellar/typesafe-activator/1.3.6/libexec/repository
Local repository: activator-local # file:/Users/w256/Downloads/activator-dist-1.3.7/repository
Play server process ID is 12608
[info] play - Application started (Prod)
[info] play - Listening for HTTP on /127.0.0.1:8888
[error] p.nettyException - Exception caught in Netty
java.lang.NoSuchMethodError: org.jboss.netty.handler.codec.http.HttpRequest.headers()Lorg/jboss/netty/handler/codec/http/HttpHeaders;
at play.core.server.netty.PlayDefaultUpstreamHandler.getHeaders(PlayDefaultUpstreamHandler.scala:366) ~[play_2.11-2.3.9.jar:2.3.9]
at play.core.server.netty.PlayDefaultUpstreamHandler.messageReceived(PlayDefaultUpstreamHandler.scala:87) ~[play_2.11-2.3.9.jar:2.3.9]
at com.typesafe.netty.http.pipelining.HttpPipeliningHandler.messageReceived(HttpPipeliningHandler.java:62) ~[netty-http-pipelining-1.1.2.jar:na]
at org.jboss.netty.handler.codec.http.HttpContentDecoder.messageReceived(HttpContentDecoder.java:104) ~[netty-3.5.7.Final.jar:na]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296) ~[netty-3.5.7.Final.jar:na]
build.sbt is here.
name := """play-getting-started"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.7"
libraryDependencies ++= Seq(
jdbc,
cache,
"org.postgresql" % "postgresql" % "9.4-1201-jdbc41",
"org.jscience" % "jscience" % "4.3.1",
ws,
"com.typesafe.play" % "play-netty-server_2.11" % "2.4.3" force(),
"io.netty" % "netty" % "3.10.4.Final" force(),
"com.typesafe.netty" % "netty-http-pipelining" % "1.1.4" force()
)
libraryDependencies <+= scalaVersion("org.scala-lang" % "scala-compiler" % _ )
I have a spray http client which is running in a server X, which will make connections to server Y. Server Y is kind of slow(will take 3+ sec for a request)
This is my http client code invocation:
def get() {
val result = for {
response <- IO(Http).ask(HttpRequest(GET,Uri(getUri(msg)),headers)).mapTo[HttpResponse]
} yield response
result onComplete {
case Success(res) => sendSuccess(res)
case Failure(error) => sendError(res)
}
}
These are the configurations I have in application.conf:
spray.can {
client {
request-timeout = 30s
response-chunk-aggregation-limit = 0
max-connections = 50
warn-on-illegal-headers = off
}
host-connector {
max-connections = 128
idle-timeout = 3s
}
}
Now I tried to abuse the server X with large number of concurrent requests(using ab with n=1000 and c=100).
Till 900 requests it went fine. After that the server threw lot of exceptions and I couldn't hit the server after that.
These are the exceptions:
[info] [ERROR] [03/28/2015 17:33:13.276] [squbs-akka.actor.default-dispatcher-6] [akka://squbs/system/IO-TCP/selectors/$a/0] Accept error: could not accept new connection
[info] java.io.IOException: Too many open files
[info] at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
[info] at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:241)
[info] at akka.io.TcpListener.acceptAllPending(TcpListener.scala:103)
and on further hitting the same server, it threw the below exception:
[info] [ERROR] [03/28/2015 17:53:16.735] [hcp-client-akka.actor.default-dispatcher-6] [akka://hcp-client/system/IO-TCP/selectors] null
[info] akka.actor.ActorInitializationException: exception during creation
[info] at akka.actor.ActorInitializationException$.apply(Actor.scala:164)
[info] at akka.actor.ActorCell.create(ActorCell.scala:596)
[info] Caused by: java.lang.reflect.InvocationTargetException
[info] at sun.reflect.GeneratedConstructorAccessor59.newInstance(Unknown Source)
[info] Caused by: java.io.IOException: Too many open files
[info] at sun.nio.ch.IOUtil.makePipe(Native Method)
I was previously using apache http client(which was synchronous) which was able to handle 10000+ requests with concurrency of 100.
I'm not sure I'm missing something. Any help would be appreciated.
The problem is that every time you call get() method it creates a new actor that creates at least one connection to the remote server. Furthermore you never shut down that actor, so each such connection leaves until it times out.
You only need a single such actor to manage all your HTTP requests, thus to fix it take IO(Http) out of the get() method and call it only once. Reuse that returned ActorRef for all your requests to that server. Shut it down on application shutdown.
For example:
val system: ActorSystem = ...
val io = IO(Http)(system)
io ! Http.Bind( ...
def get(): Unit = {
...
io.ask ...
// or
io.tell ...
}
i'm trying to deploy a play! framework 2.3.3 application to heroku this is the response from deployment window
Initializing repository, done.
Counting objects: 814, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (786/786), done.
Writing objects: 100% (814/814), 5.80 MiB | 10.00 KiB/s, done.
Total 814 (delta 316), reused 0 (delta 0)
-----> Play 2.x - Java app detected
-----> Installing OpenJDK 1.8...done
-----> Downloading SBT...done
-----> Priming Ivy cache (Scala-2.11, Play-2.3)... done
-----> Running: sbt update
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=512M; suppo
rt was removed in 8.0
[info] Loading project definition from /tmp/scala_buildpack_build_dir/pro
ject
[error] /tmp/scala_buildpack_build_dir/project/Build.scala:3: object Proj
ect is not a member of package play
[error] import play.Project._
[error] ^
[error] /tmp/scala_buildpack_build_dir/project/Build.scala:14: not found:
value filters
[error] filters,
[error] ^
[error] /tmp/scala_buildpack_build_dir/project/Build.scala:20: not found:
value javaCore
[error] javaCore,
[error] ^
[error] /tmp/scala_buildpack_build_dir/project/Build.scala:21: not found:
value javaJdbc
[error] javaJdbc,
[error] ^
[error] /tmp/scala_buildpack_build_dir/project/Build.scala:22: not found:
value javaEbean
[error] javaEbean,
[error] ^
[error] /tmp/scala_buildpack_build_dir/project/Build.scala:23: not found:
value cache
[error] cache
[error] ^
[error] /tmp/scala_buildpack_build_dir/project/Build.scala:28: object Pro
ject is not a member of package play
[error] val main = play.Project(appName, appVersion, appDependencies)
.settings(
[error] ^
[error] 7 errors found
[error] (compile:compile) Compilation failed
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? ! Fail
ed to run sbt task: update
! Push rejected, failed to compile Play 2.x - Java app
To git#heroku.com:obscure-scrubland-1026.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:obscure-scrubland-1026.git'
this is a what build.sbt looks like
import play.PlayJava
name := "schoolapp"
scalaVersion := "2.11.1"
version := "1.0-SNAPSHOT"
val appDependencies = Seq(
"be.objectify" %% "deadbolt-java" % "2.3.0-RC1",
// Comment the next line for local development of the Play Authentication core:
"com.feth" %% "play-authenticate" % "0.6.5-SNAPSHOT",
"postgresql" % "postgresql" % "9.1-901-1.jdbc4",
javaCore,
cache,
javaWs,
javaJdbc,
javaEbean
)
resolvers ++= Seq(
"Apache" at "http://repo1.maven.org/maven2/",
"jBCrypt Repository" at "http://repo1.maven.org/maven2/org/",
"play-easymail (release)" at "http://joscha.github.io/play-easymail/repo/releases/",
"play-easymail (snapshot)" at "http://joscha.github.io/play-easymail/repo/snapshots/",
Resolver.url("Objectify Play Repository", url("http://schaloner.github.io/releases/"))(Resolver.ivyStylePatterns),
"play-authenticate (release)" at "http://joscha.github.io/play-authenticate/repo/releases/",
"play-authenticate (snapshot)" at "http://joscha.github.io/play-authenticate/repo/snapshots/"
)
// Uncomment the next line for local development of the Play Authenticate core:
//lazy val playAuthenticate = project.in(file("modules/play-authenticate")).enablePlugins(PlayJava)
lazy val root = project.in(file("."))
.enablePlugins(PlayJava)
.settings(
libraryDependencies ++= appDependencies
)
// Uncomment the next lines for local development of the Play Authenticate core:
//.dependsOn(playAuthenticate)
//.aggregate(playAuthenticate)
i'm using the play authenticate module. what could be the problem?
Try to remove import play.Project._ and add import play.PlayImport._ in your project/Build.scala file.
First of I am using the play framework (Java) version 2.38. I am trying to connect MySQL to my application and it is giving me an unresolved dependency error. I have looked at all threads here on this topic and nothing has worked, this is what I have...
Application.conf
db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://127.0.0.1:3306/mydatabase"
db.default.user=root
db.default.password=""
plugins.sbt
resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"
// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.8")
// web plugins
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.0.0")
addSbtPlugin("mysql" % "mysql-connector-java" % "5.6.24")
build.sbt
name := """TestApp"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.11.1"
libraryDependencies ++= Seq(
javaJdbc,
javaEbean,
cache,
javaWs,
"mysql" % "mysql-connector-java" % "5.6.24"
)
libraryDependencies += "org.json" % "json" % "20141113"
fork in run := true
The error I am getting is the following
Error:Error while importing SBT project:
...
at sbt.std.Transform$$anon$4.work(System.scala:64)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
at sbt.Execute.work(Execute.scala:244)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[error] (*:update) sbt.ResolveException: unresolved dependency:
mysql#mysql-connector-java;5.6.24: not found
Invalid response.
Invalid response.
Invalid response.
Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=384M; support was removed in 8.0
See complete log in C:\Users\testingapp\.IntelliJIdea14
\system\log\sbt.last.log
I do not know if I am doing something wrong or if the SBT is failing somewhere, any suggestions?
MySQL java connector versions don't correlate to MySQL server versions.
See MySQL Connector/J compatibility chart for details.
The latest mysql-connector-java version for MySQL >= 4.0 as of writing is 5.1.35 (see Maven Central).
You should change your dependency declaration accordingly.
"mysql" % "mysql-connector-java" % "5.1.35"