Here's the error I'm getting:
"C:\Program Files (x86)\Java\jdk1.8.0_91\bin\java" -Didea.launcher.port=7535 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.1.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\charsets.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\deploy.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\ext\access-bridge-32.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\ext\cldrdata.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\ext\dnsns.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\ext\jaccess.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\ext\jfxrt.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\ext\localedata.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\ext\nashorn.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\ext\sunec.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\ext\sunjce_provider.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\ext\sunmscapi.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\ext\sunpkcs11.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\ext\zipfs.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\javaws.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\jce.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\jfr.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\jfxswt.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\jsse.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\management-agent.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\plugin.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\resources.jar;C:\Program Files (x86)\Java\jdk1.8.0_91\jre\lib\rt.jar;F:\IJ\scatest\aas-master\ch02-intro\target\classes;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.1.2\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain com.cloudera.datascience.intro.RunIntro
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/spark/rdd/RDD
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:125)
Caused by: java.lang.ClassNotFoundException: org.apache.spark.rdd.RDD
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 6 more
Process finished with exit code 1
I searched the specified directory and the "RDD.scala" file is present.
Based on the classPath you have mentioned I assume that your trying out the example from https://github.com/sryza/aas.
You haven't imported the project properly on your IDE. you can run the same code from the command line using maven.
#run this from the respective module's directory
mvn exec:java -Dexec.mainClass="com.cloudera.datascience.intro.RunIntro"
Note : While importing the project select on the parent pom.xml file. Intellij will resolve all the dependencies by itself.
Alternatively you can add the jars manually by following Correct way to add external jars
It might be the case that you have imported the project as a sbt project.
You have to import the project as a maven project , and then run it !
You can do this by installing the Maven plugin and then re-import the project as a maven project and then run it. I hope that helps !
Related
I'm trying to run a jar which accesses a save file from a predefined directory. It runs properly when running with IntelliJ, but When I run it with "java -jar", I get a NullPointerException pointing to the third line in the following snippet:
val dir = new File("./statFiles")
dir.listFiles
.filter(_.getName.takeRight(3) == "cmf")
.map(_.getName)
I get the same exception from IntelliJ if I remove the directory, so it's probably caused by the directory not being found. I'm assuming IntelliJ does something automatically that I should do manually, but I can't tell what the issue is.
edit: I've tried running the jar both from a folder that also houses the 'statFiles' folder as well as from the path in which IntelliJ creates the jar ({project root}/classes/artifacts/{name}_jar).
Stacktrace:
Exception in thread "main" java.lang.ExceptionInInitializerError
at cmsoft.ui.GUI.main(GUI.scala)
Caused by: java.lang.NullPointerException
at scala.collection.ArrayOps$.filter$extension(ArrayOps.scala:191)
at cmsoft.io.FileHandler$.findSavedStats(FileHandler.scala:24)
at cmsoft.io.FileHandler$.findSavedStat(FileHandler.scala:32)
at cmsoft.Control$.startup(Control.scala:30)
at cmsoft.ui.GUI$.<clinit>(GUI.scala:340)
... 1 more
I use Intellij Idea 2017.3 (Ultimate Edition) to build an artifact (an executable Jar) from a Scala/SBT project; Scala version is 2.12.
Since I have added a dependency to Scallop recently, I can no longer execute the Jar file because the Scallop class ScallopConf is not in the Jar file:
$ java -jar executable.jar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/rogach/scallop/ScallopConf
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
[...]
Caused by: java.lang.ClassNotFoundException: org.rogach.scallop.ScallopConf
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 19 more
I can confirm that the ScallopConf class is not packaged into the Jar file by inspecting it manually. All other dependencies are there, no matter if they were added initially or later.
This is how I added the dependency to the build.sbt file in the project root directory:
libraryDependencies += "org.rogach" %% "scallop" % "3.1.1"
The project compiles fine both within the IDE and with sbt compile. I can also run it fine within the IDE.
I created the artifact within the IDE in a standard way. Is there anything particular I need to pay attention to, possibly related to Scallop?
As pointed out by #Andrey , the artifact settings are not automatically updated when the SBT dependencies change. To make sure everything is up-to-date, the workaround is hence to re-create the artifact after updating the SBT dependencies.
So this issue is not related to the specific dependency (Scallop in this case).
Conflicts are happening between class files of jars, therefore in the above example when libraries are removed from File | Project Structure | Artifacts | Output Layout . Everything runs fine.
In my case I had dependencies on other jars as well, so when I did this activity of removing all other libraries. ClassNotFoundException was gone but NoClassFoundEx is coming for dependent libraries which I removed.
In order to get to the exact solution I am forced to evaluate all the jar files one by one and removed unwanted libraries to get to the exact solution.
This is a follow up to this question: creating an uber jar with spring dependencies
I have created a web service using Eclipse, which is running on Windows. I need to run it as a jar on a Solaris station and there I get the ClassNotFoundException:
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication 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
I want to create a big jar with all dependencies but I don't understand the answer to that question above.. where do I add what he wrote? And then do I just need to export a jar as usual using Eclipse's export option?
What no one ever said in the answers to other questions is that you need to use maven to create the jar and not using Eclipse's export to jar option.
What you need to do is:
1) download maven from https://maven.apache.org/download.cgi
2) The maven dir contains a 'bin' folder. Add this folder to your "path" enviornment variable (on Windows 8 right click "This PC" -> properties -> Advanced System Settings -> Environment Variables -> in System Variables find "Path" -> double click it and add it by adding the bin folder path to that variable the same way other paths are located there.
3) open CMD
4) navigate to your project's folder
5) type mvn package
The jar file is created inside the "target" folder.
Good luck
I'm not an "real" developper, but I have the right to at least write some code, and add some Jars to the Eclipse build path, without spending hours trying to figure out if the Jars are actually in the Build Path.
My problem (error here below) was resolved in question [NoClassDefFoundError, cannot run MapReduceColorCount (Avro 1.7.7) by adding the correct Jars.
[cloudera#localhost ~]$ hadoop jar avroColorCount.jar exos.MapReduceColorCount2 inavro01 outavro01
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/avro/mapreduce/AvroKeyInputFormat
at exos.MapReduceColorCount2.run(MapReduceColorCount2.java:71)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:84)
at exos.MapReduceColorCount2.main(MapReduceColorCount2.java:86)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
The following are the different ways I've tried to add Jars to the build path:
1. Maven: adding Dependencies through the POM file, they appear afterwards under "Maven Dependencies".
2. "Configure Build Path": the Jars are actually located in my local file system, thus I add the (library) folders, and the folders appear under the "Referenced Libraries".
3. Create a "lib" folder in the project folder, copy/paste the Jars (located in my local file system), do a project Refresh (the lib folder appears in the Package Explorer), select all Jars and right-click "Add to Build Path"
I confirm that my code show no warnings/errors while performing either method. I usually to an "Export ..." of the Jar file in order to execute it.
Example: I've tried adding to Build Path external Jars from Cloudera's CDH5 (Hadoop 2.3.0-cdh5.1.2 and Avro 1.7.5-cdh5.1.2) which are localted locally in /opt/lib
The only method that really worked was method 3. Why it doesn't work with methods 1. or 2. ?
Thank you in advance for your support
I could not reproduce success with method 3., I received a "cannot cast to namespace.customClass" error instead of the "NoClassDefFoundError" error.
I've found an answer for the latter error with a workaround based on two variables export:
export LIBJARS=avrojar1,avrojar2,jar3
export HADOOP_CLASSPATH=avrojar1:avrojar2:jar3
and then running the hadoop jar command with -libjars ${LIBJARS}.
This was tested with method 1. and method 3. respectively.
I conclusion, my case was specific to avro-related Jars only
Thanks
I am learning the Jena API and I want to use Schemagen to create the classes that look like in the package com.hp.hpl.jena.vocabulary for my own vocabulary;
I donwloaded Jena at http://www.apache.org/dist/incubator/jena/apache-jena-2.7.0-incubating/. Once downloaded I unzipped it and leave it as it is.
C:\Users\moi\NetBeansProjects\apache-jena-2.7.0-incubating\apache-jena-2.7.0-incubating
is the folder where there is the bat folder, the bin folder, the javadoc-arq folder etc.
I tested Jena in one of my project using all the libraries in C:\Users\moi\NetBeansProjects\apache-jena-2.7.0-incubating\apache-jena-2.7.0-incubating\lib with a relative link, and it works.
To make it simple to use in the command line I moved my file "MyKnowledgeBase.rdf" in the lib folder.
I tried from the lib folder
java jena.schemagen -i "myKnowledgeBase.rdf"
and get this
Exception in thread "main" java.lang.NoClassDefFoundError: jena/schemagen
Caused by: java.lang.ClassNotFoundException: jena.schemagen
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: jena.schemagen. Program will exit.
So I tried to set the classpath :
C:\Users\moi\NetBeansProjects\apache-jena-2.7.0-incubating\apache-jena-2.7.0-incubating\lib>
set CLASSPATH=commons-codec-1.5.jar;httpclient-4.1.2.jar;httpcore-4.1.3.jar;icu4j3.4.4.jar;jena.arq-2.9.0-incubating.jar;jena.core-2.7.0-incubating.jar;jena.iri0.9.0-incubating.jar;log4j-1.2.16.jar;slf4j-api-1.6.4.jar;slf4j-log4j12-1.6.4.jar;xercesImpl-2.10.0.jar; xml-apis-1.4.01.jar;
But I have still the same error. I also tried with
java -cp commons-codec-1.5.jar;httpclient-4.1.2.jar;httpcore-4.1.3.jar;icu4j3.4.4.jar;jena.arq-2.9.0-incubating.jar;jena.core-2.7.0-incubating.jar;jena.iri0.9.0-incubating.jar;log4j-1.2.16.jar;slf4j-api-1.6.4.jar;slf4j-log4j12-1.6.4.jar;xercesImpl-2.10.0.jar; xml-apis-1.4.01.jar; jena.schemagen -i myKnowledgeBase.rdf
when I do
echo %CLASSPATH%
I get what I entered
I tried to use set CLASSPATH with the absolute path for each jar and it doesn't work too.
So now I don't know what to do.
In Jena I found the schemagen.class in the package "jena" from the jena-core-2.7.0-incubating.jar (with netbeans)
With explorer I didn't find the class file.
I already run several projects in the command line doing java -jar so java and the command line is ok
Thank you for your help
Edit :
I removed the space between the argument -classpath and %CLASSPATH% and I get something different \o/ still doesn't work but it's in progress !
"Unrecognized option" and "Could not create the java virtual machine"
Edit2 :
As I was unable to solve this I created a new project with netbeans. I created a copy of schemagen class, put it as the main class, include all the jar as libraries.
and then :
java -jar "C:\Users\moi\NetBeansProjects\MyJena\dist\MyJena.jar" -i "myKnowledgeBase.rdf" -o "C:\Users\moi\NetBeansProjects\apache-jena-2.7.0-incubating\apache-jena-2.7.0-incubating\lib" --ontology
In all recent releases, including Jena 2.7.0, Linux shell and Windows batch scripts are provided for all of the Jena command line tools. These scripts set the CLASSPATH appropriately. Since you seem to be using Windows, you should use bat\schemagen.bat.
I had the same problem.I 'm using Jena 3.10
if anyone having the same problem , the solution for this is using schemagen bat file that located in the bat folder.
I used this command line for generating the vocabulary
C:\Jena\apache-jena-3.10.0\bat\schemagen.bat -i "FileName"