jdeploy
jdeploy copied to clipboard
java.lang.ClassNotFoundException when running my app
have built a simple REST server (2 endpoints) in Java that I need to deploy on node. I found this project last night, so I am just diving into using it. I have tried a couple of times and gotten the same result. In my latest attempt I used 'mvn clean package' to build a new copy of my project. I moved the resulting war file that runs on Apache Tomcat as is to a new, otherwise empty directory.
Then I ran 'jdeploy init' with the, by now, expected results:
$ jdeploy init Creating your package.json file with following content:
{ "bin": {"pub": "jdeploy-bundle/jdeploy.js"}, "author": "", "description": "", "main": "index.js", "preferGlobal": true, "repository": "", "version": "1.0.0", "jdeploy": {"war": "mms.war"}, "dependencies": {"shelljs": "^0.7.5"}, "license": "ISC", "name": "pub", "files": ["jdeploy-bundle"], "scripts": {"test": "echo "Error: no test specified" && exit 1"} }
Proceed? (y/N)y Writing package.json... Complete!
I made no changes to the package.json file and then ran 'jdeploy install':
$ jdeploy install Executing copy rule CopyRule{dir=., includes=[mms.war], excludes=null} .\jdeploy-bundle does not match any patterns. .\package.json does not match any patterns. .\jdeploy-bundle does not match any patterns. .\package.json does not match any patterns. npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN [email protected] No description npm WARN [email protected] No repository field.
added 16 packages from 8 contributors in 0.932s C:\Users\tullych\AppData\Roaming\npm\pub -> C:\Users\tullych\AppData\Roaming\npm\node_modules\pub\jdeploy-bundle\jdeploy.js C:\Users\tullych\AppData\Roaming\npm\node_modules\pub -> C:\Users\tullych\Projects\filechanger\maintenance-mode\pub
Since everything appears to have gone ok so far I tried to run my app:
$ pub Error: Could not find or load main class ca.weblite.jdeploy.WarRunner Caused by: java.lang.ClassNotFoundException: ca.weblite.jdeploy.WarRunner
What am I missing?
update:
I have uncommented the console.log statements in jdeploy.js and added a few of my own to the file. Which gives a much more verbose error log:
$ pub os.homedir(): C:\Users\tullych jreDir: C:\Users\tullych.jdeploy\node_modules\node-jre\jre { Error: ENOENT: no such file or directory, scandir 'C:\Users\tullych.jdeploy\node_modules\node-jre\jre' at Object.fs.readdirSync (fs.js:904:18) at getDirectories (C:\Users\tullych\Projects\filechanger\maintenance-mode\pub\jdeploy-bundle\jdeploy.js:35:36) at getEmbeddedJavaDir (C:\Users\tullych\Projects\filechanger\maintenance-mode\pub\jdeploy-bundle\jdeploy.js:54:36) at Object.
(C:\Users\tullych\Projects\filechanger\maintenance-mode\pub\jdeploy-bundle\jdeploy.js:100:15) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Function.Module.runMain (module.js:693:10) errno: -4058, code: 'ENOENT', syscall: 'scandir', path: 'C:\Users\tullych\.jdeploy\node_modules\node-jre\jre' } { [String: ''] stdout: '', stderr: 'java version "9.0.4"\r\nJava(TM) SE Runtime Environment (build 9.0.4+11)\r\nJava HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)\r\n', code: 0, cat: [Function: bound ], exec: [Function: bound ], grep: [Function: bound ], head: [Function: bound ], sed: [Function: bound ], sort: [Function: bound ], tail: [Function: bound ], to: [Function: bound ], toEnd: [Function: bound ], uniq: [Function: bound ] } stdout is java version "9.0.4" Java(TM) SE Runtime Environment (build 9.0.4+11) Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode) Java version string 9.04 { [String: ''] stdout: '', stderr: 'java version "9.0.4"\r\nJava(TM) SE Runtime Environment (build 9.0.4+11)\r\nJava HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)\r\n', code: 0, cat: [Function: bound ], exec: [Function: bound ], grep: [Function: bound ], head: [Function: bound ], sed: [Function: bound ], sort: [Function: bound ], tail: [Function: bound ], to: [Function: bound ], toEnd: [Function: bound ], uniq: [Function: bound ] } stdout is java version "9.0.4" Java(TM) SE Runtime Environment (build 9.0.4+11) Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
Java version string 9.04 Java version is 9.04 Error: Could not find or load main class ca.weblite.jdeploy.WarRunner Caused by: java.lang.ClassNotFoundException: ca.weblite.jdeploy.WarRunner
First things first, the directory C:\Users\tullych.jdeploy does not exist, so nothing referenced there will be found.
I have tried mucking around with the getJdeploySupportDir function and forcing it to point other locations. I think my problem is fundamentally that the .jdeploy directory was never created in my home directory when i used 'npm i -g jdeploy'.
This could be related to Java 9. Can you try running with Java 8 and see what happens? (i.e. Either remove JAVA_HOME entirely from your environment which will trigger it to download it's only Java 8, or set JAVA_HOME to a Java 8 home).
I get the same error after resetting my JAVA_HOME to /C/Program Files/Java/jdk1.8.0_162. But honestly my project is so small that I am just rewriting it in Javascript since it needs to run on node.
I reopened this because it is still an issue, even if the OP doesn't need it anymore.