Writing JavaScript Modules

872 views
Skip to first unread message

Brian DiCasa

unread,
Jun 3, 2012, 7:22:13 PM6/3/12
to vert.x
I'm a vert.x newbie and I'm trying to write my own JavaScript module.
I want to make a module to will parse Handlebars templates.

However, I'm running into a Module not found error. To start, I'm just
trying to return a string from the module. The module code is below:

load('vertx.js');

vertx.eventBus.registerHandler('handlebars', function(message,
replier) {
replier('Hello world from handlebars');
});

I'm not sure if there is a format you need to follow when writing a
module? I thought this would just add the handlebars handler to the
event bus, and that I would be able to call it. I have a small groovy
application that is trying to call the handlebars verticle:

import org.vertx.groovy.core.http.RouteMatcher

container.with {

deployVerticle("handlebars")
}


def rm = new RouteMatcher()

rm.get('/') { req ->
vertx.eventBus.send("handlebars", null) { reply ->
req.response.end(reply)
}
}

vertx.createHttpServer().requestHandler(rm.asClosure()).listen(9292)

Thanks for any assistance. vertx looks like a very promising platform
and I look forward to developing in it.

There error I was receiving when running the application is below:

org.mozilla.javascript.JavaScriptException: Error: Module "app.js" not
found.
at
org.mozilla.javascript.ScriptRuntime.throwError(ScriptRuntime.java
at
org.mozilla.javascript.commonjs.module.Require.requireMain(Require
at
org.vertx.java.deploy.impl.rhino.RhinoVerticle.start(RhinoVerticle
at org.vertx.java.deploy.impl.VerticleManager
$2.run(VerticleManager.j
at org.vertx.java.core.impl.DefaultVertx
$2.run(DefaultVertx.java:249)
at org.vertx.java.core.impl.Context$2.run(Context.java:113)
at
org.jboss.netty.channel.socket.nio.AbstractNioWorker.processEventQ
at
org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractN
at
org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:38
at
org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunn
at org.jboss.netty.util.internal.DeadLockProofWorker
$1.run(DeadLockPr
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown
Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
Source)
at java.lang.Thread.run(Unknown Source)

Joern Bernhardt

unread,
Jun 4, 2012, 2:17:02 AM6/4/12
to ve...@googlegroups.com
Hi Brian,

you need to have your mod.json and the name of your main module class right: It cannot find a file "app.js", so I guess you have a mod.json file with { "main" : "app.js" } but your module code is not inside a file called app.js. If I set that up, I get another exception, since req.response.end() in your groovy code cannot use a Message instance.  If I change line 13 into req.response.end(reply.body), your example works for me.

Joern

Brian DiCasa

unread,
Jun 4, 2012, 7:34:30 PM6/4/12
to vert.x
Hi Joern,

Thanks a lot for the reply, I appreciate it.

In my mods directory, I have a handlebars folder, with an app.js file,
and a mod.json file. The contents of the mod.json file are:

{
"main": "app.js"
}

I have a VERTX_HOME environment variable set.

In my project directory, I have an App.groovy file, and I'm trying to
run it with:

vertx run App.groovy

I'm really puzzled at what is going on, especially since you can get
it running. Are you using "vertx run App.groovy" to launch the
application?

Thanks again,

Brian

On Jun 4, 2:17 am, Joern Bernhardt <joern.bernha...@googlemail.com>
wrote:

Joern Bernhardt

unread,
Jun 4, 2012, 9:20:30 PM6/4/12
to ve...@googlegroups.com
Hi Brian,

yes, I use vertx run App.groovy. I don't have a VERTX_HOME variable set, just the bin directory in PATH. I put the handlebars directory directly in the mods folder of the vertx installation (where you can also find auth-mgr, mailer, etc.).

I just realized that I could only get it running with vert.x 1.0.final, tried it on windows. vert.x 1.0.1.final did NOT work for me (same error as you have).

HTH,
Joern

Finn Bock

unread,
Jun 5, 2012, 3:25:19 AM6/5/12
to ve...@googlegroups.com

On Tuesday, June 5, 2012 3:20:30 AM UTC+2, Joern Bernhardt wrote:
Hi Brian,

yes, I use vertx run App.groovy. I don't have a VERTX_HOME variable set, just the bin directory in PATH. I put the handlebars directory directly in the mods folder of the vertx installation (where you can also find auth-mgr, mailer, etc.).

I just realized that I could only get it running with vert.x 1.0.final, tried it on windows. vert.x 1.0.1.final did NOT work for me (same error as you have).

It seems that vertx 1.0.1.final does not contain the js.jar.

regards,
finn

Tim Fox

unread,
Jun 5, 2012, 4:46:14 AM6/5/12
to ve...@googlegroups.com
There's a note about installing js.jar on the install documentation page

regards,
finn
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/vertx/-/-WkbB-u7IAwJ.
To post to this group, send an email to ve...@googlegroups.com.
To unsubscribe from this group, send email to vertx+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/vertx?hl=en-GB.

Joern Bernhardt

unread,
Jun 5, 2012, 8:14:40 AM6/5/12
to ve...@googlegroups.com
Rhino is installed and js.jar is inside the lib directory.
To unsubscribe from this group, send email to vertx+unsubscribe@googlegroups.com.

Sujith Vellat

unread,
Jun 5, 2012, 10:57:15 AM6/5/12
to ve...@googlegroups.com
I tried to replicate this issue with vertx 1.0.1 final on a windows box.

Caution: I am just learning vertx.

I see that relative path in mod.json is failing. Looks like Rhino is looking for the file in the current directory from where we execute "vertx run App.groovy"

The relative path to js file in mod.json is failing.
{
  "main": "app.js"
}

The absolute path seems to work fine. 
{
  "main": "/projects/software/vert.x-1.0.1.final/mods/handlebars/app.js"
}

Is there any setting in vertx 1.0.1 to make relative paths work. OR is it only a windows specific issue? Brian: did you face this on a windows box?

Thanks,
Sujith

To view this discussion on the web, visit https://groups.google.com/d/msg/vertx/-/KrMSnR5mknoJ.

To post to this group, send an email to ve...@googlegroups.com.
To unsubscribe from this group, send email to vertx+un...@googlegroups.com.

Joern Bernhardt

unread,
Jun 5, 2012, 11:14:42 AM6/5/12
to ve...@googlegroups.com
The workaround you suggested works on windows and my linux VM. If I don't use the relative path, the exception is the same on both windows and linux.


On Tuesday, June 5, 2012 4:57:15 PM UTC+2, Sujith Vellat wrote:
I tried to replicate this issue with vertx 1.0.1 final on a windows box.

Caution: I am just learning vertx.

I see that relative path in mod.json is failing. Looks like Rhino is looking for the file in the current directory from where we execute "vertx run App.groovy"

The relative path to js file in mod.json is failing.
{
  "main": "app.js"
}

The absolute path seems to work fine. 
{
  "main": "/projects/software/vert.x-1.0.1.final/mods/handlebars/app.js"
}

Is there any setting in vertx 1.0.1 to make relative paths work. OR is it only a windows specific issue? Brian: did you face this on a windows box?

Thanks,
Sujith

Sujith Vellat

unread,
Jun 5, 2012, 12:28:09 PM6/5/12
to ve...@googlegroups.com
Thanks Joern for confirming that its not OS specific.

I also tried with a Java and Javascript version of App.groovy https://github.com/sujithvellat/vertx-handlebars 

So regardless of we call the module from Java, Javascript or Groovy,only the absolute path seems to work in this case using vertx 1.0.1

Thanks,
Sujith

To view this discussion on the web, visit https://groups.google.com/d/msg/vertx/-/gcKmzoH5kAwJ.

To post to this group, send an email to ve...@googlegroups.com.
To unsubscribe from this group, send email to vertx+un...@googlegroups.com.

Tim Fox

unread,
Jun 5, 2012, 12:29:51 PM6/5/12
to ve...@googlegroups.com
I'm not sure what the issue is here.

All the out of the box modules (look in the mods directory) of the installation work fine with relative paths.

I'm guessing you either haven't installed the module in mods or haven't set VERTX_MODS to point to your module parent directory, as described in the modules manual.
To unsubscribe from this group, send email to vertx+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/vertx?hl=en-GB.
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/vertx/-/KrMSnR5mknoJ.

To post to this group, send an email to ve...@googlegroups.com.
To unsubscribe from this group, send email to vertx+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/vertx?hl=en-GB.
--
You received this message because you are subscribed to the Google Groups "vert.x" group.

Tim Fox

unread,
Jun 5, 2012, 12:41:52 PM6/5/12
to ve...@googlegroups.com
From reading this thread, I'm confused about what is trying to be achieved and what has been attempted.

Can someone please summarise, specifying exact what files have been put in what directories and what environment variables have been set, and what command line has been used to run the application?

Given the above I can say whether or not what is being done is correct.


On Tuesday, June 5, 2012 5:29:51 PM UTC+1, Tim Fox wrote:
I'm not sure what the issue is here.

All the out of the box modules (look in the mods directory) of the installation work fine with relative paths.

I'm guessing you either haven't installed the module in mods or haven't set VERTX_MODS to point to your module parent directory, as described in the modules manual.

On 05/06/2012 15:57, Sujith Vellat wrote:
I tried to replicate this issue with vertx 1.0.1 final on a windows box.

Caution: I am just learning vertx.

I see that relative path in mod.json is failing. Looks like Rhino is looking for the file in the current directory from where we execute "vertx run App.groovy"

The relative path to js file in mod.json is failing.
{
  "main": "app.js"
}

The absolute path seems to work fine. 
{
  "main": "/projects/software/vert.x-1.0.1.final/mods/handlebars/app.js"
}

Is there any setting in vertx 1.0.1 to make relative paths work. OR is it only a windows specific issue? Brian: did you face this on a windows box?

Thanks,
Sujith

On Tue, Jun 5, 2012 at 8:14 AM, Joern Bernhardt <joern.bernhardt@googlemail.com> wrote:
Rhino is installed and js.jar is inside the lib directory.


On Tuesday, June 5, 2012 10:46:14 AM UTC+2, Tim Fox wrote:
On 05/06/2012 08:25, Finn Bock wrote:

On Tuesday, June 5, 2012 3:20:30 AM UTC+2, Joern Bernhardt wrote:
Hi Brian,

yes, I use vertx run App.groovy. I don't have a VERTX_HOME variable set, just the bin directory in PATH. I put the handlebars directory directly in the mods folder of the vertx installation (where you can also find auth-mgr, mailer, etc.).

I just realized that I could only get it running with vert.x 1.0.final, tried it on windows. vert.x 1.0.1.final did NOT work for me (same error as you have).

It seems that vertx 1.0.1.final does not contain the js.jar.

There's a note about installing js.jar on the install documentation page

regards,
finn
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/vertx/-/-WkbB-u7IAwJ.
To post to this group, send an email to ve...@googlegroups.com.
To unsubscribe from this group, send email to vertx+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/vertx?hl=en-GB.
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/vertx/-/KrMSnR5mknoJ.

To post to this group, send an email to ve...@googlegroups.com.
To unsubscribe from this group, send email to vertx+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/vertx?hl=en-GB.
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To post to this group, send an email to ve...@googlegroups.com.
To unsubscribe from this group, send email to vertx+unsubscribe@googlegroups.com.

Sujith Vellat

unread,
Jun 5, 2012, 1:01:35 PM6/5/12
to ve...@googlegroups.com
Tim,

We have a simple mod called "handlebars" with a app.js and mod.json files inside it. We tried putting the handlebars in the same directory where all other default mods are present. $VERTX_HOME/mods
Then we had a file named App.groovy in a different folder. (For example C:\test\App.groovy) App.groovy tries to load the module handlebars programmatically using deployVerticle

VERTX_HOME environment is set to install directory. $VERTX_HOME/bin is in path. VERTX_MODS was not set.

The command line used was "vertx run App.groovy"


If the main in mod.json point to the absolute path of app.js file it works.

Also all the default bus mods in vertx1.0.1 [auth-manager, mailer, mongo-persistor, web-server and work-queue] are having a main pointing to Java class in mod.json. I could n't find a javascript example.

Thanks,
Sujith

To view this discussion on the web, visit https://groups.google.com/d/msg/vertx/-/Y6a4N5VRcm8J.

To post to this group, send an email to ve...@googlegroups.com.
To unsubscribe from this group, send email to vertx+un...@googlegroups.com.

Brian DiCasa

unread,
Jun 5, 2012, 7:57:53 PM6/5/12
to vert.x
What Sujith summarized is correct.

I'll also note that I tried putting the handlebars mod in the
installation directory mod folder, as well a custom mod folder (with
VERTX_MODS specified in environment variables).

Thanks for looking into this.

Brian

On Jun 5, 1:01 pm, Sujith Vellat <vtsuj...@gmail.com> wrote:
> Tim,
>
> We have a simple mod called "handlebars" with a app.js and mod.json files
> inside it. We tried putting the handlebars in the same directory where all
> other default mods are present. $VERTX_HOME/mods
> Then we had a file named App.groovy in a different folder. (For example
> C:\test\App.groovy) App.groovy tries to load the module handlebars
> programmatically using deployVerticle
>
> VERTX_HOME environment is set to install directory. $VERTX_HOME/bin is in
> path. VERTX_MODS was not set.
>
> The command line used was "vertx run App.groovy"
>
> I have all these files athttps://github.com/sujithvellat/vertx-handlebars
> >>   "main": "/projects/software/vert.x-1.**0.1.final/mods/handlebars/app.**
> >>>> To view this discussion on the web, visithttps://groups.google.com/d/*
> >>>> *msg/vertx/-/-WkbB-u7IAwJ<https://groups.google.com/d/msg/vertx/-/-WkbB-u7IAwJ>
> >>>> .
> >>>> To post to this group, send an email to ve...@googlegroups.com.
> >>>> To unsubscribe from this group, send email to vertx+unsubscribe@**
> >>>> googlegroups.com <vertx+un...@googlegroups.com>.
> >>>> For more options, visit this group athttp://groups.google.com/**
> >>>> group/vertx?hl=en-GB <http://groups.google.com/group/vertx?hl=en-GB>.
>
> >>>>  --
> >>> You received this message because you are subscribed to the Google
> >>> Groups "vert.x" group.
> >>>  To view this discussion on the web, visithttps://groups.google.com/d/*
> >>> *msg/vertx/-/KrMSnR5mknoJ<https://groups.google.com/d/msg/vertx/-/KrMSnR5mknoJ>.
>
> >>> To post to this group, send an email to ve...@googlegroups.com.
> >>> To unsubscribe from this group, send email to vertx+unsubscribe@**
> >>> googlegroups.com <vertx%2Bunsu...@googlegroups.com>.
> >>> For more options, visit this group athttp://groups.google.com/**
> >>> group/vertx?hl=en-GB <http://groups.google.com/group/vertx?hl=en-GB>.
>
> >>  --
> >> You received this message because you are subscribed to the Google Groups
> >> "vert.x" group.
> >> To post to this group, send an email to ve...@googlegroups.com.
> >> To unsubscribe from this group, send email to vertx+unsubscribe@**
> >> googlegroups.com <vertx+un...@googlegroups.com>.
> >> For more options, visit this group athttp://groups.google.com/**
> >> group/vertx?hl=en-GB <http://groups.google.com/group/vertx?hl=en-GB>.

Brian DiCasa

unread,
Jun 5, 2012, 9:24:04 PM6/5/12
to vert.x
Hey guys,

So I got the application working by using an absolute path as the
suggested work around.

I'm running into another issue though - I'm having trouble sending a
Groovy map as a message to the JavaScript handlebars module.

The Groovy file is the same except I'm trying to send a map to the
JavaScipt module. It is below:

import org.vertx.groovy.core.http.RouteMatcher

container.with {
deployVerticle("handlebars")
}

def rm = new RouteMatcher()

rm.get('/') { req ->
vertx.eventBus.send("handlebars", ["data": "test message"]) { reply -
>
req.response.end(reply.body)
}
}

vertx.createHttpServer().requestHandler(rm.asClosure()).listen(9292)

The JavaScript module is pretty much the same, except I'm trying to
read the data property from the map:

load('vertx.js');
load('handlebars-1.0.6-beta.js');

vertx.eventBus.registerHandler('handlebars', function(message,
replier) {
replier('echoing message data: ' message.data);
});

I'm running into a JSON parse error in the JavaScript module. Does it
look like I'm doing everything right? The error is below. Thanks again
for the help.

org.mozilla.javascript.WrappedException: Wrapped
java.lang.ClassCastException: java.lang.String cannot be cast to
org.vertx.java.core.json.JsonObject (core/even
t_bus.js#65)
        at
org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:
1786)
        at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:183)
        at
org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:
260)
        at
org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
        at
org.mozilla.javascript.gen.core_event_bus_js_4._c_anonymous_5(core/
event_bus.js:65)
        at org.mozilla.javascript.gen.core_event_bus_js_4.call(core/
event_bus.js)
        at
org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
        at
org.mozilla.javascript.gen.file__C__dev_vertx_dev_mods_handlebars_app_js_1._c_anonymous_1(file:/
C:/dev/vertx-dev/mods/handlebars/app.js:5)
        at
org.mozilla.javascript.gen.file__C__dev_vertx_dev_mods_handlebars_app_js_1.call(file:/
C:/dev/vertx-dev/mods/handlebars/app.js)
        at
org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:
97)
        at
org.mozilla.javascript.gen.core_event_bus_js_4._c_anonymous_4(core/
event_bus.js:56)
        at org.mozilla.javascript.gen.core_event_bus_js_4.call(core/
event_bus.js)
        at
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:
426)
        at
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:
3134)
        at org.mozilla.javascript.gen.core_event_bus_js_4.call(core/
event_bus.js)
        at org.mozilla.javascript.JavaAdapter.doCall(JavaAdapter.java:
642)
        at org.mozilla.javascript.JavaAdapter.access
