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)