Problem with routes discovery

35 views
Skip to first unread message

Sergey Weiss

unread,
Dec 4, 2012, 4:17:17 AM12/4/12
to xitrum-f...@googlegroups.com
Hi!

I'm trying to setup a simple xitrum project using gradle as a build tool. I have the following two classes:

package server

import xitrum.handler.Server
import xitrum.routing.Routes

object Boot {
  def main(args: Array[String]) {
    Server.start()
  }
}

and:

package server.controllers

import xitrum.Controller

class TestController extends Controller {
  pathPrefix = "test"

  def index = GET {
    respondText("hello")
  }
}

Here's what I got on server startup:

12:40:26,902  INFO Routes$:169 - Load routes.cache/collect routes and action/page cache config from controllers...
12:40:27,585  INFO Routes$:60 - Routes:
GET  /xitrum/routes.js  xitrum.routing.JSRoutesController#serve
12:40:27,844  INFO Server$:45 - HTTP server started on port 8000
12:40:27,856  INFO Server$:45 - HTTPS server started on port 4430

So there's no route GET /test
What is wrong with this setup?

Ngoc Dao

unread,
Dec 4, 2012, 4:27:15 AM12/4/12
to Xitrum web framework
Why don't you use SBT?

I have never used Gradle.
Can you post a sample project somewhere and give some instructions
about how to build and run the project?

Basically, when running Xitrum will use Sclasner (https://github.com/
ngocdaothanh/sclasner) to scan all .class files in Java class path,
then use Javassist to inspect the routes in them.

Ngoc Dao

unread,
Dec 4, 2012, 4:31:14 AM12/4/12
to Xitrum web framework
If there's no directory named "target" in the current working
directory (production mode), Xitrum will just load the file
routes.cache. So please try deleting the file routes.cache to force
Xitrum to reload all routes.

Sergey Weiss

unread,
Dec 4, 2012, 4:35:52 AM12/4/12
to xitrum-f...@googlegroups.com
Deleting routes.cache helped. Thanks a lot!

вторник, 4 декабря 2012 г., 13:31:14 UTC+4 пользователь Ngoc Dao написал:

Ngoc Dao

unread,
Dec 4, 2012, 4:43:50 AM12/4/12
to Xitrum web framework
> Deleting routes.cache helped. Thanks a lot!

OK. But it's not very convenient while developing. Without
routes.cache, Xitrum will have to recollect everything from class
paths. This is slow comparing to recollecting only .class files inside
the "target" directory while developing.

Sergey Weiss

unread,
Dec 4, 2012, 4:46:08 AM12/4/12
to xitrum-f...@googlegroups.com
Gradle uses 'build' instead of 'target'. Is the target directory name configurable?

Ngoc Dao

unread,
Dec 4, 2012, 5:57:36 AM12/4/12
to Xitrum web framework
> Gradle uses 'build' instead of 'target'. Is the target directory name
> configurable?

I've just released a new version of Sclasner to support Gradle:
https://github.com/ngocdaothanh/sclasner/commit/230e3a26edddbb2aa08e697c4b5b04a276f42299
https://github.com/ngocdaothanh/xitrum/commit/a2c1bd195096d49efb169d6ca70ba788eae501f9

The directory name will be configurable in the future if there's
further need.

You can try Xitrum 1.9.11-SNAPSHOT:
git clone git://github.com/ngocdaothanh/xitrum.git
cd xitrum
sbt/sbt publish-local

Then in your project's build.sbt, use:
libraryDependencies += "tv.cntt" %% "xitrum" % "1.9.11-SNAPSHOT"

Sergey Weiss

unread,
Dec 5, 2012, 3:54:52 AM12/5/12
to xitrum-f...@googlegroups.com
It works, thanks!
Configuration option in future releases would be highly appreciated though :)

On Tue, Dec 4, 2012 at 2:57 PM, Ngoc Dao <ngocda...@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages