开发者

Error 500 for basic REST service in Lift Scala MongoDB while createRecord

开发者 https://www.devze.com 2023-02-24 23:11 出处:网络
The REST service object code is: object Account extends RestHelper { def createUser = { for { username <- S.param(\"username\") ?~ \"username parameter missing\" ~> 400

The REST service object code is:

object Account extends RestHelper {
  def createUser = {
    for {
      username <- S.param("username") ?~ "username parameter missing" ~> 400
      number <- S.param("number") ?~ "number parameter missing"
    } yield {
      val u = GeoFence.createRecord.name(username)
      u.save
      u.asJSON
    }
  }

  serve {
    case Req("api" :: "hello" :: Nil, "json", GetRequest) => JString("hi")
    case Req("api" :: "accounts" :: "new" :: Nil, "json", GetRequest) => createUser()
  }
}

This is the exception I see on browser whenever I'm trying to run the REST service.

The exception is pointing to line 27 which is:

val u = GeoFence.createRecord.name(username)

u.save

HTTP ERROR 500

Problem accessing /api/accounts/new.json. Reason:

(class: net/liftweb/record/Record$class, method: toForm signature: (Lnet/liftweb/record/Record;Lscala/Function1;)Lscala/xml/NodeSeq;) Incompatible object argument for function call

Caused by:

java.lang.VerifyError: (class: net/liftweb/record/Record$class, method: toForm signature: (Lnet/liftweb/record/Record;Lscala/Function1;)Lscala/xml/NodeSeq;) Incompatible object argument for function call at smartfamily.model.GeoFence.(GeoFence.scala:21) at smartfamily.model.GeoFence$.(GeoFence.scala:19) at smartfamily.model.GeoFence$.(GeoFence.scala) at smartfamily.api.Account$$anonfun$createUser$1$$anonfun$apply$1.apply(Account.scala:27) at smartfamily.api.Account$$anonfun$createUser$1$$anonfun$apply$1.apply(Account.scala:25) at net.liftweb.common.Full.map(Box.scala:478) at smartfamily.api.Account$$anonfun$createUser$1.apply(Account.scala:25) at smartfamily.api.Account$$anonfun$createUser$1.apply(Account.scala:24) at net.liftweb.common.Full.flatMap(Box.scala:480) at smartfamily.api.Account$.createUser(Account.scala:24) at smartfamily.api.Account$$anonfun$1.apply(Account.scala:35) at smartfamily.api.Account$$anonfun$1.apply(Account.scala:33) at net.liftweb.http.rest.RestHelper$class.apply(RestHelper.scala:472) at smartfamily.api.Account$.apply(Account.scala:21) at smartfamily.api.Account$.apply(Account.scala:21) at net.liftweb.util.NamedPF$$anonfun$applyBox$1.apply(NamedPartialFunction.scala:97) at net.liftweb.util.NamedPF$$anonfun$applyBox$1.apply(NamedPartialFunction.scala:97) at net.liftweb.common.Full.map(Box.scala:478) at net.liftweb.util.NamedPF$.applyBox(NamedPartialFunction.scala:97) at net.liftweb.http.LiftServlet.doService(LiftServlet.scala:220) at net.liftweb.http.LiftServlet$$anonfun$doIt$1$1.apply$mcZ$sp(LiftServlet.scala:129) at net.liftweb.http.LiftServlet$$anonfun$doIt$1$1.apply(LiftServlet.scala:129) at net.liftweb.http.LiftServlet$$anonfun$doIt$1$1.apply(LiftServlet.scala:129) at net.liftweb.util.TimeHelpers$class.calcTime(TimeHelpers.scala:344) at net.liftweb.util.Helpers$.calcTime(Helpers.scala:34) at net.liftweb.util.TimeHelpers$class.logTime(TimeHelpers.scala:353) at net.liftweb.util.Helpers$.logTime(Helpers.scala:34) at net.liftweb.http.LiftServlet.doIt$1(LiftServlet.scala:128) at net.liftweb.http.LiftServlet.service(LiftServlet.scala:137) at net.liftweb.http.provider.HTTPProvider$$anonfun$service$2$$anonfun$apply$mcV$sp$1.apply$mcV$sp(HTTPProvider.scala:69) at net.liftweb.http.provider.HTTPProvider$$anonfun$service$2$$anonfun$apply$mcV$sp$1.apply(HTTPProvider.scala:68) at net.liftweb.http.provider.HTTPProvider$$anonfun$service$2$$anonfun$apply$mcV$sp$1.apply(HTTPProvider.scala:68) at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) at net.liftweb.http.URLRewriter$.doWith(Req.scala:1063) at net.liftweb.http.provider.HTTPProvider$$anonfun$service$2.apply$mcV$sp(HTTPProvider.scala:67) at net.liftweb.http.provider.HTTPProvider$$anonfun$service$2.apply(HTTPProvider.scala:67) at net.liftweb.http.provider.HTTPProvider$$anonfun$service$2.apply(HTTPProvider.scala:67) at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) at net.liftweb.http.provider.HTTPProvider$class.service(HTTPProvider.scala:63) at net.liftweb.http.LiftFilter.service(LiftServlet.scala:689) at net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun$doFilter$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp(ServletFilterProvider.scala:67) at net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun$doFilter$1$$anonfun$apply$mcV$sp$1.apply(ServletFilterProvider.scala:62) at net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun$doFilter$1$$anonfun$apply$mcV$sp$1.apply(ServletFilterProvider.scala:62) at net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$12$$anonfun$apply$13$$anonfun$apply$14$$anonfun$apply$15.apply(Vars.scala:513) at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) at net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$12$$anonfun$apply$13$$anonfun$apply$14.apply(Vars.scala:512) at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) at net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$12$$anonfun$apply$13.apply(Vars.scala:511) at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) at net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$12.apply(Vars.scala:510) at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) at net.liftweb.http.CoreRequestVarHandler$class.apply(Vars.scala:509) at net.liftweb.http.RequestVarHandler$.apply(Vars.scala:428) at net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun$doFilter$1.apply$mcV$sp(ServletFilterProvider.scala:61) at net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun$doFilter$1.apply(ServletFilterProvider.scala:61) at net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun$doFilter$1.apply(ServletFilterProvider.scala:61) at net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$12$$anonfun$apply$13$$anonfun$apply$14$$anonfun$apply$15.apply(Vars.scala:513) at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) at net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$12$$anonfun$apply$13$$anonfun$apply$14.apply(Vars.scala:512) at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) at net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$12$$anonfun$apply$13.apply(Vars.scala:511) at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) at net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$12.apply(Vars.scala:510) at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:71) at net.liftweb.http.CoreRequestVarHandler$class.apply(Vars.scala:509) at net.liftweb.http.TransientRequestVarHandler$.apply(Vars.scala:432) at net.liftweb.http.provider.servlet.ServletFilterProvider$class.doFilter(ServletFilterProvider.scala:60) at net.liftweb.http.LiftFilter.doFilter(LiftServlet.scala:689) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440) at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230) at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThr开发者_C百科eadPool.java:582)

UPDATE 1

Well it was resolved by the excellent lift community at the given link.

http://groups.google.com/group/liftweb/browse_thread/thread/e70cc3763734fdd9


The first line in your exception is:

smartfamily.model.GeoFence.<init>(GeoFence.scala:21)

This is where you'll have to look for the problem. Your call to net.liftweb.record.Record.toForm apparently doesn't match the signature you compiled it against. I would guess that you're running your application with the wrong version of lift. Either that or your lift jar file is corrupt.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号