diff --git a/src/examples/javascript/commonjs/main.js b/src/examples/javascript/commonjs/main.js index 4ebc38a191b..5920d263697 100644 --- a/src/examples/javascript/commonjs/main.js +++ b/src/examples/javascript/commonjs/main.js @@ -1,7 +1,7 @@ var Server, handler; -Server = require('server'); -handler = require('handler'); +Server = require('./server'); +handler = require('./handler'); server = new Server(8080, 'localhost'); server.use(handler); diff --git a/src/main/java/org/vertx/java/deploy/impl/rhino/RhinoVerticle.java b/src/main/java/org/vertx/java/deploy/impl/rhino/RhinoVerticle.java index f26924b0b41..a2d37de95de 100644 --- a/src/main/java/org/vertx/java/deploy/impl/rhino/RhinoVerticle.java +++ b/src/main/java/org/vertx/java/deploy/impl/rhino/RhinoVerticle.java @@ -107,20 +107,14 @@ public static Require installRequire(Context cx, ScriptableObject scope, List modulePaths= new ArrayList<>(); - // Get the URLs - // Must add current path since Rhino can't resolve relative module IDs when require() is used outside of a module - URL[] urls = ((URLClassLoader)cl).getURLs(); - for(URL url : urls){ - modulePaths.add(url.getPath()); - } // Hack to add the javascript core library to the module path String corePath = new File(cl.getResource("vertx.js").getPath()).getParent(); modulePaths.add(corePath); - installRequire(cx, scope, modulePaths, false); + return installRequire(cx, scope, modulePaths, false); } private static void loadScript(ClassLoader cl, Context cx, ScriptableObject scope, String scriptName) throws Exception { @@ -150,8 +144,8 @@ public void start() throws Exception { scopeThreadLocal.set(scope); clThreadLocal.set(cl); - installRequire(cl, cx, scope); - loadScript(cl, cx, scope, scriptName); + Require require = installRequire(cl, cx, scope); + require.requireMain(cx, scriptName); try { stopFunction = (Function)scope.get("vertxStop", scope);