I'm attempting to build the SimpleShortestPathsComputation example included with Giraph and run it from within my home directory. Basically, I'm just trying to tweak the SimpleShortestPaths example and run it without any hassle (not quite sure what the best way to go about that would be). My approach was as follows:
SimpleShortestPathsComputaiton.java:
import org.apache.giraph.graph.BasicComputation;
......
import org.apache.log4j.Logger;
import java.io.IOException;
public class SimpleShortestPathsComputation extends BasicComputation<
LongWritable, DoubleWritable, FloatWritable, DoubleWritable> {
......
I build it like so:
JCC = javac
JFLAGS = "-Xlint"
OUTPUT_CLASS="test"
CLASSPATH = $(HADOOP_HOME)/hadoop-core-0.20.203.0.jar:$(GIRAPH_HOME)/giraph-core/target/giraph-1.1.0-SNAPSHOT-for-hadoop-0.20.203.0-jar-with-dependencies.jar
default: SimpleShortestPathsComputation.class
SimpleShortestPathsComputation.class: SimpleShortestPathsComputation.java
mkdir -p $(OUTPUT_CLASS)
$(JCC) $(JFLAGS) -classpath $(CLASSPATH) -d $(OUTPUT_CLASS) SimpleShortestPathsComputation.java
jar cvf SimpleShortestPathsComputation.jar -C $(OUTPUT_CLASS)/ .
This works fine and I create a jar file named SimpleShortestPathsComputation. I then try running it like so:
$HADOOP_HOME/bin/hadoop jar $GIRAPH_HOME/giraph-examples/target/giraph-examples-1.1.0-SNAPSHOT-for-hadoop-0.20.203.0-jar-with-dependencies.jar \
org.apache.giraph.GiraphRunner /home/hduser/SimpleShortestPathsComputation.jar \
-vif org.apache.giraph.io.formats.JsonLongDoubleFloatDoubleVertexInputFormat \
-vip /user/hduser/input/tiny_graph.txt \
-vof org.apache.giraph.io.formats.IdWithValueTextOutputFormat \
-op /user/hduser/output/shortestpaths -w 1 \
/
However, this results in the following:
Exception in thread "main" java.lang.ClassNotFoundException: /home/hduser/SimpleShortestPathsComputation.jar
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at org.apache.giraph.utils.ConfigurationUtils.handleComputationClass(ConfigurationUtils.java:470)
at org.apache.giraph.utils.ConfigurationUtils.populateGiraphConfiguration(ConfigurationUtils.java:453)
at org.apache.giraph.utils.ConfigurationUtils.parseArgs(ConfigurationUtils.java:207)
at org.apache.giraph.GiraphRunner.run(GiraphRunner.java:74)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79)
at org.apache.giraph.GiraphRunner.main(GiraphRunner.java:124)
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:156)
I'm not quite sure what I'm doing wrong. If anyone can point me in the right direction, or link to a resource that explains an easier way of what I'm trying to accomplish, I'd greatly appreciate it!
If you are running the "Quick start", actually there are inconsistency with 1.0.0:
(1) argument "-vof" should have been "-of". "-vof" was introduced in 1.1.0 (see GIRAPH-774).
(2) In 1.0.0, there doesn't exist a class called "org.apache.giraph.examples.SimpleShortestPathsComputation", change it to "org.apache.giraph.examples.SimpleShortestPathsVertex".
Related
I opened a cmd window at this location:
C:\...\apache-jmeter-2.13\lib\ext and ran this command C:\...\apache-jmeter-2.13\lib\ext>java -jar cmdrunner-2.0.jar --tool Reporter --generate-png test.png --input-jtl C:\...\...\Desktop\jmeter\..\reports\
jpGCgraphs.jtl --plugin-type ResponseTimesOverTimeGui --width 800 --height 600
Error:
ERROR: java.lang.IllegalArgumentException: Tool class Reporter not found
*** Problem's technical details go below ***
Home directory was detected as: E:\dumps\apache-jmeter-2.13\lib\ext
Exception in thread "main" java.lang.IllegalArgumentException: Tool class Reporter not found
at kg.apc.cmdtools.PluginsCMD.getToolInstance(PluginsCMD.java:123)
at kg.apc.cmdtools.PluginsCMD.processParams(PluginsCMD.java:53)
at kg.apc.cmdtools.PluginsCMD.processParams(PluginsCMD.java:22)
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:497)
at kg.apc.cmd.UniversalRunner.main(UniversalRunner.java:105)
I am referring to solution here: http://jmeter.512774.n5.nabble.com/Unable-to-execute-JMeterPluginsCMD-Command-Line-Tool-td5681583.html
I have both required jars in the folder: cmdrunner-2.0.jar and JMeterPlugins-Extras.jar
Make sure you have jmeter-plugins-standard.jar in E:\dumps\apache-jmeter-2.13\lib\ext folder
In my case the problem was solved after I installed 'Command-Line Graph Plotting Tool' using plugins manager.
In your question, you refer to: JMeterPlugins-Extras.jar, but the reporter class is found in JMeterPlugins-Standard.jar
The JMeterPlugins-Standard.jar is found in this zip file:
https://jmeter-plugins.org/downloads/file/JMeterPlugins-Standard-1.4.0.zip
Also, it doesn't matter where the jar files are, the jar files must be in class path where you execute the command
hence it requires additional argument
windows
-cp "cmdrunner-2.0.jar;JMeterPlugins-Standard.jar"
Linux
-cp "cmdrunner-2.0.jar:JMeterPlugins-Standard.jar"
Also in the post they are saying they have added jmeter home also added to class path but here i dont see that
hence -cp "C:/pathto/jmeter/home/bin/*.*;cmdrunner-2.0.jar;JMeterPlugins-Standard.jar"
The error message is saying "main" java.lang.IllegalArgumentException: Tool class Reporter not found, means the The class in not found in the class path.
Now the overall command looks
C:\...\apache-jmeter-2.13\lib\ext>java -jar cmdrunner-2.0.jar --tool Reporter --generate-png test.png --input-jtl C:\...\...\Desktop\jmeter\..\reports\
jpGCgraphs.jtl --plugin-type ResponseTimesOverTimeGui --width 800 --height 600 -cp "cmdrunner-2.0.jar;JMeterPlugins-Standard.jar"
Hope this helps .. Please provide your findings . if this helps dont forget to click answered.
I was trying to manually comiple the HelloWorldSWT.java from the eclipse tutorial, so I used
$ javac -cp /opt/eclipse/plugins/org.eclipse.swt.gtk.linux.x86_*.jar HelloWorldSWT.java
to compile the program, and it worked. But when I tried to run it like this
$ java -cp /opt/eclipse/plugins/org.eclipse.swt.gtk.linux.x86_*.jar:. HelloWorldSWT
NoClassDefFoundError was thrown:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Display
at HelloWorldSWT.main(HelloWorldSWT.java:19)
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Display
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)
... 1 more
I tried to add quotes to the path
$ java -cp "/opt/eclipse/plugins/org.eclipse.swt.gtk.linux.x86_*.jar:." HelloWorldSWT
but it didn't work, either.
Then I tried various combo of classpaths to get it run, I used the debug perspective of eclipse to see how it ran my program, it looked like this:
/usr/lib/jvm/jdk1.7.0_51/bin/java \
-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:60185 \
-Djava.library.path=/home/joyeecheung/workspace/org.eclipse.swt.gtk.linux.x86 \
-Dfile.encoding=UTF-8 \
-classpath /home/joyeecheung/workspace/HelloWorldSWT/bin:/opt/eclipse/plugins/org.eclipse.swt_3.103.0.v20140605-2008.jar:/home/joyeecheung/workspace/org.eclipse.swt.gtk.linux.x86/bin \
HelloWorldSWT
OK, they didn't use the asterisks, so I tried
$ javac -cp /opt/eclipse/plugins/org.eclipse.swt.gtk.linux.x86_3.103.0.v20140605-2012.jar HelloWorldSWT.java
$ java -cp /opt/eclipse/plugins/org.eclipse.swt.gtk.linux.x86_3.103.0.v20140605-2012.jar:. HelloWorldSWT
to compile and run it, it worked.
So I'm wondering why when I was using the asterisk, Java seemed unable to find the class?
I'm using Ubuntu 12.04, and oracle jdk 1.7.0_51. I haven't added the current dir . into my $CLASSPATH environment variables. The HelloWorldSWT program looked like this:
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class HelloWorldSWT {
public static void main(String[] args) {
// TODO Auto-generated method stub
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Hello World!");
shell.open();
while(!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
From (http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html):
Understanding class path wildcards
Class path entries can contain the basename wildcard character , which is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR. For example, the class path entry foo/ specifies all JAR files in the directory named foo. A classpath entry consisting simply of * expands to a list of all the jar files in the current directory.
In your case try java -cp /opt/eclipse/plugins/* instead of java -cp /opt/eclipse/plugins/org.eclipse.swt.gtk.linux.x86_*.jar
I believe I've seen all of the other posts on this issue. I think this is a different question because I am looking for a way to determine which class is causing the problem.
I build my jar using Maven.
If I ask it to build for Java 5 and I run it under Java 6 it works fine.
If I ask it to build for Java 6 and I run it under Java 6 it works fine.
If I ask it to build for Java 5 and I run it under Java 5 it fails:
java.lang.RuntimeException: public static void ....main(java.lang.String[]) failed for arguments (String[]{...})
Caused by: java.lang.reflect.InvocationTargetException:
...
Caused by: java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
...
I have inspected the jar using Java Version Check and it reports all classes in the jar as built for Java 5.
I can only conclude that it is hacking its own classpath and linking up with some other library/jar on my machine that is not Java 5. This is quite possible but I do not have access to the source of that process and as far as I am aware I cannot single-step into the class loader to find out which class it is loading.
Are there any techniques I can use that will help me work out which class is causing the exception?
One way to catch almost all class definitions is to use a Java Agent using the Instrumentation API. This API allows to transform all byte codes before they are used (with the exception of some of the core classes) but, of course, you can use it to just extract the version number and generate a report without changing the byte code.
One nice property of the class file transformation is that the JVM will call the transformers before rejecting malformed/ unsupported byte code to give them a chance to transform the code to something usable. So we will see the responsible byte code before the UnsupportedClassVersionError is thrown.
Here is the code of the Java Agent which does the job:
package versioncheck;
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.IllegalClassFormatException;
import java.lang.instrument.Instrumentation;
import java.security.ProtectionDomain;
public class CheckAgent implements ClassFileTransformer
{
public static void premain(String agentArgs, Instrumentation inst)
{
inst.addTransformer(new CheckAgent(), inst.isRetransformClassesSupported());
}
public static void agentmain(String agentArgs, Instrumentation inst)
{
inst.addTransformer(new CheckAgent(), inst.isRetransformClassesSupported());
}
private int supported;
CheckAgent()
{
supported=(int)Double.parseDouble(System.getProperty("java.class.version"));
}
public byte[] transform(ClassLoader loader, String className,
Class<?> classBeingRedefined, ProtectionDomain protectionDomain,
byte[] classfileBuffer) throws IllegalClassFormatException
{
int version=(classfileBuffer[6]&0xff)<<8 | (classfileBuffer[7]&0xff);
if(version>supported)
System.out.println(className+" v"+version+" from "
+protectionDomain.getCodeSource());
return null;
}
}
Then you need to put this class in a jar together with a manifest containing the following lines:
Premain-Class: versioncheck.CheckAgent
Agent-Class: versioncheck.CheckAgent
Can-Redefine-Classes: true
And the last thing to do is to add the following parameter to command line which starts your Java application: -javaagent:pathtothe.jar
See also http://docs.oracle.com/javase/7/docs/api/java/lang/instrument/package-summary.html
As a side note, such a Java Agent could also fix the problem by transforming (down-porting) the byte code to a lower version. But that’s far beyond the original question…
Well to check what JVM versions JARs in your classpath have, I would do something like the recipe below. But as I already mentioned in the last comment, this solution doesn't cover cases when a JAR have a custom classloader which modifies classpath and does other evil things. Nevertheless you may try to use this solution and see if it helps. If no, a more elaborate solution is required...
retrieve a full classpath for your application. Usually I perform this step with Maven AppAssembler but certainly there're other ways. AppAssembler is handy because it builds a shell script with the classpath specified explicitly, so you may simply copy-paste it.
Run the following bash script with the classpath as the argument. The script uses file, unzip and bc internally, so you should have these tools installed.
The script:
#!/bin/sh -e
# force numeric to use decimal point
LC_NUMERIC=C
export LC_NUMERIC
tempdir=
cleanup() {
trap - EXIT
if test -n "$tempdir"; then
rm -rf "$tempdir" ||:
fi
exit "$#"
}
debug() {
test -z "$DEBUG" || echo "$#" >&2 ||:
}
get_jar_version() {
local ver maxVersion compare
maxVersion=0.0
for ver in $(find "$1" -type f -name '*.class' -exec file {} \; | grep 'Java class data, version' | sed -e 's;.*Java class data, version ;;'); do
debug "Version = '$ver'"
compare=$(echo "$ver > $maxVersion" | bc)
if [ "x$compare" = "x1" ]; then
maxVersion="$ver"
fi
done
debug "maxVersion=$maxVersion"
echo -n "$maxVersion"
}
process_classpath_jars() {
trap cleanup EXIT
local cp jar oldIFS maxVersion
oldIFS="$IFS"
for cp in "$#"; do
IFS=':'
for jar in $cp; do
if [ -z "$jar" -o "${jar%.jar}" = "$jar" ]; then
continue
fi
debug "processing JAR $jar"
tempdir=$(mktemp -d jar.XXXXXXX)
unzip -qq "$jar" -d "$tempdir"
IFS="$oldIFS"
maxVersion=$(get_jar_version "$tempdir")
rm -rf "$tempdir" ||:
tempdir=
IFS=':'
echo "$jar is compiled for $maxVersion JVM"
done
IFS="$oldIFS"
done
}
process_classpath_jars "$#"
I am trying to attach a custom (java) partitioner to my MapReduce streaming job. I am using this command:
../bin/hadoop jar ../contrib/streaming/hadoop-streaming-1.2.1.jar \
-libjars ./NumericPartitioner.jar -D mapred.map.tasks=12 -D mapred.reduce.tasks=36 \
-input /input -output /output/keys -mapper "map_threeJoin.py" -reducer "keycount.py" \
-partitioner newjoin.NumericPartitioner -file "map_threeJoin.py" \
-cmdenv b_size=6 -cmdenv c_size=6
The important bit of that is the file NumericPartitioner.jar, which resides in the same folder the command is being run in (a level down from the Hadoop root installation.) Here is its code:
package newjoin;
import java.util.*;
import java.lang.*;
import org.apache.hadoop.mapreduce.*;
import org.apache.hadoop.io.*;
public class NumericPartitioner extends Partitioner<Text,Text>
{
#Override
public int getPartition(Text key,Text value,int numReduceTasks)
{
return Integer.parseInt(key.toString().split("\\s")[0]) % numReduceTasks;
}
}
And yet, when I try to run the above command, I get:
-partitioner : class not found : newjoin.NumericPartitioner
Streaming Command Failed!
What's going on here, and how can I get mapReduce to find my partitioner?
-libjars option is to make your third-party JAR’s available to the remote map and reduce task JVM’s.
But for making these same third party JAR’s available to the client JVM( JVM that’s created when you run the hadoop jar command) , you need to specify in HADOOP_CLASSPATH variable
$ export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:./NumericPartitioner.jar
../bin/hadoop jar ../contrib/streaming/hadoop-streaming-1.2.1.jar \
-libjars ${HADOOP_CLASSPATH} -D mapred.map.tasks=12 -D mapred.reduce.tasks=36 \
-input /input -output /output/keys -mapper "map_threeJoin.py" -reducer "keycount.py" \
-partitioner newjoin.NumericPartitioner -file "map_threeJoin.py" \
-cmdenv b_size=6 -cmdenv c_size=6
I am trying to use randoop(automatic test generator for Java) and randoop cannot find my class:
eliezer#ubuntu:~/Desktop$ java -ea -classpath \
randoop.1.3.2.jar:home/eliezer/myclasses \
randoop.main.Main gentests \
--testclass=/home/eliezer/Desktop/myclasses/ArrayListError
policy = sun.security.provider.PolicyFile#85af80
Throwable thrown while handling command:java.lang.Error:\
classForName(/home/eliezer/Desktop/myclasses/ArrayListError)
java.lang.Error: classForName(/home/eliezer/Desktop/myclasses/ArrayListError)
at randoop.util.Reflection.classForName(Reflection.java:206)
at randoop.util.Reflection.loadClassesFromList(Reflection.java:386)
at randoop.main.GenInputsAbstract.findClassesFromArgs(GenInputsAbstract.java:507)
at randoop.main.GenTests.handle(GenTests.java:184)
at randoop.main.Main.nonStaticMain(Main.java:80)
at randoop.main.Main.main(Main.java:42)
Caused by: java.lang.ClassNotFoundException: \
/home/eliezer/Desktop/myclasses/ArrayListError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at randoop.util.Reflection.classForName(Reflection.java:198)
... 5 more
Randoop failed.
Last sequence under execution:null
My class is called ArrayListError.java and is found in /home/eliezer/Desktop/myclasses.
The randoop docs are found at: https://randoop.github.io/randoop/manual/index.html.
I am sure it is something really trivial but I'm inexperienced with these things.
You need to set your classpath such that, jvm should be able to locate all your resources like classes, files, jars etc.
In your case, ArrayListError is placed under directory /home/eliezer/Desktop/myclasses. You need to place this in your classpath.
Once you point your classpath to mentioned directory, You need to pass the class name to --testclass=ArrayListError.
java -ea -classpath randoop.1.3.2.jar:/home/eliezer/Desktop/myclasses randoop.main.Main gentests --testclass=ArrayListError
should fix your problem. I suggest you to search on setting classpath and read on.
This is wrong
my class is called ArrayListError.java and is found in
/home/eliezer/Desktop/myclasses.
Your ArrayListError.java is the source code, but java virtual machine needs a compiled class in its classpath.
EDIT:
Since you said that you have the .class file also, then your problem can be solved in two ways
a. No package
Run the command (take care of the --testclas, it is not directory, it should be the class)
java -ea -classpath randoop.1.3.2.jar:/home/eliezer/myclasses
randoop.main.Main gentests --testclass=ArrayListError
b. Class in a package
If your ArrayListError does have package com.test; make a directory /com/test in your myclasses directory and run the command below
java -ea -classpath
randoop.1.3.2.jar:/home/eliezer/myclasses/com/test/ randoop.main.Main
gentests --testclass=com.test.ArrayListError
Check your classpath on the command line;
I see home/eliezer/myclasses, without the leading /.