0

I just reinstalled my Operating System from Ubuntu 10.04 to 12.04, and I was using play 2.0.1 on ubuntu 10.04, everything was working ok on 10.04, but now with the same play 2.0.1 things messed up and now every time I run the command play "run 80" the server starts but when I hit index page of my app it gives me following exception:

[error] application - 

! @6bh1b1h5g - Internal server error, for request [GET /] ->

play.api.Configuration$$anon$1: Configuration error [Cannot connect to database [mytestdb]]
    at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:71) ~[play_2.9.1.jar:2.0.1]
    at play.api.Configuration.reportError(Configuration.scala:258) ~[play_2.9.1.jar:2.0.1]
    at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:240) ~[play_2.9.1.jar:2.0.1]
    at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:231) ~[play_2.9.1.jar:2.0.1]
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194) ~[scala-library.jar:0.11.2]
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194) ~[scala-library.jar:0.11.2]

and before comming to this forum I double checked that:

  1. mysql is running.
  2. user has sufficient privileges (by logging this user and run some select commands on this db inside bash terminal).
  3. my project compiles successfully.

configuration file with some minor changes:

# This is the main configuration file for the application.
# ~~~~~

# Secret key
# ~~~~~
# The secret key is used to secure cryptographics functions.
# If you deploy your application to several instances be sure to use the same key!
application.secret="*********************************"

# The application languages
# ~~~~~
application.langs="en"

# Global object class
# ~~~~~
# Define the Global object class for this application.
# Default to Global in the root package.
# global=Global

# Database configuration
# ~~~~~ 
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#

db.mytestdb.url="mysql://user1:user1@127.0.0.1:3306/mytestdb"
db.mytestdb.driver=com.mysql.jdbc.Driver
db.mytestdb.user="user1"
db.mytestdb.pass="user1"
db.mytestdb.jndiName=mytestdbDS

jpa.default=TESTmytestdb
jpa.TESTmytestdb=TESTmytestdb

# Logger
# ~~~~~
# You can also configure logback (http://logback.qos.ch/), by providing a logger.xml file in the conf directory .

# Root logger:
logger.root=ERROR

# Logger used by the framework:
logger.play=INFO

# Logger provided to your application:
logger.application=DEBUG
gmuhammad
  • 1,434
  • 4
  • 25
  • 39
  • Show us your configuration for this DB, whole, change only password to `***` and nothing else. – biesior Sep 02 '12 at 11:25
  • added the configuration file with some minor changes (user, password, and db name) – gmuhammad Sep 02 '12 at 12:01
  • Have you tried with `localhost` instead of `127.0.0.1`. Maybe it comes from the binding address in the MySQL config (http://serverfault.com/a/139324). – ndeverge Sep 02 '12 at 12:16
  • @nico_ekito: how it was working on ubuntu 10.04 with 127.0.0.1. it seems pretty odd to me using localhost, but lemme try with that and I'll let you know. – gmuhammad Sep 02 '12 at 12:20
  • @nico_ekito: no change getting same error. – gmuhammad Sep 02 '12 at 12:26
  • Have you tried connecting with the mysql client: `mysql -h 127.0.0.1 -u user1 -p mytestdb`. It will tell if it comes from Play or the MySQL server (grant privileges or something else). – ndeverge Sep 02 '12 at 12:32
  • @nico_ekito: I tried that from terminal and it connected to that db. I actually tried to login to mysql using that user before comming to the forum but on your request I tried to connect to directly db and it did connect from terminal. – gmuhammad Sep 02 '12 at 12:43
  • Try replacing "mysql://user1:user1@127.0.0.1:3306/mytestdb" by "mysql://127.0.0.1/mytestdb". – ndeverge Sep 02 '12 at 12:49
  • Same result. One thing I remember is that on 10.04 I was running with Sun JDK and on 12.04 I have Open JDK. Does it make any difference? – gmuhammad Sep 02 '12 at 13:34

3 Answers3

0

I think that's about your URL check other answer and fix it:

https://stackoverflow.com/a/10007515/1066240

Community
  • 1
  • 1
biesior
  • 55,576
  • 10
  • 125
  • 182
  • val appDependencies = Seq( "mysql" % "mysql-connector-java" % "5.1.18", "org.hibernate" % "hibernate-entitymanager" % "3.6.9.Final", "org.apache.httpcomponents" % "httpclient" % "4.1.3", "com.github.mumoshu" %% "play2-memcached" % "0.2.1-SNAPSHOT") – gmuhammad Sep 02 '12 at 12:29
  • it's already there. (If I am not wrong that's what you were referring in the link). I already said that everything was in working condition on Ubuntu 10.04. :( – gmuhammad Sep 02 '12 at 12:30
  • Nope: I was refering to your `db.mytestdb.url="mysql://user1:user1@127.0.0.1..."` switch it to `db.mytestdb.url="jdbc:mysql://localhost/mytestdb?characterEncoding=UTF-8"` (jdbc at the beggining no credentials in url) – biesior Sep 02 '12 at 14:00
  • did that, still not working. One thing I remember is that on 10.04 I was running with Sun JDK and on 12.04 I have Open JDK. Does it make any difference? – gmuhammad Sep 02 '12 at 17:18
0

Have you tried removing user:password away from url like this?

db.mytestdb.url="jdbc:mysql://localhost:3306/mytestdb"
db.mytestdb.driver=com.mysql.jdbc.Driver
db.mytestdb.user="user1"
db.mytestdb.pass="user1"
demogorgon
  • 21
  • 2
0

It was memcached problem which was not started. Now I got it working by starting the memcached.

gmuhammad
  • 1,434
  • 4
  • 25
  • 39