$000(JavaAdapter.java:54)
        at org.mozilla.javascript.JavaAdapter$1.run(JavaAdapter.java:
622)
        at org.mozilla.javascript.Context.call(Context.java:521)
        at
org.mozilla.javascript.ContextFactory.call(ContextFactory.java:536)
        at
org.mozilla.javascript.JavaAdapter.callMethod(JavaAdapter.java:619)
        at adapter1.handle(<adapter>)
        at org.vertx.java.core.eventbus.impl.DefaultEventBus
$7.run(DefaultEventBus.java:503)
        at org.vertx.java.core.impl.Context$2.run(Context.java:113)
        at
org.jboss.netty.channel.socket.nio.AbstractNioWorker.processEventQueue(AbstractNioWorker.java:
360)
        at
org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:
244)
        at
org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:38)
        at
org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:
102)
        at org.jboss.netty.util.internal.DeadLockProofWorker
$1.run(DeadLockProofWorker.java:42)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown
Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: java.lang.String cannot be
cast to org.vertx.java.core.json.JsonObject
        at
org.vertx.java.core.eventbus.impl.JsonMessage.handleReply(JsonMessage.java:
30)
        at
org.vertx.java.core.eventbus.impl.BaseMessage.reply(BaseMessage.java:
51)
        at org.vertx.java.core.eventbus.Message.reply(Message.java:58)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)
        ... 30 more
