Search code examples
javaphpmacosphpstormjava-9

NoClassDefFoundError and NullPointerException when opening a project with PhpStorm on OS X Sierra


Recently installed PhpStorm 2017.2.4 on my Mac Pro (Sierra 10.12.6), Java version is (9+181).

Whenever I try to open a project, PhpStorm hangs. I took a look at the log file situated in /Library/Logs/PhpStorm2017.2. There are several NoClassDefFoundError happening, with a slice of NullPointerException. Here are a few excerpts:

java.lang.NoClassDefFoundError: com/apple/eawt/AppEvent$AboutEvent
java.lang.NoClassDefFoundError: com/apple/eawt/OpenURIHandler
java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter
java.lang.NoClassDefFoundError: Could not initialize class com.intellij.credentialStore.kdbx.KdbxKt
java.lang.NullPointerException at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.b(ToolWindowManagerImpl.java:1800)
java.lang.NullPointerException at com.intellij.codeInsight.daemon.impl.DaemonListeners$MyProfileChangeListener.a(DaemonListeners.java:519)
  • I tried to change the target java version in the info.plist configuration file inside the PhpStorm package.
  • I also followed these instructions in order to be able to start the application.
  • Just to check I also installed Webstorm, which worked perfectly out of the box.

After doing some research, it looks like no one else is having this problem. I really need some inspiration, some crazy idea to try.

PS: I uploaded the log file here if anyone feels like wading through it.


Solution

  • Found a better solution, you can install PhpStorm with homebrew

    homebrew cask install phpstorm
    

    Worked like a charm.

    I'm leaving the old answer, just in case someone needs this kind of information.

    Ooookay, I got it working. But that was not pretty.

    So for some reason PhpStorm is not able to use its own bundled JDK. It's trying to use the system's default JDK, which is Java 9 for me.

    Therefore i did something a bit extreme, I replaced the lib folder in the system's JDK by a symbolic link pointing to the jre lib folder inside the Phpstorm.app package

    sudo ln -s /Applications/PhpStorm.app/Contents/jdk/Contents/Home/jre/lib /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib
    

    Needless to say that you should not use this method if you have other applications using the system's JDK.

    Thanks to LazyOne, whose comment gave me the 'aha!' moment.

    PS: if anyone needs this information, I also had to give executing permissions to fsnotifier in order to be able to browse files within the IDE

    chmod 744 /Applications/PhpStorm.app/Contents/bin/fsnotifier