Coder Social home page Coder Social logo

mod-lang-nashorn's People

Contributors

purplefox avatar vietj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mod-lang-nashorn's Issues

CommonJS support broken

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:

  1. the Vertx module loader should explicitly call the wrapper function with the global object as "this" object, see fix above
  2. modules/libraries included in commonjs libraries are loaded from the wrong location.

sANTo

beta1: cannot start application

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 with jdk 1.8.0-ea-120 and socksJS when closing connection

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.