Question

I am trying to deploy a Play 2 application in the cloud in CloudBees. I followed the instructions given in the CloudBees documentation. The database(mysql) gets created and the application gets deployed. Looking at the configuration, all seems fine

Application : pareeje/playconfig Title : pareeje/playconfig Created : Sun Jan 05 11:05:06 IST 2014 Status : active URL : playconfig.pareeje.cloudbees.net clusterSize : 1 container : java_free containerType : play2 hibernateTimeout: 21600 maxMemory : 256 proxyBuffering : false securityMode : PUBLIC serverPool : stax-global (Stax Global Pool)

But when I try to run the application, it fails stating 502 Bad Gateway, and the Logs display - Application is not running.

I do not know where I am going wrong. Is there any link, which explains the process step by step with a real example. That may help me to proceed.

Thanks.

Was it helpful?

Solution

You have seen on your logs "Application is not running" because you took a look to the logs when your application was hibernated. if you wake up your application, for example just doing a new request to http://playconfig.pareeje.cloudbees.net/ you will see that your logs tells you something different. In fact, you should see something like this:

Caused by: java.sql.SQLException: No suitable driver found for jdbc:jdbc:mysql://***********.compute-1.amazonaws.com/playconferance
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:363)
at com.jolbox.bonecp.BoneCP.<init>(BoneCP.java:416)
at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:120)
at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:245)
... 22 more

So I think it means you have an issue on your application. We have a play2 application example which could help you with the setup. See here.

In the application.conf file you should have something like this:

# Database configuration
# ~~~~~ 
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#
# db.default.driver=org.h2.Driver
# db.default.url="jdbc:h2:mem:play"
# db.default.user=sa
# db.default.password=

db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:"${DATABASE_URL_DB}
db.default.user=${DATABASE_USERNAME_DB}
db.default.password=${DATABASE_PASSWORD_DB}
db.default.maxConnectionsPerPartition=10
db.default.partitionCount=2

The steps you should follow are pretty simple for a play 2 application.

  1. Download and install the CoudBees SDK
  2. Create a blank application

    $bees app:create -t play2 -a appName

  3. Create a database

    $bees db:create dbName

  4. Bind the application to the database

    $bees app:bind -a appName -db dbName -as mydb

  5. Deploy your application

    $bees app:deploy -a appName -t play2 PATH_TO_WAR_FILE.zip

Application configuration:

# Database configuration
# ~~~~~ 
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#
# db.default.driver=org.h2.Driver
# db.default.url="jdbc:h2:mem:play"
# db.default.user=sa
# db.default.password=

db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:"${DATABASE_URL_DB}
db.default.user=${DATABASE_USERNAME_DB}
db.default.password=${DATABASE_PASSWORD_DB}
db.default.maxConnectionsPerPartition=10
db.default.partitionCount=2

OTHER TIPS

Great thanks user3164975. Finally I am able to deploy my app in Cloudbees, feels great. I also landed up with a very neat document http://ics-software-engineering.github.io/play-example-mysql/

Both this document and your suggestion helped me a lot! Thanks again!

My first application is up in the clouds :) ...!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top