Jun 05, 2012 8:36:23 PM
org.vertx.java.core.logging.impl.JULLogDelegate error
SEVERE: Exception in JavaScript verticle:
Wrapped java.lang.ClassCastException: java.lang.String cannot be cast
to org.vertx.java.core.json.JsonObject
        at core/event_bus.js:65 (anonymous)
        at file:/C:/dev/vertx-dev/mods/handlebars/app.js:5 (anonymous)
        at core/event_bus.js:56 (anonymous)

Peter Ledbrook

unread,
Jun 8, 2012, 8:11:12 AM6/8/12
to ve...@googlegroups.com
> I'm running into a JSON parse error in the JavaScript module. Does it
> look like I'm doing everything right? The error is below. Thanks again
> for the help.

The message you send back must be the same type as the one you
received. Whether this is intentional or a bug I don't know. But the
message you receive is a map, whereas you send back a string. Try
returning 'message', not 'message.data'.

Peter

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware

Tim Fox

unread,
Jun 11, 2012, 7:17:21 AM6/11/12
to ve...@googlegroups.com
I can't replicate this using your example and vert.x 1.0.1.final.

I took your "handlebars" folder and added it as a subdirectory of the mods directory in the install

I then put your JSApp.js in another directory elsewhere, and ran it with vertx run JSApp.js

