title: Hive JDBC Connection NoClassDefFoundError
body: <p>I am using Hive 2.1.1 and trying to create a connection. Following is the code I am trying:</p>
  
  <pre><code>private static String driverName = "org.apache.hive.jdbc.HiveDriver";
  
  public static void main(String[] args) throws SQLException, ClassNotFoundException {
      // Register driver and create driver instance
  
      Class.forName(driverName);
      // get connection
  
      Connection con = DriverManager.getConnection("jdbc:hive2://", "", "");
      Statement stmt = con.createStatement();
  
      stmt.executeQuery("CREATE DATABASE userdb");
      System.out.println("Database userdb created successfully.");
  
      con.close();
  }
  </code></pre>
  
  <p>These are my classpaths declared in bashrc:</p>
  
  <blockquote>
    <p>CLASSPATH=$CLASSPATH:/usr/lib/hive/lib/hive-jdbc-2.1.1.jar
    CLASSPATH=$CLASSPATH:/usr/local/hadoop/lib/*:.
    CLASSPATH=$CLASSPATH:/usr/local/apache-hive-2.1.1-bin/lib</p>
  </blockquote>
  
  <p>I am getting the error below. </p>
  
  <blockquote>
    <p>ERROR StatusLogger No log4j2 configuration file found. Using default
    configuration: logging only errors to the console. Exception in thread
    "main" java.lang.NoClassDefFoundError:
    org/apache/hadoop/hive/ql/metadata/HiveException  at
    org.apache.hive.service.cli.thrift.EmbeddedThriftBinaryCLIService.(EmbeddedThriftBinaryCLIService.java:33)
      at
    org.apache.hive.jdbc.HiveConnection.(HiveConnection.java:163)
      at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107)     at
    java.sql.DriverManager.getConnection(DriverManager.java:664)  at
    java.sql.DriverManager.getConnection(DriverManager.java:247)  at
    com.raad.ams.bean.HiveJdbc.main(HiveJdbc.java:17)     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:498)     at
    com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
    Caused by: java.lang.ClassNotFoundException:
    org.apache.hadoop.hive.ql.metadata.HiveException  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)</p>
  </blockquote>
  
  <p>Any help would be appreciated.</p>