1

I am trying to schedule a cron job, which will run a java class out of a jar created using maven. I am able to run the program in IDE (IntelliJ IDEA) but when I try to run the same using terminal using below command it is throwing error.

Command I am using to run the class :

/usr/bin/java -cp zookeeper-util-1.0.0-SNAPSHOT.jar com.myapp.services.app.zk.ZKDeleteJob

Error I am getting :

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/zookeeper/KeeperException
    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 sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.zookeeper.KeeperException
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 7 more

I read another answer here where it is suggested to add following export HBASE_CLASSPATH=/usr/local/hbase-0.94.1/lib but I do not see this folder in my system, still I able to run the program from IDE.

Please help me resolve this.

Atul Kumar Verma
  • 369
  • 3
  • 8
  • 23

0 Answers0