The module loads and runs just fine.

I also added a little logging in app.js so I could see it was being executed.

Perhaps you could simplify your example a little? Concentrating on one language (e.g. JS) makes things clearer. Also all the stuff about registering handlers seems redundant. All you need in app.js is 

load("vertx.js");
console.log("in app.js");

And in JSApp.js:

load("vertx.js");
vertx.deployVerticle("handlebars");

Sujith Vellat

unread,
Jun 11, 2012, 9:06:48 AM6/11/12
to ve...@googlegroups.com
Thanks Tim for looking into this.

I have simplified the example as you recommended https://github.com/sujithvellat/vertx-handlebars . The mod.json file has an entry { "main": "app.js" }

I am still getting the following error. Can this be due to any difference in the rhino js jar that we are using. I built the jar from rhino source as specified in tutorial. I have uploaded the js.jar i am using as well. 
org.mozilla.javascript.JavaScriptException: Error: Module "app.js" not found.
        at org.mozilla.javascript.ScriptRuntime.throwError(ScriptRuntime.java:4023)
        at org.mozilla.javascript.commonjs.module.Require.requireMain(Require.java:150)
        at org.vertx.java.deploy.impl.rhino.RhinoVerticle.start(RhinoVerticle.java:207)
        at org.vertx.java.deploy.impl.VerticleManager$2.run(VerticleManager.java:288)
        at org.vertx.java.core.impl.DefaultVertx$2.run(DefaultVertx.java:249)
        at org.vertx.java.core.impl.Context$2.run(Context.java:113)
        at org.jboss.netty.channel.socket.nio.AbstractNioWorker.processEventQueue(AbstractNioWorker.java:360)
        at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:244)
        at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:38)
        at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102)
        at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)
