Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.2.0-RC2] router URL handing errors with Mongodb #1678

Closed
thinksource opened this issue Sep 16, 2013 · 8 comments
Closed

[2.2.0-RC2] router URL handing errors with Mongodb #1678

thinksource opened this issue Sep 16, 2013 · 8 comments

Comments

@thinksource
Copy link

I create Comment.scala in controllers

  object Comments extends ApplicationController {
         def create(postId:ObjectId) = Authenticated {

then I added it to router:

POST    /posts/:post_id/comments    controllers.Comments.create(post_id: org.bson.types.ObjectId)

I use mongodb, so I changed the class dependencies in Build.scala:

val appDependencies = Seq(
// Add your project dependencies here,
jdbc,
anorm,
"org.mongodb"%"bson"%"2.11.3",
"org.fusesource.scalate"%%"scalate-core"%"1.6.1",
"se.radley" %% "play-plugins-salat" % "1.3.0"
)

val main = play.Project(appName, appVersion, appDependencies).settings(
routesImport += "se.radley.plugin.salat.Binders._",
templatesImport += "org.bson.types.ObjectId"

)

I still get errors for url handling in play:

[error] F:\Kepler\scala_blog\conf\routes:13: No URL path binder found for type o
rg.bson.types.ObjectId. Try to implement an implicit PathBindable for this type.

[error] POST /posts/:post_id/comments controllers.Comments.create(post_id:
org.bson.types.ObjectId)
[error] F:\Kepler\scala_blog\conf\routes:13: No URL path binder found for type o
rg.bson.types.ObjectId. Try to implement an implicit PathBindable for this type.

[error] POST /posts/:post_id/comments controllers.Comments.create(post_id:
org.bson.types.ObjectId)
[error] F:\Kepler\scala_blog\conf\routes:13: No URL path binder found for type o
rg.bson.types.ObjectId. Try to implement an implicit PathBindable for this type.

@jroper
Copy link
Member

jroper commented Sep 19, 2013

Could you take a look at target/scala-2.10/src_managed/main/routes_routing.scala, and see whether there is an import se.radley.plugin.salat.Binders._ statement in that file?

Also, did you do a clean before attempting to compile?

@thinksource
Copy link
Author

@jroper I use cmd command line do "play clean", "play compile" again.
The target/scala-2.10/src_managed/main/routes_routing.scala do not have an import se.radley.plugin.salat.Binders._ statement file:

It only have:

import play.core._
import play.core.Router._
import play.core.j._

import play.api.mvc._

import Router.queryString

@jroper
Copy link
Member

jroper commented Sep 19, 2013

Ok that's odd, I tested just then and the setting is working fine for me. Could you add the following setting to your build:

sourcePositionMappers := Nil

Then run play compile, and paste the error messages, and also could you past the first 3 lines of target/scala-2.10/src_managed/main/routes_routing.scala.

Also, could you check that you don't have a build.sbt file in your root directory?

@thinksource
Copy link
Author

@jroper where to added sourcePositionMappers := Nil?

can you say it more clearly where in build.scala?

this is my build.scala, which line to added the sourcePositionMappers := Nil?

object ApplicationBuild extends Build {

val appName         = "blog"
val appVersion      = "1.0-SNAPSHOT"

val appDependencies = Seq(
// Add your project dependencies here,
jdbc,
anorm,
"org.mongodb"%"bson"%"2.11.3",
"org.fusesource.scalate"%%"scalate-core"%"1.6.1",
"se.radley" %% "play-plugins-salat" % "1.3.0"
 )


val main = play.Project(appName, appVersion, appDependencies).settings(
  routesImport += "se.radley.plugin.salat.Binders._",
  templatesImport += "org.bson.types.ObjectId" 

)

}

I have build.sbt in my root directory, this is the file content:

name := "scala_blog"

version := "1.0-SNAPSHOT"

libraryDependencies ++= Seq(
jdbc,
anorm,
cache
)     

play.Project.playScalaSettings

@thinksource
Copy link
Author

object ApplicationBuild extends Build {

val appName = "blog"
val appVersion = "1.0-SNAPSHOT"
sourcePositionMappers := Nil //-------------------I added your line here
val appDependencies = Seq(
// Add your project dependencies here,
jdbc,
anorm,
"org.mongodb"%"bson"%"2.11.3",
"org.fusesource.scalate"%%"scalate-core"%"1.6.1",
"se.radley" %% "play-plugins-salat" % "1.3.0"
)

val main = play.Project(appName, appVersion, appDependencies).settings(
routesImport += "se.radley.plugin.salat.Binders._",
templatesImport += "org.bson.types.ObjectId"

)

}

The output errors is:

[info] Compiling 25 Scala sources and 2 Java sources to F:\Kepler\scala_blog\tar
get\scala-2.10\classes...
[error] F:\Kepler\scala_blog\conf\routes: not found: type controllers
[error] F:\Kepler\scala_blog\conf\routes: not found: type controllers
[error] F:\Kepler\scala_blog\conf\routes:13: No URL path binder found for type o
rg.bson.types.ObjectId. Try to implement an implicit PathBindable for this type.

[error] POST /posts/:post_id/comments controllers.Comments.create(post_id:
org.bson.types.ObjectId)
[error] F:\Kepler\scala_blog\conf\routes:13: No URL path binder found for type o
rg.bson.types.ObjectId. Try to implement an implicit PathBindable for this type.

[error] POST /posts/:post_id/comments controllers.Comments.create(post_id:
org.bson.types.ObjectId)
[error] F:\Kepler\scala_blog\conf\routes:13: No URL path binder found for type o
rg.bson.types.ObjectId. Try to implement an implicit PathBindable for this type.

[error] POST /posts/:post_id/comments controllers.Comments.create(post_id:
org.bson.types.ObjectId)
[error] F:\Kepler\scala_blog\conf\routes: not found: type controllers
[error] F:\Kepler\scala_blog\conf\routes: not found: type controllers
[error] 7 errors found
error Compilation failed
[error] Total time: 14 s, completed 20/09/2013 2:21:55 AM

@thinksource
Copy link
Author

past the first 3 lines of target/scala-2.10/src_managed/main/routes_routing.scala

import play.core._
import play.core.Router._
import play.core.j._

@jroper
Copy link
Member

jroper commented Oct 16, 2013

You can't have both a build.sbt and a Build.scala, you can use one or the other. Delete your build.sbt.

@ghost
Copy link

ghost commented Nov 18, 2013

please see very similar issue I have even without build.sbt, jroper, can you please please please help??
#2055

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants