Re: [2.1-RC1] object db is not a member of package play.api

3,281 views
Skip to first unread message

James Roper

unread,
Nov 21, 2012, 3:06:05 AM11/21/12
to play-fr...@googlegroups.com
Ignoring eclipse, what happens when you compile the code in Play?

On Wednesday, 21 November 2012 17:53:53 UTC+11, Kirill Grishin wrote:
Hi. A question from a newbie.

Trying out 2.1-RC1. Tried to follow the steps from Slick / Play tutorial ( http://www.jroller.com/ouertani/entry/getting_started_with_play_2 ) but ran into an error:

"object db is not a member of package play.api "
on line "import play.api.db.DB"

when tried to create Global.scala .

In fact, when I write " import play.api.db._ " in any *.scala file inside models directory I get "object db is not a member of package play.api" error highlighted inside Eclipse Scala IDE.

What do I do wrong?

Thank you!

Jean Helou

unread,
Nov 21, 2012, 7:22:14 AM11/21/12
to play-fr...@googlegroups.com
Funny I followed the exact same article a couple nights ago

My guess is you need to add play-jdbc as a dependency. the article was written before the modularization. 

change you app dependencies in project/Build.scala to 
val appDependencies: Seq[ModuleID]=Seq(
    "com.typesafe" % "slick_2.10.0-RC1" % "0.11.2",
    "play" %% "play-jdbc" % "2.1-SNAPSHOT"
  )

Remember also that the hierarchy for evolutions is
conf/evolutions/${datasourcename}/${evolutionID}.sql

in application.conf, you need to add 
db.${datasourcename}.driver=...
db.${datasourcename}.url=...

If you want to see a play app using this setup have a look here : https://github.com/jeantil/xstaffing-mobile/blob/master/conf/application.conf the app is very small
conf is 

in Build.scala the line 
    net.virtualvoid.sbt.graph.Plugin.graphSettings: _*
is to be able to use https://github.com/jrudolph/sbt-dependency-graph (I am a maven refugee :) )


Cheers
Jean

Kirill Grishin

unread,
Nov 21, 2012, 9:59:31 AM11/21/12
to play-fr...@googlegroups.com
Jean, thanks for the reply! Indeed, the problem was with the "jdbc" dependency. In fact, in the docs https://github.com/playframework/Play20/blob/master/documentation/manual/Highlights.md it is explained quite clearly. So I just added jdbc to dependencies and it all worked.

    val appDependencies = Seq(
      jdbc,

      "com.typesafe" % "slick_2.10.0-RC1" % "0.11.2"
    )

And thank you for the links to samples, I'll definitely have a close look at them.

Kirill

среда, 21 ноября 2012 г., 21:22:14 UTC+9 пользователь Jean Helou написал:

Nick McCready

unread,
Jan 24, 2013, 2:09:03 PM1/24/13
to play-fr...@googlegroups.com
I should probably make a new thread on this, but I am seeing a similar problem but on a older version of play.

Play: 2.1-09142012
Scala - 2.9.2
jdk-1.7.0_09 - 11 all have same errors

object api is not a member of package models.play
[error] import play.api.i18n._

Nick McCready

unread,
Jan 24, 2013, 3:26:45 PM1/24/13
to play-fr...@googlegroups.com
nvm this error was due to package name being incorrect under the wrong folder

- I had a model which got moved to a services directory that had a sub package play.

Enter code here...
/app
   
/models
       
/play
           
/*.scala
   /services

//got moved to
/app
   /models
   /services
       /play
           /*.scala   <---- Still had the "package model.play"

This is what caused the error: object api is not a member of package play.api

Making the package services.play did fix the issue

Nick McCready

unread,
Jan 24, 2013, 3:27:36 PM1/24/13
to play-fr...@googlegroups.com
typo

should have been "package models.play"

Lars Støttrup Nielsen

unread,
Apr 4, 2013, 5:04:13 PM4/4/13
to play-fr...@googlegroups.com
Just add "jdbc" as a dependency.
It's a predefined key.

I haven't found mention of this in the official docs though, but there you have it.
Reply all
Reply to author
Forward
0 new messages