Details
Description
I tried to execute: ./bin/hadoop namenode -format in hadoop-0.21.0 inside a folder with path: ~/Desktop/my test/hadoop-0.21.0/
But i kept receiving the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: test/hadoop-0/21/0/bin////logs
Caused by: java.lang.ClassNotFoundException: me.hadoop-0.21.0.bin....logs
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:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Tried to change the language just to test what would happen. So I got a same error with a folder name with spaces:
Exception in thread "main" java.lang.NoClassDefFoundError: ??????
Caused by: java.lang.ClassNotFoundException: ??????
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:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
(You can notice the ???, might this be a java issue?)
I was able to run it only in folder names that didn't include spaces. Both english and greek.
I tried to trace this issue and I found that the problem is in the HADOOP_HOME/hdfs script. On the last line where: exec "$JAVA" $JAVA_HEAP_MAX $HADOOP_OPTS $CLASS "$@" tries to be executed, variable HADOOP_OPTS has white spaces which produce the above errors.
A solution to this problem could be to include double quotes to each path when they are collected and call exec command with eval at the front.
I found a workaround to this issue by adding:
tmp=`echo ${HADOOP_OPTS// /\\\ }`
eval exec "$JAVA" $JAVA_HEAP_MAX $(echo ${tmp//
-/\ -}) " " $CLASS "$@"
This code basically it added backslashes in front of each space in a path.
Attachments
Issue Links
- Is contained by
-
HADOOP-9902 Shell script rewrite
- Resolved