Jun 11, 2012 8:52:06 AM org.vertx.java.core.logging.impl.JULLogDelegate error
SEVERE: Exception in JavaScript verticle:
Error: Module "app.js" not found.

Can you please check once the simplified example and see if I am missing something.

Thanks,
Sujith

To view this discussion on the web, visit https://groups.google.com/d/msg/vertx/-/ne8HZ-GQq-8J.

To post to this group, send an email to ve...@googlegroups.com.
To unsubscribe from this group, send email to vertx+un...@googlegroups.com.

Tim Fox

unread,
Jun 11, 2012, 9:56:03 AM6/11/12
to ve...@googlegroups.com
Hi Sujith-

Just to confirm - what version of vert.x are you using?

Tim Fox

unread,
Jun 11, 2012, 10:04:08 AM6/11/12
to ve...@googlegroups.com
I ran your simplified version (using vert.x 1.0.1.final) and it works fine for me.

I'm thinking there must be some other thing we're doing differently here.

Can you list the _exact_ steps you are using, from installing vert.x to running it, e.g.

1) Installed vert.x as per install instructions
2) Copied handlebars directory to <x>
3) Saved JSApp.js to directory <y>
4) cd into <y>
5) vertx run JSApp.js

etc

Cheers

Sujith Vellat

unread,
Jun 12, 2012, 2:28:05 AM6/12/12
to ve...@googlegroups.com
Tim,

