luben / sctags

Ctags and Etags extractor for Scala
Apache License 2.0
33 stars 4 forks source link

java.lang.NoClassDefFoundError #1

Closed nloyola closed 9 years ago

nloyola commented 9 years ago

I just cloned the repository and built it following your instructions. When I run sctags on the sctags project I get an exception:

Command:

sctags -f TAGS -R src/main/scala

Backtrace:

Exception in thread "main" java.lang.NoClassDefFoundError: scala/reflect/internal/Trees$Tree
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2615)
    at java.lang.Class.getMethod0(Class.java:2856)
    at java.lang.Class.getMethod(Class.java:1668)
    at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: scala.reflect.internal.Trees$Tree
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 6 more

How do I fix this?

Thanks

luben commented 9 years ago

Hi, you must have the scala-2.11 distribution available and its '/bin' directory on your PATH.

The shell script tries to find the scala libraries relative to the 'scala' executable. I should make it fail earlier with a descriptive message.

luben commented 9 years ago

Hi, changed the sctags to fail fast if it can't find the "scala" executable. Also improved the README to clearly state this dependency.

nloyola commented 9 years ago

I can get it to work now, but I still have problems. I'm running Ubuntu 14.10 and I installed scala from here:

http://www.scala-lang.org/files/archive/scala-2.11.6.deb

This installs scala to /usr/bin/scala, but the file /usr/bin/scala is a symlink to /usr/share/scala/bin/scala.

To run sctags successfully I have to use the command:

SCALA_LIB="/usr/share/scala/lib" ~/sctags -f TAGS -R src/main/scala

If I don't specify SCALA_LIB on the command line, the script thinks that SCALA_LIB is /usr/bin/../lib which is the wrong directory.

Thanks

luben commented 9 years ago

Yes, right. It should be fixed in the last commit - now it will follow symlinks when trying to find where are the scala libraries.

nloyola commented 9 years ago

Perfect! It works now without specifying SCALA_LIB.

Thank you