title: apache hive cannot connect to derby:metastore_db although ij from derby can
body: <p>I am setting up a hive on hadoop cluster on three machines. The hadoop (2.7.1) and derby (10.11) runs fine:</p>
  
  <pre><code>hduser@master:~$ ij
  ij version 10.11
  ij&gt; connect 'jdbc:derby://localhost:1527/metastore_db;create=true';
  ij&gt; select * from a;
  ID
  -----------
  
  0 rows selected
  ij&gt;
  </code></pre>
  
  <p>but hive complains:</p>
  
  <pre><code>...
  Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
          at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:522)
          at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:677)
          at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:606)
          at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
          at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
  Caused by: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
          at org.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.java:1523)
          at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.&lt;init&gt;(RetryingMetaStoreClient.java:86)
          at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.getProxy(RetryingMetaStoreClient.java:132)
          at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.getProxy(RetryingMetaStoreClient.java:104)
          at org.apache.hadoop.hive.ql.metadata.Hive.createMetaStoreClient(Hive.java:3005)
          at org.apache.hadoop.hive.ql.metadata.Hive.getMSC(Hive.java:3024)
          at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:503)
          ... 8 more
  Caused by: java.lang.reflect.InvocationTargetException
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
          at org.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.java:1521)
          ... 14 more
  Caused by: javax.jdo.JDOFatalDataStoreException: Unable to open a test connection to the given database. JDBC url = jdbc:derby://localhost:1527/metastore_db;create=true , username = APP. Terminating connectio pool (set lazyInit to true if you expect to start your database after your app). Original Exception: ------
  java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/metastore_db;create=true
  ...
  </code></pre>
  
  <p>environmental variables:</p>
  
  <pre><code># Java
  export JAVA_HOME=/usr/lib/jvm/jdk
  
  # derby
  
  export DERBY_HOME=/usr/local/derby
  export PATH=$PATH:$DERBY_HOME/bin
  export CLASSPATH=$CLASSPATH:$DERBY_HOME/lib/derby.jar:$DERBY_HOME/lib/derbytools.jar
  
  # Hadoop
  export HADOOP_HOME=/usr/local/hadoop
  export PATH=$PATH:$HADOOP_HOME/bin
  export PATH=$PATH:$HADOOP_HOME/sbin
  export HADOOP_MAPRED_HOME=$HADOOP_HOME
  export HADOOP_COMMON_HOME=$HADOOP_HOME
  export HADOOP_HDFS_HOME=$HADOOP_HOME
  export HADOOP_YARN_HOME=$HADOOP_HOME
  export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
  export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib"
  
  
  # hive
  
  export HIVE_HOME=/usr/local/hive
  export PATH=$PATH:$HIVE_HOME/bin
  export CLASSPATH=$CLASSPATH:/usr/local/hive/lib/*:.
  </code></pre>
  
  <p>hive-site.xml has only this property in the config:</p>
  
  <pre><code>  &lt;property&gt;
       &lt;name&gt;javax.jdo.option.ConnectionURL&lt;/name&gt;
       &lt;value&gt;jdbc:derby://localhost:1527/metastore_db;create=true &lt;/value&gt;
       &lt;description&gt;JDBC connect string for a JDBC metastore &lt;/description&gt;
    &lt;/property&gt;
  </code></pre>
  
  <p>what's going on?</p>