MatthewVita / node-hl7-complete

Node module that is bridged with the Java Hapi HL7 library.
54 stars 13 forks source link

Error: Could not create class node_hl7_complete.hl7.Parser #4

Closed CragVFX closed 7 years ago

CragVFX commented 7 years ago

Getting the following error when trying to run the example at the bottom of this issue:

/path/to/my/node_modules/node-hl7-complete/index.js:17 javaBridgeParser = java.newInstanceSync('node_hl7_complete.hl7.Parser'); ^

Error: Could not create class node_hl7_complete.hl7.Parser java.lang.NoClassDefFoundError: node_hl7_complete/hl7/Parser Caused by: java.lang.ClassNotFoundException: node_hl7_complete.hl7.Parser at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

at Error (native)
at construct (/path/to/my/node_modules/node-hl7-complete/index.js:17:29)
at /Users/jesse/Code/hl7test/node_modules/node-hl7-complete/index.js:58:3
at Object.<anonymous> (/path/to/my/node_modules/node-hl7-complete/index.js:65:2)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)

To replicate (OS X):

  1. make new dir and change dirs to it
  2. npm install node-hl7-complete
  3. create js file and paste in snippet from node-hl7-complete docs
  4. run file (node index.js)

If I clone the project and install, then run unit_tests, the test cases pass, which is interesting. Any idea what the issue might be?

MatthewVita commented 7 years ago

Hi @CragVFX !

Thanks for reaching out. The reason the npm run functional_tests works is because it is bringing in the file correctly. Requiring via npm isn't working however.

I'm working on a PR right now for this: https://github.com/MatthewVita/node-hl7-complete/pull/5

Thanks, Matthew

MatthewVita commented 7 years ago

Hi @CragVFX,

I just checked in a fix and updated NPM... please test on a *nix machine and let me know if it works now!

Thanks, Matthew

CragVFX commented 7 years ago

Hey Matthew,

Thanks for hopping on this so fast.

I had an idea for handling the java dep requiring, but I didn't have the permissions to push my branch up to github for this project. With the below changes, you would just initialize your module when using it like:

var NodeHL7Complete = require('node-hl7-complete'); var hl7 = new NodeHL7Complete(); //use hl7.hl7ToJs or whatever you want now.

Here's the changes, mostly just used the path module to do it, use it if you'd like (I didn't update the unit tests, so those would probably break but this works for the hl7ToJs and jsToHl7:

I made a gist: https://gist.github.com/CragVFX/46a80c20310093a1ebad92662fae0f30

MatthewVita commented 7 years ago

Great!

I just invited you to the repo (will have full access). Let's get your code on a branch/PR and we'll get testing!

Thanks, Matthew

MatthewVita commented 7 years ago

@CragVFX,

I made your branch a PR with added unit tests here: https://github.com/MatthewVita/node-hl7-complete/pull/6

Please test it out and then we'll merge it in a bump the package to 2.0.0 !

Note: I simply commit --amend'ed your commit so you will get full authorship, despite my small formatting and test fix additions.

Thanks, Matthew