This time I tried it on a plain RHEL 5.8 VM and still got the sam error. 

I installed jdk7 and GIT first. Then performed the following steps.

1. cd /home/vertx/projects/software/
2. wget http://vertx.io/downloads/vert.x-1.0.1.final.tar.gz
3. gzip -d vert.x-1.0.1.final.tar.gz
4. tar xf vert.x-1.0.1.final.tar
5. cd /home/vertx/projects/code
6. git clone https://github.com/sujithvellat/vertx-handlebars
7. git clone https://github.com/mozilla/rhino.git (Unnecessary step)
8. cp -pr vertx-handlebars/mods/handlebars/ ../software/vert.x-1.0.1.final/mods/
9. cd ../software/vert.x-1.0.1.final
10. set the PATH and VERTX_HOME 
export PATH=/home/vertx/projects/software/vert.x-1.0.1.final/bin:/usr/java/latest/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/vertx/bin
export VERTX_HOME=/home/vertx/projects/software/vert.x-1.0.1.final 
11. chmod +x install-rhino.sh
12. Edit the install-rhino.sh for updating to 1.8.4 ant version
13. ./install-rhino.sh
14. cd ../../code/vertx-handlebars/
15. vertx run JSApp.js 

Thanks,
Sujith

Tim Fox

unread,
Jun 12, 2012, 6:12:41 AM6/12/12
to ve...@googlegroups.com
It seems the Rhino API changed between the version 1.0.1.final was built against and what is now in Rhino master :(

I've fixed vert.x to use the correct API now, this is committed in master. Can you verify it works correctly?

It's a pain that we have to work against Rhino master, but once Rhino 1.7.R4 is out (still waiting for it :( ) these problems should be a thing of the past. 

Tim Fox

unread,
Jun 12, 2012, 11:34:13 AM6/12/12
to ve...@googlegroups.com


On Tuesday, June 12, 2012 7:28:05 AM UTC+1, Sujith Vellat wrote:
Tim,

This time I tried it on a plain RHEL 5.8 VM and still got the sam error. 

I installed jdk7 and GIT first. Then performed the following steps.

1. cd /home/vertx/projects/software/
2. wget http://vertx.io/downloads/vert.x-1.0.1.final.tar.gz
3. gzip -d vert.x-1.0.1.final.tar.gz
4. tar xf vert.x-1.0.1.final.tar
5. cd /home/vertx/projects/code
6. git clone https://github.com/sujithvellat/vertx-handlebars
7. git clone https://github.com/mozilla/rhino.git (Unnecessary step)
8. cp -pr vertx-handlebars/mods/handlebars/ ../software/vert.x-1.0.1.final/mods/
9. cd ../software/vert.x-1.0.1.final
10. set the PATH and VERTX_HOME 
export PATH=/home/vertx/projects/software/vert.x-1.0.1.final/bin:/usr/java/latest/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/vertx/bin


Fwiw, it wasn't causing the issue but it seems you have two vertx installs on your path ^^^

/home/vertx/projects/software/vert.x-1.0.1.final/bin

and

/home/vertx/bin

This might cause you problems

Sujith Vellat

unread,
Jun 12, 2012, 11:53:45 AM6/12/12
to ve...@googlegroups.com
Thanks Tim. Your change in master has fixed the issue. Also I have tested this in my Windows box an works fine now.

Though I had /home/vertx/bin in path there is no such folder in my system.
[vertx@localhost vertx-handlebars]$ echo $PATH
/home/vertx/projects/software/vert.x-1.0.1.final/bin:/usr/java/latest/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/vertx/bin
[vertx@localhost vertx-handlebars]$ cd /home/vertx/bin
-bash: cd: /home/vertx/bin: No such file or directory
[vertx@localhost vertx-handlebars]$

I have not added a github issue for this since its already fixed in master. Please do not revert the fix :)

Thanks,
Sujith

To view this discussion on the web, visit https://groups.google.com/d/msg/vertx/-/MDvi4_Uq-xAJ.

To post to this group, send an email to ve...@googlegroups.com.
To unsubscribe from this group, send email to vertx+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages