malaporte / nashorn-commonjs-modules

CommonJS modules support for Nashorn
MIT License
108 stars 31 forks source link

java.lang.NoClassDefFoundError: com/coveo/nashorn_modules/Folder #1

Closed jwulf closed 8 years ago

jwulf commented 8 years ago

I include this in my pom.xml, and get this at runtime:

java.lang.NoClassDefFoundError: com/coveo/nashorn_modules/Folder

I'm loading it into a Bukkit plugin in Minecraft.

malaporte commented 8 years ago

When calling ResourceFolder.create you need to pass a class loader and path. What are you entering there?

jwulf commented 8 years ago

I got around that issue - I had to do this: https://bukkit.org/threads/tutorial-use-external-library-s-with-your-plugin.103781/

Now I have two distinct issues:

  1. I'm loading files from the file system. It seems like I have to supply an absolute file path as the file root?
  2. With an absolute path, the first file is loaded with a require; however that file in turn requires another file (from the same directory) and that require fails.
malaporte commented 8 years ago

I don't think you need to supply an absolute path, in particular the UT for FilesystemFolder uses a relative path. Also that's how I use this lib in a separate project. But then there might be something I'm missing.

For the require part, do you prefix the name of the string to include with ./, if it's a file in the same folder? This is required as per https://nodejs.org/api/modules.html (to the best of my understanding).

jwulf commented 8 years ago

Yes, my require looks like require('./module1.js').

Inside module1.js it has require('./module2.js'). That second include fails.

malaporte commented 8 years ago

Are you able to reproduce that issue outside Bukkit? Here it certainly works. Since you're getting a NoClassDefFound I guess that somehow something is messing up with the class loader...