vert-x / mod-lang-nashorn Goto Github PK
View Code? Open in Web Editor NEWVert.x 2.x is deprecated - use instead
Home Page: https://github.com/vert-x3/vertx-lang-js
License: Other
Vert.x 2.x is deprecated - use instead
Home Page: https://github.com/vert-x3/vertx-lang-js
License: Other
I'm trying to run some existing code on Nashorn instead of Rhino by using mod-lang-nashorn.
The code uses CommonJS to "require" some external libraries, such as URI.js
With the Rhino module everything works, but with the Nashorn module I get the following error:
javax.script.ScriptException: TypeError: Cannot read property "punycode" from undefined in <eval> at line number 27
FYI: punycode is another library, that is being "required" by the URI.js library.
First I thought it was an issue with the URI.js library and created a ticket for it at the URI.js github site.
But they explained (and convinced) me that the issues are caused by some bugs in the Vert.x Nashorn module and not in the URI.js library.
The error above can easily be solved by changing line 60 in VertxRequire from this:
"})({ id: __jscriptcontext.getModule().getId(),\n" +
to this:
"})(this, { id: __jscriptcontext.getModule().getId(),\n" +
This simple change fixes the error mentioned above.
Unfortunately there is one other bug, namely that the modules "required" by a CommonJS module are loaded from a wrong location.
E.g. URI.js loads several other libraries, like this:
module.exports = factory(require('./punycode'), require('./IPv6'), require('./SecondLevelDomains'));
When I try to load URI.js (and therefore also those other libraries) with following code:
var URI = require("js/libs/uri/URI");
I get the following error:
Cannot find script: ./punycode.js
In other words, the Nashorn module is trying to load those modules from the wrong location.
So to summarize, there are 2 issues with the CommonJS support in mod-lang-nashorn:
sANTo
In my langs.properties I have:
nashorn=io.vertx~lang-nashorn~1.0.0-beta1:org.vertx.java.platform.impl.NashornVerticleFactory
.js=nashorn
When I try to start the server, I get the following error:
$ vertx run server.js
Module io.vertx~lang-js~1.0.0-SNAPSHOT not found in any repositories
I use 2.0.2-final. Any ideas?
Exception in Nashorn JavaScript verticle
java.lang.UnsupportedOperationException
at org.vertx.java.core.sockjs.EventBusBridgeHook$$NashornJavaAdapter.handleUnregister(Unknown Source)
at org.vertx.java.core.sockjs.EventBusBridge.handleUnregister(EventBusBridge.java:660)
at org.vertx.java.core.sockjs.EventBusBridge.handleSocketClosed(EventBusBridge.java:123)
at org.vertx.java.core.sockjs.EventBusBridge.access$400(EventBusBridge.java:40)
at org.vertx.java.core.sockjs.EventBusBridge$2.handle(EventBusBridge.java:266)
at org.vertx.java.core.VoidHandler.handle(VoidHandler.java:27)
at org.vertx.java.core.VoidHandler.handle(VoidHandler.java:24)
at org.vertx.java.core.sockjs.impl.Session.doClose(Session.java:297)
at org.vertx.java.core.sockjs.impl.Session.shutdown(Session.java:162)
at org.vertx.java.core.sockjs.impl.WebSocketTransport$WebSocketListener$2.handle(WebSocketTransport.java:104)
at org.vertx.java.core.VoidHandler.handle(VoidHandler.java:27)
at org.vertx.java.core.VoidHandler.handle(VoidHandler.java:24)
at org.vertx.java.core.http.impl.WebSocketImplBase.handleClosed(WebSocketImplBase.java:158)
at org.vertx.java.core.http.impl.ServerConnection.handleClosed(ServerConnection.java:258)
at org.vertx.java.core.net.impl.VertxHandler$3.run(VertxHandler.java:120)
at org.vertx.java.core.impl.DefaultContext$3.run(DefaultContext.java:176)
at org.vertx.java.core.impl.DefaultContext.execute(DefaultContext.java:135)
at org.vertx.java.core.net.impl.VertxHandler.channelInactive(VertxHandler.java:118)
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelInactive(DefaultChannelHandlerContext.java:238)
at io.netty.channel.DefaultChannelHandlerContext.fireChannelInactive(DefaultChannelHandlerContext.java:224)
at io.netty.handler.codec.ReplayingDecoder.channelInactive(ReplayingDecoder.java:347)
at io.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder.channelInactive(WebSocket08FrameDecoder.java:479)
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelInactive(DefaultChannelHandlerContext.java:238)
at io.netty.channel.DefaultChannelHandlerContext.fireChannelInactive(DefaultChannelHandlerContext.java:224)
at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:767)
at io.netty.channel.AbstractChannel$AbstractUnsafe$5.run(AbstractChannel.java:560)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
at java.lang.Thread.run(Thread.java:744)
Exception in Nashorn JavaScript verticle
java.lang.UnsupportedOperationException
at org.vertx.java.core.sockjs.EventBusBridgeHook$$NashornJavaAdapter.handleUnregister(Unknown Source)
at org.vertx.java.core.sockjs.EventBusBridge.handleUnregister(EventBusBridge.java:660)
at org.vertx.java.core.sockjs.EventBusBridge.handleSocketClosed(EventBusBridge.java:123)
at org.vertx.java.core.sockjs.EventBusBridge.access$400(EventBusBridge.java:40)
at org.vertx.java.core.sockjs.EventBusBridge$2.handle(EventBusBridge.java:266)
at org.vertx.java.core.VoidHandler.handle(VoidHandler.java:27)
at org.vertx.java.core.VoidHandler.handle(VoidHandler.java:24)
at org.vertx.java.core.sockjs.impl.Session.doClose(Session.java:297)
at org.vertx.java.core.sockjs.impl.Session.shutdown(Session.java:162)
at org.vertx.java.core.sockjs.impl.WebSocketTransport$WebSocketListener$2.handle(WebSocketTransport.java:104)
at org.vertx.java.core.VoidHandler.handle(VoidHandler.java:27)
at org.vertx.java.core.VoidHandler.handle(VoidHandler.java:24)
at org.vertx.java.core.http.impl.WebSocketImplBase.handleClosed(WebSocketImplBase.java:158)
at org.vertx.java.core.http.impl.ServerConnection.handleClosed(ServerConnection.java:258)
at org.vertx.java.core.net.impl.VertxHandler$3.run(VertxHandler.java:120)
at org.vertx.java.core.impl.DefaultContext$3.run(DefaultContext.java:176)
at org.vertx.java.core.impl.DefaultContext.execute(DefaultContext.java:135)
at org.vertx.java.core.net.impl.VertxHandler.channelInactive(VertxHandler.java:118)
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelInactive(DefaultChannelHandlerContext.java:238)
at io.netty.channel.DefaultChannelHandlerContext.fireChannelInactive(DefaultChannelHandlerContext.java:224)
at io.netty.handler.codec.ReplayingDecoder.channelInactive(ReplayingDecoder.java:347)
at io.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder.channelInactive(WebSocket08FrameDecoder.java:479)
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelInactive(DefaultChannelHandlerContext.java:238)
at io.netty.channel.DefaultChannelHandlerContext.fireChannelInactive(DefaultChannelHandlerContext.java:224)
at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:767)
at io.netty.channel.AbstractChannel$AbstractUnsafe$5.run(AbstractChannel.java:560)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
at java.lang.Thread.run(Thread.java:744)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.