I am invoking a java command in python with this code [1], but I get the error in [2]. I am using python (not jpython) and I would like that python could understand that this is an exception, so that it can throw it. Is there a way to catch java exception in python?
[1] code to call java command command = "hadoop jar examples.jar wordcount /input1 /output1"
process = subprocess.Popen(
shlex.split(command), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out = process.communicate()
output = out[stdout]
[2] java exception
java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
at org.apache.hadoop.mapred.examples.MyWordCount.main(MyWordCount.java:146)
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 org.apache.hadoop.util.ProgramDriver$ProgramDescription.invoke(ProgramDriver.java:71)
at org.apache.hadoop.util.ProgramDriver.run(ProgramDriver.java:144)
at org.apache.hadoop.mapred.examples.ExampleDriver.main(ExampleDriver.java:26)
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 org.apache.hadoop.util.RunJar.run(RunJar.java:221)