1

Dear Heroku/Play experts,

I'm new to Heroku and Play 2.0 (with Java) and am trying to get my first db-backed Heroku app up and running (I'm using the zentask app for learning purposes). I've been reading the related documents on stackoverflow and @James Ward's Play2torial very thoroughly but can't seem to find a solution to a problem I'm having:

When pushing my files to Heroku I always get a "Driver not found" error for the postgres driver - just as if it weren't installed on Heroku. I've pretty much tried everything that you, the experts, have proposed as solutions but nothing has worked. I even tried copying a jdbc driver jar into the lib folder to compensate for the missing jdbc jar but then I get some error concerning missing validation - this might be because I couldn't find the jar for 9.1-901-1.jdbc4 on the postgres website. In any case, your solutions suggest that this postgres driver should be there out of the box as the standard setup of Heroku so I'm getting a bit frustrated...

Hence, please find below the "driver not found error" with the files involved and the resulting error message.

I would be very, very grateful for your advice. Thanks a lot in advance! Best,

Horacio


Here are my files:

Procfile:

web: target/start -Dhttp.port=${PORT} ${JAVA_OPTS} -Dconfig.resource=application.conf

Build.scala:

import sbt._
import Keys._

import PlayProject._

object ApplicationBuild extends Build {

    val appName         = "Myapp"
    val appVersion      = "1.0"

    val main = PlayProject(appName, appVersion, mainLang = JAVA)

    val appDependencies = Seq(
      "postgresql" % "postgresql" % "9.1-901-1.jdbc4"
    )
}

application.conf:

application.name=myapp

application.secret="some secret"

db.default.driver=org.postgresql.Driver

db.default.url="jdbc:postgresql://some URL"

ebean.default="models.*"

logger=ERROR

logger.play=INFO

logger.application=DEBUG

error message:

