scala - Lift RestHelper don't receive my request -
i tried create simple resthelper
"hello world" example i'm having trouble. when start container container:start
command,
serve { case nil _ => extraction.decompose("hello restful world!") }
is not invoked in resthelper
extension. following message: "the requested url / not found on server"
so, seems reason lift ignores
liftrules.statelessdispatch.append(service)
line in bootstrap.boot.boot
definition. , have absolutely no clue why happens.
here's boot
class:
package bootstrap import net.liftweb.http.liftrules import com.yac.restfultest.service class boot { def boot { liftrules.statelessdispatch.append(service) } }
and here's service
:
package com.yac.restfultest import net.liftweb.http.rest.resthelper import net.liftweb.json.extraction object service extends resthelper { serve { case nil _ => extraction.decompose("hello restful world!") } }
and in case helps here's web.xml
:
<!doctype web-app system "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <filter> <filter-name>liftfilter</filter-name> <display-name>lift filter</display-name> <description>the filter intercepts lift calls</description> <filter-class>net.liftweb.http.liftfilter</filter-class> </filter> <filter-mapping> <filter-name>liftfilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
and in case of above not enough here build.sbt
:
name := "testrest" version := "1.0" scalaversion := "2.11.6" resolvers ++= seq("snapshots" @ "https://oss.sonatype.org/content/repositories/snapshots", "releases" @ "https://oss.sonatype.org/content/repositories/releases" ) jetty() librarydependencies ++= { val liftversion = "2.6.2" seq( "net.liftweb" %% "lift-webkit" % liftversion % "compile" ) }
as can see it's minimalistic lift project setup possible. still can't working. appreciated.
and here's sbt
log on container:start
:
[info] compiling 1 scala source /home/yac/ideaprojects/testrest/target/scala-2.11/classes... [info] packaging /home/yac/ideaprojects/testrest/target/scala-2.11/testrest_2.11-1.0.jar ... [info] done packaging. [info] starting server ... [success] total time: 2 s, completed apr 22, 2015 7:51:25 pm > 2015-04-22 19:51:25.640:info::main: logging initialized @44ms 2015-04-22 19:51:25.646:info:oejr.runner:main: runner 2015-04-22 19:51:25.726:info:oejs.server:main: jetty-9.2.1.v20140609 2015-04-22 19:51:29.818:warn:oeja.annotationconfiguration:main: servletcontainerinitializers: detected. class hierarchy: empty slf4j: failed load class "org.slf4j.impl.staticloggerbinder". slf4j: defaulting no-operation (nop) logger implementation slf4j: see http://www.slf4j.org/codes.html#staticloggerbinder further details. 2015-04-22 19:51:30.405:info:oejsh.contexthandler:main: started o.e.j.w.webappcontext@32e377c7{/,file:/home/yac/ideaprojects/testrest/target/webapp/,available}{file:/home/yac/ideaprojects/testrest/target/webapp/} 2015-04-22 19:51:30.406:warn:oejsh.requestloghandler:main: !requestlog 2015-04-22 19:51:30.417:info:oejs.serverconnector:main: started serverconnector@7a601e4{http/1.1}{0.0.0.0:8080} 2015-04-22 19:51:30.418:info:oejs.server:main: started @4848ms
so, turns out it's usual noobish non-attentiveness. package, containing boot.scala
should called bootstrap.liftweb
, not bootstrap
in case.
and yes, suggested jcern should "index" :: nil
in routing pattern.
Comments
Post a Comment