Support for Vert.x #39

Open
zhaopuming opened this Issue May 29, 2012 · 13 comments

Projects

None yet

2 participants

@zhaopuming

As you may have already know it, vert.x is a new webframework/server for the JVM, similarity to Node.js. From its feature list and its VMWare background, it looks promising. Homepage is at http://vertx.io/

I tried to use Rythm as the template engine in vert.x, but failed due to vert.x not finding classes in the rythm jars. It seems to be related to classloader problems, which I don't understand.

As playframework had moved away from Java into scala, I'd suggest supporting Rythm in vert.x is a good option. Would you be insterested in taking a look at vert.x and make Rythm work with it ?

@greenlaw110
Collaborator

thanks. Can you pack and email me(greenlaw110@gmail.com) your sample
project which failed with Rythm rendering ?

On Tue, May 29, 2012 at 11:10 PM, zhaopuming <
reply@reply.github.com

wrote:

As you may have already know it, vert.x is a new webframework/server for
the JVM, similarity to Node.js. From its feature list and its VMWare
background, it looks promising. Homepage is at http://vertx.io/

I tried to use Rythm as the template engine in vert.x, but failed due to
vert.x not finding classes in the rythm jars. It seems to be related to
classloader problems, which I don't understand.

As playframework had moved away from Java into scala, I'd suggest
supporting Rythm in vert.x is a good option. Would you be insterested in
taking a look at vert.x and make Rythm work with it ?


Reply to this email directly or view it on GitHub:
#39

@zhaopuming

Thanks :) I have sent you a email, with my simple project. I just found that vert.x has a module system similar to play framework. So maybe that is where you should look into if you are interested. http://vertx.io/mods_manual.html

@zhaopuming

Hi green, is there a plan on this issue?

@greenlaw110
Collaborator

Hi puming,

Not at the moment I am afraid. Getting too busy to cover this topic. Anyway
I will try to spend 1 or 2 hours this week to read your project and see
what I can do.

Thx,
Green

On Tue, Jun 26, 2012 at 1:36 PM, zhaopuming <
reply@reply.github.com

wrote:

Hi green, is there a plan on this issue?


Reply to this email directly or view it on GitHub:
#39 (comment)

@zhaopuming

Thanks Green. I'd like to learn about how Rhythm is designed and implemented. Could you guide me with some resources? I've read docs on your website. Will get some time to start reading your code :)

@greenlaw110
Collaborator

Well, it's hard to say I have employed any formal design/construct
methodology to create Rythm (not Rhythm!). And there is basically no design
and implementation document I could send to you except the source code. The
docs on the web site is for the end user, not very usable from the
implementation perspective.

Basically here is the workflow:

  1. Parse template file and generate java source code
  2. Compile the java source code and load class into a in-house class
    loader, and then Rythm is ready to
  3. Service the template generation request

There are lot of other things like class bytecode in-memory and in-disk
cache, tag handling etc.

Sorry for lacking the documentation, so just play with the source code ;-)

On Wed, Jun 27, 2012 at 4:10 PM, zhaopuming <
reply@reply.github.com

wrote:

Thanks Green. I'd like to learn about how Rhythm is designed and
implemented. Could you guide me with some resources? I've read docs on
your website. Will get some time to start reading your code :)


Reply to this email directly or view it on GitHub:
#39 (comment)

@zhaopuming

Hi, green. I'm back to try Rythm with Vert.x again. A simplest test with:

Rythm.render("Hello @who", "World");

in vert.x will lead to the following exception:

com.greenlaw110.rythm.exception.CompileException: Error compile template[Hello @who]. Java code line: 4; Template code line:-1; Error: com.greenlaw110.rythm.template.TagBase cannot be resolved to a type

Can you shed some light on this and direct me where to find the problem? I know you've been busy.

@zhaopuming

I guess it may be caused by a classpath problem. The Eclipse compiler did not get the classpath (including rythm.jar) from vert.x code which was calling Rytem.render()... Are they in different classloader? How can I pass the classpath information to the eclipse compiler? I can't find any document about the eclipse compiler online.

@zhaopuming

This is the code I'm using:

public class ServerVerticle extends Verticle {

    @Override
    public void start() throws Exception {
        HttpServer server = vertx.createHttpServer();

        RouteMatcher route = new RouteMatcher();
        route.get("/", new Handler<HttpServerRequest>() {
            @Override
            public void handle(HttpServerRequest req) {
                // ~ This is OK
                // req.response.end("Hello world");
                // ~ This leads to template compiler error
                req.response.end(Rythm.render("Hello @who", "world"));
            }
        });

        server.requestHandler(route);
        server.listen(8080);
    }

}
@greenlaw110
Collaborator

this is strange, because Rythm's template class loader's parent loader is
your default class loader which should locate rythm.jar without problem. If
you run the samples by typing "ant" inside samples folder, it will render
correctly. Need to check how the jvm environment is setup inside vert.ex

On Wed, Jul 25, 2012 at 11:14 AM, zhaopuming <
reply@reply.github.com

wrote:

I guess it may be caused by a classpath problem. The Eclipse compiler did
not get the classpath (including rythm.jar) from vert.x code which was
calling Rytem.render()... Are they in different classloader? How can I pass
the classpath information to the eclipse compiler? I can't find any
document about the eclipse compiler online.


Reply to this email directly or view it on GitHub:
#39 (comment)

@zhaopuming

Yes, running from ant or directly from Eclipse (in a main method) is OK.

I can't think of a way that a child classloader won't be able to load classes already in its parents. I don't know much about classloaders and JVM internals though.

So you mean this may be caused by vert.x? I'll ask on their google group

@zhaopuming

As for now, Vert.x 2.0 works with Rythm OK.

@greenlaw110
Collaborator

awesome!

On Fri, Jun 7, 2013 at 12:16 AM, zhaopuming notifications@github.comwrote:

As for now, Vert.x 2.0 works with Rythm OK.


Reply to this email directly or view it on GitHubhttps://github.com/greenlaw110/Rythm/issues/39#issuecomment-19047898
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment