Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoClassDefFoundError #73

Closed
joeroot opened this issue Nov 13, 2013 · 10 comments
Closed

java.lang.NoClassDefFoundError #73

joeroot opened this issue Nov 13, 2013 · 10 comments

Comments

@joeroot
Copy link

joeroot commented Nov 13, 2013

Hi there. When I try and execute the bin on *.nix platforms, I get a java.lang.NoClassDefFoundError error. Specifically

Exception in thread "main" java.lang.NoClassDefFoundError: scala/reflect/ClassManifest
        at com.mongodb.casbah.Implicits$$anon$4.asScala(Implicits.scala:73)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.mongodb.casbah.MongoClient.apply(MongoClient.scala:216)
        at com.onlysix.preface.retriever$.run(Retriever.scala)
Caused by: java.lang.ClassNotFoundException: scala.reflect.ClassManifest
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        ... 9 more

Everything runs fine with sbt run. Please let me know if any other details would help!

@jsuereth
Copy link
Member

Can you run the script with -d as an argument? It should print out the path that's actually used to run the program.

Thanks!

@joeroot
Copy link
Author

joeroot commented Nov 14, 2013

Hey, when I execute with -d, I get the following:

# Executing command line:
java
-Xms1024m
-Xmx1024m
-XX:MaxPermSize=256m
-XX:ReservedCodeCacheSize=128m
-cp
/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/retriever.retriever-1.0.0.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/com.amazonaws.aws-java-sdk-1.5.6.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/commons-logging.commons-logging-1.1.1.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/org.apache.httpcomponents.httpclient-4.2.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/org.apache.httpcomponents.httpcore-4.2.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/commons-codec.commons-codec-1.3.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/org.codehaus.jackson.jackson-core-asl-1.8.9.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/org.codehaus.jackson.jackson-mapper-asl-1.8.9.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/org.mongodb.casbah-commons_2.9.3-2.6.2.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/com.github.nscala-time.nscala-time_2.9.2-0.2.0.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/org.joda.joda-convert-1.2.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/org.slf4j.slf4j-api-1.6.0.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/org.mongodb.mongo-java-driver-2.11.2.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/org.mongodb.casbah-core_2.9.3-2.6.2.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/org.mongodb.casbah-query_2.9.3-2.6.2.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/org.mongodb.casbah-gridfs_2.9.3-2.6.2.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/net.liftweb.lift-json_2.9.1-2.5.1.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/org.scala-lang.scalap-2.9.1.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/com.thoughtworks.paranamer.paranamer-2.4.1.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/org.scala-lang.scala-library-2.10.1.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/com.typesafe.akka.akka-actor_2.10-2.1.4.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/com.typesafe.config-1.0.0.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/org.scala-lang.scala-compiler-2.10.1.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/org.scala-lang.scala-reflect-2.10.1.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/junit.junit-4.10.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/org.hamcrest.hamcrest-core-1.1.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/net.sourceforge.jregex.jregex-1.2_01.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/org.jblas.jblas-1.2.3.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/com.github.nscala-time.nscala-time_2.9.3-0.6.0.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/joda-time.joda-time-2.3.jar:/Users/joe/Dropbox/Developer/prelude/development/retriever/target/universal/stage/lib/org.jsoup.jsoup-1.7.2.jar
com.onlysix.preface.retriever

Exception in thread "main" java.lang.NoClassDefFoundError: scala/reflect/ClassManifest
        at com.mongodb.casbah.Implicits$$anon$4.asScala(Implicits.scala:73)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.mongodb.casbah.MongoClient.apply(MongoClient.scala:216)
        at com.onlysix.preface.retriever$.run(Retriever.scala:85)
        at com.onlysix.preface.retriever$.main(Retriever.scala:236)
        at com.onlysix.preface.retriever.main(Retriever.scala)
Caused by: java.lang.ClassNotFoundException: scala.reflect.ClassManifest
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        ... 9 more

My build.sbt is:

name := "Retriever"

version := "1.0.0"

scalaVersion := "2.9.3"

resolvers += "IESL Release" at "http://dev-iesl.cs.umass.edu/nexus/content/groups/public"

libraryDependencies ++= Seq(
  "com.amazonaws"           %  "aws-java-sdk"       % "1.5.6",
  "org.mongodb"             %% "casbah"             % "2.6.2",
  "net.liftweb"             %  "lift-json_2.9.1"    % "2.5.1",
  "com.github.nscala-time"  %% "nscala-time"        % "0.6.0",
  "org.jsoup"               %  "jsoup"              % "1.7.2"
)

retrieveManaged := true

conflictWarning := ConflictWarning.disable

packageArchetype.java_application

Thanks for your help!

@tomaszym
Copy link

Hi, I'm not sure whether it's the same issue, but seems similar.

I've successfully built a deb package, installed it and then executing through a symbolic link (placed in /usr/bin/) gives an error "class not found".
Using /usr/share//bin/ file works.

Echoing this one gives two different paths.

declare -r app_home="$(realpath "$(dirname "$0")")"

Am I using the script in wrong manner somehow or this value needs to be changed for deb packages?

@schleichardt
Copy link

I have the same problem on ubuntu with a Play 2.2 app, when I run masters-thesis-app I get

Exception in thread "main" java.lang.NoClassDefFoundError: play/core/server/NettyServer
Caused by: java.lang.ClassNotFoundException: play.core.server.NettyServer
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: play.core.server.NettyServer. Program will exit.

My current workaround to start the app with:
$(readlink -f /usr/bin/masters-thesis-app)

@digicyc
Copy link

digicyc commented Dec 1, 2013

It appears to not be packaging up the other libs that sbt is putting into .ivy/
Having a similar problem when trying to deploy my created .deb to a different server rather then the one I built the package on.

@jsuereth
Copy link
Member

jsuereth commented Dec 2, 2013

What version of native packager is everyone using? There was an issue with grabbing the real path of symlinks from the wrong location. This is either another manifestation of that, or you're not on the latest native packager version (0.6.3).

@schleichardt
Copy link

I use Play 2.2.1 so according to https://github.com/playframework/playframework/blob/2.2.1/framework/project/plugins.sbt it is native packager 0.6.0.

Is it possible to override the version? How?

@jsuereth
Copy link
Member

jsuereth commented Dec 2, 2013

Yeah, in project/plugins.sbt add this:


// make sure there's a blank line above
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.6.3")

Then, this should upgrade the version used by play and you'll see the new behavior.

@muuki88
Copy link
Contributor

muuki88 commented Dec 20, 2013

This is an issue with the realPath() method, which was fixed in 2929211 and 2929211.

Try to use the packageArchetype.java_server, which will generate by default an Upstart configuration, which let's you start you application like this:

sudo service application-name start

Starting your application another way, may cause confusing where the logging output is written as the default configuration in play uses the execution directory as a relative path for your logging files.

IMHO this ticket is resolved. (Even though I would like to replace the realPath() logic with readlink -f ;) )

@jsuereth
Copy link
Member

I understand the desire to use readlink. @havocp pushed me away from readlink I think because there was some sort of issue that readlink just doesn't handle.

In any case, since we haven't heard back I'll mark this as closed for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants