Exception in thread "main" java.lang.NoClassDefFoundError: when launching pyspark - java

I just download the spark on Mac, the version I download is the latest one
pre-built for Hadoop 2.6
When I try to install this, on the Terminal I type bin/pyspark
I got is the following exception
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/spark/launcher/Main
Caused by: java.lang.ClassNotFoundException: org.apache.spark.launcher.Main
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)
I looked up on Google and some answer says I need to update my Java, I just downloaded latest Java version but still get the error message
Can anyone help me on this please. Please explain in detail as I'm new to Spark

I met the same problem when I was trying to install Spark 1.6.2 on Mac OS (10.11 El Captain).
After installing the latest Java JDK (Java SE Development Kit 8), I had no problem to run pyspark. You could download the latest JDK from Oracle's website.
Good luck!
BTW, I also installed the legacy Java 6 runtime for OS X 10.11 El Capitan provided by Apple because I encountered an error message To use the "java" command-line tool you need to install a JDK in the beginning of the installation process.

Related

Exception in thread "main" java.lang.NoClassDefFoundError: junit/textui/ResultPrinter After updating to Yosemite

I recently updated my system from Mavericks (OSX) to Yosemite. I use to be able to right click on a test and run it. Now I get the exception
/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/bin/java -ea -Didea.launcher.port=7541 "-Didea.launcher.bin.path=/Applications/Android Studio.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/Android Studio.app/Contents/lib/idea_rt.jar:/Applications/Android Studio.app/Contents/plugins/junit/lib/junit-rt.jar:/Users/michael.cameron/Code/Android/sdk/platforms/android-21/android.jar:/Users/michael.cameron/Code/Android/sdk/platforms/android-21/data/res:/Users/michael.cameron/Code/Android/darxstudios/TheChefsCodex/app/build/intermediates/classes/debug:/Users/michael.cameron/Code/Android/darxstudios/TheChefsCodex/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/classes.jar:/Users/michael.cameron/Code/Android/darxstudios/TheChefsCodex/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res:/Users/michael.cameron/Code/Android/darxstudios/TheChefsCodex/app/libs/ParseCrashReporting-1.8.0.jar:/Users/michael.cameron/Code/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/21.0.3/support-annotations-21.0.3.jar:/Users/michael.cameron/Code/Android/darxstudios/TheChefsCodex/app/build/intermediates/exploded-aar/com.android.support/support-v4/21.0.3/res:/Users/michael.cameron/Code/Android/darxstudios/TheChefsCodex/app/build/intermediates/exploded-aar/com.android.support/support-v4/21.0.3/classes.jar:/Users/michael.cameron/Code/Android/darxstudios/TheChefsCodex/app/build/intermediates/exploded-aar/com.android.support/support-v4/21.0.3/libs/internal_impl-21.0.3.jar:/Users/michael.cameron/Code/Android/darxstudios/TheChefsCodex/app/libs/Parse-1.8.0.jar:/Users/michael.cameron/.gradle/caches/modules-2/files-2.1/com.parse.bolts/bolts-android/1.1.4/129874135e6081269ace2312092031558865de12/bolts-android-1.1.4.jar:/Users/michael.cameron/Code/Android/darxstudios/TheChefsCodex/app/libs/bolts-android-1.1.4.jar" com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 com.darxstudios.thechefscodex.ApplicationTest
Exception in thread "main" java.lang.NoClassDefFoundError: junit/textui/ResultPrinter
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:116)
Caused by: java.lang.ClassNotFoundException: junit.textui.ResultPrinter
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)
... 3 more
it may also be related to when i tap the open Android Studio icon in my Dock i get the error no JVM was found but i can open it via Terminal no problem.
This is the same as a brand new android studio project with the default applicationTest trying to run.
So two things
First, if you try to open Android Studio on Yosemite upgrade and it says "No JVM found" you need to install the java 6 for osx here as Android requires java 1.6 and not java 1.6+.
Second, The Exception I found was caused because it was trying to run JUnit as if I wanted to run through java standard console instead of with Android.
Do not use the Java test that contains a black with arrows, use the unit tests within a Android Tests and delete all uses of the JUnit configuration.
Your configuration should look like this, then you can right click on single tests and run them like normal.
As of the release of Android Studio 1.1.0 (on Feb 18 2015), it is now possible to run standard JUnit tests in Android Studio on local JVM for as long as the code under test isn't calling Android API. Please follow the instructions in this guide for more info.

Unable to start server due following issues: Launch process failed with exit code 1

For 3 days now, I have been trying to install glassfish 4.1 on eclipse Luna version 4.4.1. I first installed the plugin from eclipse marketplace then added it in my runtime using jdk 8. I also made jdk my default since eclipse default uses jre. I have to point out that I have been been using glassfish on netbeans and tomcat on eclipse but I decided to play around with glassfish on eclipse. Every information I got on the internet didn't fix my issue.
Below is the error I got in the console. Right now, this is driving me nuts so I have decided to come to you for direction.
Thanks
Launching GlassFish on Felix platform
ERROR: Unable to create cache directory: C:\Program Files\glassfish-4.1\glassfish\domains\domain1\osgi-cache\felix
ERROR: Error creating bundle cache. (java.lang.RuntimeException: Unable to create cache directory.)
java.lang.RuntimeException: Unable to create cache directory.
at org.apache.felix.framework.cache.BundleCache.<init>(BundleCache.java:131)
at org.apache.felix.framework.Felix.init(Felix.java:640)
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiFrameworkLauncher$1.run(OSGiFrameworkLauncher.java:88)
Exception in thread "Thread-1" java.lang.RuntimeException: org.osgi.framework.BundleException: Error creating bundle cache.
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiFrameworkLauncher$1.run(OSGiFrameworkLauncher.java:90)
Caused by: org.osgi.framework.BundleException: Error creating bundle cache.
at org.apache.felix.framework.Felix.init(Felix.java:645)
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiFrameworkLauncher$1.run(OSGiFrameworkLauncher.java:88)
Caused by: java.lang.RuntimeException: Unable to create cache directory.
at org.apache.felix.framework.cache.BundleCache.<init>(BundleCache.java:131)
at org.apache.felix.framework.Felix.init(Felix.java:640)
... 1 more
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:54)
Caused by: org.glassfish.embeddable.GlassFishException: java.lang.NullPointerException
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntimeBuilder.build(OSGiGlassFishRuntimeBuilder.java:170)
at org.glassfish.embeddable.GlassFishRuntime._bootstrap(GlassFishRuntime.java:157)
at org.glassfish.embeddable.GlassFishRuntime.bootstrap(GlassFishRuntime.java:110)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:112)
... 6 more
Caused by: java.lang.NullPointerException
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntimeBuilder.newFramework(OSGiGlassFishRuntimeBuilder.java:241)
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntimeBuilder.build(OSGiGlassFishRuntimeBuilder.java:135)
... 9 more
Error stopping framework: java.lang.NullPointerException
java.lang.NullPointerException
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher$1.run(GlassFishMain.java:203)
Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=192m; support was removed in 8.0
Run Eclipse or any other IDE you use in Administrator mode.
Works for me.
I think your comment deserves to be posted as the main answer but I have been trying to mark your comment as answer but I wash't able to. So I decided to post post your comment here and then back it up with my own experience.
Answer by unwichtich:
I guess this is a similar problem. The cause may be that you have installed Glassfish in c:\Program Files. You can try to move your Glassfish installation to a directory where your normal user account has full access rights but you then have to change the path to the Glassfish installation in Eclipse.
My own experience:
Turns out that all the problems I had with the glassfish server (including exit code 1 error) was because glassfish could not handle folder names with spaces in it. So I moved the glassfish-4.1 folder from C:\Program File\glassfish-4.1.. path to C:\ glassfish-4.1.. It wiped all my tears away. This is really important in eclipse and netbeans IDEs (if you are installing the netbeans that does not come with a glassfish bundled zip).
I had the same problem and fixed it by installing Glassfish under C:\ instead of C:\Program Files. Try that.
use JDk 7 instead of JDK 8 am also faced the same issue i just changed to jdk7 its working now.

ClassNotFoundException of NIO using Tomcat 7 and Java 7

I build a web project in Eclipse Kepler with Apache Tomcat 7.0.47.
While running on server, it causes java.lang.ClassNotFoundException: java.nio.file.Paths as below.
java.lang.NoClassDefFoundError: java/nio/file/Paths
at ...
Caused by: java.lang.ClassNotFoundException: java.nio.file.Paths
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
... 12 more
It worked well before I invite this new feature of Java 7. Could anyone give me some suggest to figure out what's going on here please?
Uninstalling older version is not required.
But it is obvious that your Tomcat 7.0 still uses the jdk 6. There are two paths system path and user path. Check both of them.

JavaCV-OpenCV error

I want to capture my webcam on a easy way into Java.
I followed this tutorial with JavaCV and OpenCV: http://ganeshtiwaridotcomdotnp.blogspot.com/2011/12/opencv-javacv-eclipse-project.html
I get this error when trying some example code:
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\Francis\AppData\Local\Temp\jniopencv_core7109340164936655704.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1703)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1003)
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:403)
at com.googlecode.javacpp.Loader.load(Loader.java:342)
at com.googlecode.javacpp.Loader.load(Loader.java:316)
at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:131)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.googlecode.javacpp.Loader.load(Loader.java:335)
at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:96)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.googlecode.javacpp.Loader.load(Loader.java:335)
at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:91)
at com.googlecode.javacv.OpenCVFrameGrabber.start(OpenCVFrameGrabber.java:171)
at beeldherkenningp1.CaptureImage.captureFrame(CaptureImage.java:13)
at beeldherkenningp1.BeeldherkenningP1.main(BeeldherkenningP1.java:37)
But al my jar's are included, Microsoft Visual C++ 2010 Redistributable Package is installed, extracted OpenCV into root and my system Path is set correct... (tryed already several times to reinstal the Visual C++ Redistributable Package). (x64 bit, does it matter Netbeans is x86?)
Or does anybody know an other lib that easily captures a cam in java?
Thanks a lot!
I am the one who wrote the tutorial that you're following.
Exception in thread "main" java.lang.UnsatisfiedLinkError:
C:\Users\Francis\AppData\Local\Temp\jniopencv_core7109340164936655704.dll:
Can't find dependent libraries
It looks like the dll library is not in environment variable path because you didn't properly added the path of opencv. Or this might be issue because you have installed both x64 and x86 version of thet Visual C++ redistribuables that Romain is saying.
I suggest you to follow the steps I described here JavaCV : eclipse project configuration windows ? and Add the following to System Path ?
Configure path
64-bit version of the JDK:
[installation path]\build\common\tbb\intel64\vc10\;C:\opencv\build\x64\vc10\bin\;
32-bit version of the JDK:
[installation path]\build\common\tbb\ia32\vc10\;C:\opencv\build\x86\vc10\bin\;
Here [installation path] might be "C:\opencv"
Hope this helps.
UPDATE:
An easier and simpler step to configure JavaCV is available. Please check the link below:
http://ganeshtiwaridotcomdotnp.blogspot.com/2017/01/javacv-configuration-in-windows.html

Eclipse JBoss Plugin - Cannot start my Server a second time

I have a really strange problem. I can successfully start my Eclipse internal JBoss Server (7.0.2). I can access the website and everything is fine. But after restarting or shutting down and starting again I always receive the following error out of nowhere:
Exception in thread "main" java.lang.NoClassDefFoundError: /Users/path/Coding/JBoss
Caused by: java.lang.ClassNotFoundException: .Users.robin.Coding.JBoss
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)
I googled and looked in the JBoss forums. Some ppl had a problem with using the JRE Version instead of the JDK. I checked I am using the JDK 1.6..
Here some other informations:
Eclipse Indigo (3.7.1)
JBoss (jboss-as-web-7.0.2.Final) also tested with the newer version 7.1
JBoss Tools (3.3.x)
Java version "1.6.0_29"
Mac Os X 10.7.3 (Lion)
After deleting the internal Server in Eclipse and recreating I can again start it successfully the first time. The path to the external JBoss directory is correct.
Did anyone have the same problem or any idea what it could be?
Thanks for your help!
I found the solution. It's very strange but somehow after executing the Server a second time it's crashing because of the space in the path:
/Users/robin/Coding/JBoss Servers/..'
After removing the space I could also run the Server several times without crashing. Thanks to Perception, his comment was leading me to the solution.

Categories