title: ClassNotFoundException when connecting Hive from a Java client
body: <p>In a Java client, I am trying to execute a query over a table in Hive. When executing query, program throws <code>java.lang.ClassNotFoundException</code> as detailed below. I have <code>hadoop-core-1.0.4.jar</code> in my classpath. Hive version is 0.12.0 and hadoop version is 1.0.4. I could not fix the problem. What could it be? Below is the code piece and error.</p>
  
  <pre><code>public static String getDummyData() {
      String result = "";
      String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver";
      try {
          Class.forName(driverName);
      } catch (ClassNotFoundException e) {
          log.error("Could not find driver", e);
      }
      try {
          Connection conn = DriverManager.getConnection("jdbc:hive://noon102:10000/default", "","");
          String tableName = "user";
          String query = "select * from " + tableName + " where id = ?";
          PreparedStatement ipMacSt = conn.prepareStatement(query);
          ipMacSt.setInt(1, 6);
  
          ResultSet res = ipMacSt.executeQuery();
          while (res.next()) {
              result = result + res.getString(2) + "\n";
          }
      } catch (Exception e) {
      log.error("Could not execute the query", e);
      }
  
      return result;
  }
  
  Caused by: java.lang.NoClassDefFoundError: org/apache/hadoop/io/Writable
          at org.apache.hadoop.hive.jdbc.HiveQueryResultSet.initSerde(HiveQueryResultSet.java:101)
          at org.apache.hadoop.hive.jdbc.HiveQueryResultSet.&lt;init&gt;(HiveQueryResultSet.java:66)
          at org.apache.hadoop.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:198)
          at org.apache.hadoop.hive.jdbc.HiveStatement.execute(HiveStatement.java:132)
          at org.apache.hadoop.hive.jdbc.HiveConnection.configureConnection(HiveConnection.java:133)
          at org.apache.hadoop.hive.jdbc.HiveConnection.&lt;init&gt;(HiveConnection.java:122)
          at org.apache.hadoop.hive.jdbc.HiveDriver.connect(HiveDriver.java:106)
          at java.sql.DriverManager.getConnection(DriverManager.java:582)
          at java.sql.DriverManager.getConnection(DriverManager.java:185)
          at com.**.services.HadoopOperations.getDummyData(HadoopOperations.java:90)
          ... 15 more
  Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.io.Writable
          at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
          at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
          at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
          at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
          ... 25 more
  </code></pre>