javamacosexceptionhomebrewcommandbox

Installing Ortus Commandbox on Mac OSX Sierra, running box results in errors and exceptions


I tried installing Commandbox from Ortus by downloading the zip file that also contains the JRE. This landed in the Downloads folder on my Mac running OSX Sierra. I unzipped it and tried running box. It first initialized stuff, then ran fine.

The installation tip here: https://ortus.gitbooks.io/commandbox-documentation/content/setup/installation.html suggests placing the box binary in /usr/bin. I tried but couldn't. I even tried using sudo to mv it but it said I was not permitted.

SO then I decided to use the Homebrew method of installation. I installed Homebrew. When installation was complete, I then ran "brew install commandbox". It completed ok. I then typed "which box" to see which one it would find, the one in my Downloads dir or another. It showed it was in /usr/local/bin/box. Seems to be ok.

I then ran box. It crashes and burns!

$ box
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at cliloader.LoaderCLIMain.execute(LoaderCLIMain.java:205)
    at cliloader.LoaderCLIMain.main(LoaderCLIMain.java:705)
Caused by: java.lang.NoClassDefFoundError: sun/misc/VM
    at lucee.commons.collection.Hashing.randomHashSeed(Hashing.java:263)
    at lucee.commons.collection.HashMapPro.<init>(HashMapPro.java:195)
    at lucee.commons.collection.HashMapPro.<init>(HashMapPro.java:236)
    at lucee.commons.collection.LinkedHashMapPro.<init>(LinkedHashMapPro.java:70)
    at lucee.runtime.type.StructImpl.<init>(StructImpl.java:82)
    at lucee.runtime.type.StructImpl.<init>(StructImpl.java:68)
    at lucee.runtime.type.scope.ScopeSupport.<init>(ScopeSupport.java:85)
    at lucee.runtime.type.scope.ArgumentImpl.<init>(ArgumentImpl.java:67)
    at lucee.runtime.PageContextImpl.<init>(PageContextImpl.java:263)
    at lucee.runtime.CFMLFactoryImpl.getPageContextImpl(CFMLFactoryImpl.java:154)
    at lucee.runtime.CFMLFactoryImpl.getLuceePageContext(CFMLFactoryImpl.java:140)
    at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:435)
    at lucee.runtime.engine.CFMLEngineImpl.cli(CFMLEngineImpl.java:760)
    at lucee.loader.engine.CFMLEngineWrapper.cli(CFMLEngineWrapper.java:267)
    at luceecli.CLIMain.run(CLIMain.java:223)
    ... 6 more
Caused by: java.lang.ClassNotFoundException: sun.misc.VM
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
    at lucee.loader.classloader.LuceeClassLoader.loadClass(LuceeClassLoader.java:173)
    at lucee.loader.classloader.LuceeClassLoader.loadClass(LuceeClassLoader.java:138)
    ... 21 more
Cause:
java.lang.NoClassDefFoundError: sun/misc/VM
    at lucee.commons.collection.Hashing.randomHashSeed(Hashing.java:263)
    at lucee.commons.collection.HashMapPro.<init>(HashMapPro.java:195)
    at lucee.commons.collection.HashMapPro.<init>(HashMapPro.java:236)
    at lucee.commons.collection.LinkedHashMapPro.<init>(LinkedHashMapPro.java:70)
    at lucee.runtime.type.StructImpl.<init>(StructImpl.java:82)
    at lucee.runtime.type.StructImpl.<init>(StructImpl.java:68)
    at lucee.runtime.type.scope.ScopeSupport.<init>(ScopeSupport.java:85)
    at lucee.runtime.type.scope.ArgumentImpl.<init>(ArgumentImpl.java:67)
    at lucee.runtime.PageContextImpl.<init>(PageContextImpl.java:263)
    at lucee.runtime.CFMLFactoryImpl.getPageContextImpl(CFMLFactoryImpl.java:154)
    at lucee.runtime.CFMLFactoryImpl.getLuceePageContext(CFMLFactoryImpl.java:140)
    at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:435)
    at lucee.runtime.engine.CFMLEngineImpl.cli(CFMLEngineImpl.java:760)
    at lucee.loader.engine.CFMLEngineWrapper.cli(CFMLEngineWrapper.java:267)
    at luceecli.CLIMain.run(CLIMain.java:223)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at cliloader.LoaderCLIMain.execute(LoaderCLIMain.java:205)
    at cliloader.LoaderCLIMain.main(LoaderCLIMain.java:705)
Caused by: java.lang.ClassNotFoundException: sun.misc.VM
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
    at lucee.loader.classloader.LuceeClassLoader.loadClass(LuceeClassLoader.java:173)
    at lucee.loader.classloader.LuceeClassLoader.loadClass(LuceeClassLoader.java:138)
    ... 21 more

I have no idea what to do now to fix this.

I suspect it may have fouled up things when I ran box from the Downloads folder, not realizing it would initialize stuff. I deleted the Downloads version containing both the box binary and the JRE folder and emptied the Trash.

Any suggestions on how to get Commandbox up and running now?


Solution

  • I just did some local testing and confirmed that you're on Java 9 which isn't supported right now by CommandBox. The fix is easy and you can leave Java 9 installed as the main JVM for your PC. What you need to do is take the JRE folder that you downloaded before, or just download a server version of Java 8 and rename the folder to JRE. Then place that folder in the same directory as the box binary.

    When CommandBox first starts, it checks to see if there is a folder called JRE in the same folder, and if so it uses it. If it doesn't find the folder, then it will fall back to the general version of Java your operating system has installed.

    Since Java 9 is popping up more in the wild, I'll see about getting a check for it put into CommandBox to alert people with a more useful message. We already have a similar check in place, but it only looks for Java versions less then 7.