2012-11-23T17:39:35+00:00 heroku[web.1]: State changed from crashed to starting
2012-11-23T17:39:41+00:00 heroku[web.1]: Starting process with command `target/start -Dhttp.port=${PORT} ${JAVA_OPTS} -Dconfig.resource=application.conf`
2012-11-23T17:39:42+00:00 app[web.1]: Play server process ID is 2
2012-11-23T17:39:43+00:00 app[web.1]: Oops, cannot start the server.
2012-11-23T17:39:43+00:00 app[web.1]: Configuration error: Configuration error [Driver not found: [org.postgresql.Driver]]
2012-11-23T17:39:43+00:00 app[web.1]:   at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:71)
2012-11-23T17:39:43+00:00 app[web.1]:   at play.api.Configuration.reportError(Configuration.scala:258)
2012-11-23T17:39:43+00:00 app[web.1]:   at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194)
2012-11-23T17:39:43+00:00 app[web.1]:   at play.api.db.BoneCPApi.play$api$db$BoneCPApi$$register(DB.scala:283)
2012-11-23T17:39:43+00:00 app[web.1]:   at play.api.db.BoneCPApi$$anonfun$4.apply(DB.scala:386)
2012-11-23T17:39:43+00:00 app[web.1]:   at play.api.db.BoneCPApi$$anonfun$4.apply(DB.scala:390)
2012-11-23T17:39:43+00:00 app[web.1]:   at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194)
2012-11-23T17:39:43+00:00 app[web.1]:   at scala.collection.TraversableLike$class.map(TraversableLike.scala:194)
2012-11-23T17:39:43+00:00 app[web.1]:   at scala.collection.immutable.Set$Set1.foreach(Set.scala:86)
2012-11-23T17:39:43+00:00 app[web.1]:   at play.api.db.BoneCPPlugin.play$api$db$BoneCPPlugin$$dbApi(DB.scala:211)
2012-11-23T17:39:43+00:00 app[web.1]:   at play.api.db.BoneCPPlugin.onStart(DB.scala:240)
2012-11-23T17:39:43+00:00 app[web.1]:   at play.api.Play$$anonfun$start$1.apply(Play.scala:60)
2012-11-23T17:39:43+00:00 app[web.1]:   at scala.collection.immutable.Set$Set1.map(Set.scala:73)
2012-11-23T17:39:43+00:00 app[web.1]:   at scala.collection.immutable.Set$Set1.scala$collection$SetLike$$super$map(Set.scala:73)
2012-11-23T17:39:43+00:00 app[web.1]:   at scala.collection.SetLike$class.map(SetLike.scala:93)
2012-11-23T17:39:43+00:00 app[web.1]:   at play.api.db.BoneCPApi.<init>(DB.scala:386)
2012-11-23T17:39:43+00:00 app[web.1]:   at play.api.Play$$anonfun$start$1.apply(Play.scala:60)
2012-11-23T17:39:43+00:00 app[web.1]:   at play.api.Play$.start(Play.scala:60)
2012-11-23T17:39:43+00:00 app[web.1]:   at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
2012-11-23T17:39:43+00:00 app[web.1]:   at play.core.StaticApplication.<init>(ApplicationProvider.scala:51)
2012-11-23T17:39:43+00:00 app[web.1]:   at play.core.server.NettyServer$$anonfun$main$5.apply(NettyServer.scala:153)
2012-11-23T17:39:43+00:00 app[web.1]:   at play.core.server.NettyServer$.main(NettyServer.scala:152)
2012-11-23T17:39:43+00:00 app[web.1]:   at scala.collection.immutable.List.foreach(List.scala:45)
2012-11-23T17:39:43+00:00 app[web.1]:   at play.core.server.NettyServer$.createServer(NettyServer.scala:132)
2012-11-23T17:39:43+00:00 app[web.1]:   at play.core.server.NettyServer$$anonfun$main$5.apply(NettyServer.scala:152)
2012-11-23T17:39:43+00:00 app[web.1]:   at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
2012-11-23T17:39:43+00:00 app[web.1]:   at scala.Option.map(Option.scala:133)
2012-11-23T17:39:43+00:00 app[web.1]:   at play.core.server.NettyServer.main(NettyServer.scala)
2012-11-23T17:39:43+00:00 app[web.1]: Caused by: java.lang.ClassNotFoundException: org.postgresql.Driver
2012-11-23T17:39:43+00:00 app[web.1]:   at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
2012-11-23T17:39:43+00:00 app[web.1]:   at java.security.AccessController.doPrivileged(Native Method)
2012-11-23T17:39:43+00:00 app[web.1]:   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
2012-11-23T17:39:43+00:00 app[web.1]:   ... 24 more
2012-11-23T17:39:43+00:00 app[web.1]:   at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
2012-11-23T17:39:43+00:00 app[web.1]:   at java.lang.Class.forName(Class.java:264)
2012-11-23T17:39:43+00:00 app[web.1]:   at play.api.db.BoneCPApi.play$api$db$BoneCPApi$$register(DB.scala:281)
2012-11-23T17:39:43+00:00 app[web.1]:   at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
2012-11-23T17:39:43+00:00 app[web.1]:   at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
2012-11-23T17:39:43+00:00 app[web.1]:   at java.lang.Class.forName0(Native Method)
2012-11-23T17:39:44+00:00 heroku[web.1]: Process exited with status 255
2012-11-23T17:39:44+00:00 heroku[web.1]: State changed from starting to crashed
2012-11-23T17:40:19+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=SOME_URL.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=
  • Please link back to those prior discussions and suggestions for context. – Craig Ringer Nov 23 '12 at 00:09
  • Sure, absolutely: here they are: – user1326028 Nov 23 '12 at 00:44
  • [link](http://stackoverflow.com/questions/12054118/jars-in-lib-folder-not-picked-up-when-deploying-play-application-on-heroku); [link](http://stackoverflow.com/questions/13410422/play-framework-heroku-postgres-not-able-to-connect); [link](http://stackoverflow.com/questions/12037394/how-to-use-databse-url-in-play-2-0-scala-for-local-connection-to-postgresql-9); [link](http://stackoverflow.com/questions/11237351/heroku-unable-to-setup-postgres-database-through-play-framework-app) – user1326028 Nov 23 '12 at 00:46
  • Did you make sure that your committed your `Build.scala` changes to your git repo and pushed them to Heroku? Also, can you provide the error and details on when it happens? – James Ward Nov 23 '12 at 14:24
  • Dear James, thanks a lot for your comment. I've just added the error details. Build.scala seems to be committed in the git repo. I'm using the Eclipse Heroku plugin and have just downloaded the full git repo on Heroku to a new folder and all the files, including the Build.scala are there with the correct content...thanks a lot for your help! – user1326028 Nov 23 '12 at 17:59
  • Oh, another thing: The above error does not happen during the Build phase. The build seems to run ok. It's only when I open the application (e.g. via 'heroku open') that the error appears. Thanks again! – user1326028 Nov 26 '12 at 17:05

1 Answers1

5

thanks to the great Heroku support team I can give you the solution: Apparently, I didn't specify my appDependencies in my PlayProject. So I had to add my appDependencies to my PlayProject in Build.scala like this:

val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA)

I hope this helps everyone who runs into the same issue :)

Cheers, Horacio