<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question How to configure Impala/Hive2 JDBC driver in Apache Tomcat without ClassNotFound exceptions in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-configure-Impala-Hive2-JDBC-driver-in-Apache-Tomcat/m-p/16982#M2586</link>
    <description>&lt;P&gt;I am attempting to add the Impala/Hive2 JDBC driver to an existing application that is deployed with Tomcat 7 (7.0.54). Other JDBC drivers work fine (Oracle, MS SS, SyBase).&lt;BR /&gt;&lt;BR /&gt;However, the driver never connected and always threw exceptions that would not be trapped by Java (JDK 1.7.0_55) in Eclipse (Kepler). This is being done on a Windows 8.1 Lenovo T500 laptop. There were no meaningful error messages nor stack traces.&lt;BR /&gt;&lt;BR /&gt;To find out where the errors occur, I got the Hive source code and made a simple Java program to test the JDBC connection stepping through in DEBUG. There were reference errors to missing classes that were not in the jars than specified in [Clouder's documentation][1] . There are errors in HiveConnection.java ( org.apache.hive.jdbc) for : &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; import org.apache.hadoop.hive.ql.session.SessionState; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; import org.apache.http.impl.client.DefaultHttpClient; &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I tracked down where these classes exist and added the following jars to the UserLibrary I made:&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hive-exec-0.12.0.jar&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; which contains the packages for ....hive.ql..... &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; httpclient-4.2.5.jar&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; which contains the packages for ....http.impl.client.... &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;After adding `httpclient`, there is still a reference error for&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; httpClient.addRequestInterceptor&amp;nbsp;&amp;nbsp; - message =&amp;nbsp; The type org.apache.http.HttpRequestInterceptor cannot be resolved. It is indirectly referenced from required .class files&lt;BR /&gt;&lt;BR /&gt;I tracked this to:&amp;nbsp; `httpcore-4.2.4.jar`&lt;BR /&gt;&lt;BR /&gt;The standalone Java program successfully connected to the Impala daemon. I added these jars to the Tomcat /WEB-INF/ib/ folder along with the JDBC packages as Java source code. Tomcat had problems including not being able to publish ginving an IndexOutOfBounds exception. I found this was primarily due to the `hadoop-common` jar. I was able to get it to publish by completely cleaning the Tomcat definition and then also the project and adding this jar as the last one. Still took a few attempts.&lt;BR /&gt;&lt;BR /&gt;Then, running the application also stopped with exceptions at DriverManager.getConnection(connstr). The errors were always related to not seeing various classes that were in the jar files loaded into the /WEB-INF/lib/ folder. Deleting and then re-importing them walked through these errors in the following sequence: &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; org/apache/http/client/httpclient&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (in httpclient jar) &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; org/apache/http/httprequestinterceptor (in httpcore jar) &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; org/apache/hadoop/conf/configuration&amp;nbsp;&amp;nbsp; (in hadoop-common jar) &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; org/apache/hadoop/hive/conf/hiveconf&amp;nbsp;&amp;nbsp; (in hive-common AND hive-exec jars) &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;A final odd error for `HIVE_CLI_SERVICE_PROTOCOL_V6`.&amp;nbsp;&amp;nbsp; The latter was hard to track down until I saw it in the Java code in HiveConnection.java where `HIVE_CLI_SERVICE_PROTOCOL_Vx` are added to a collection of supportedProtocols.&amp;nbsp; This is used to check the response from Impala and if Impala uses one not in the list then the connection is cancelled. In the version I have, V1-V3 are used. I found that the most recent source on SVN is up to V7 but these are not used in the JDBC code shipped with CDH5.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Doing another cycle of removing everything and then adding the library jars and then source code for JDBC (so did not add JDBC jar) into packages in my Tomcat Java/src folder: &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; org.apache.hadoop.hive.jdbc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Hive 1 driver) &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; org.apache.hive.jdbc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Hive 2 driver) &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;At long last, I was able to step through in DEBUG the HiveConnection and successfully made the communication and could check the response from Impala. It responded it was using ____V1 protocol so it was accepted.&lt;BR /&gt;&lt;BR /&gt;Since the documentation states that only some of the jars are needed but I found several more needed just to satisfy the import statements, how can I configure Tomcat so I can use just the distributed JDBC driver and its support jars? I suspect there may an issue in how Tomcat does class loading since I noticed the killer exception occuring in Catalina.jar with its classloader (no source code for this so I do not know exactly where or why).&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; [1]: &lt;A href="http://www.cloudera.com/content/cloudera-content/cloudera-docs/Impala/latest/Installing-and-Using-Impala/ciiu_impala_jdbc.html" target="_blank"&gt;http://www.cloudera.com/content/cloudera-content/cloudera-docs/Impala/latest/Installing-and-Using-Impala/ciiu_impala_jdbc.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Sep 2022 09:05:05 GMT</pubDate>
    <dc:creator>gmalafsky</dc:creator>
    <dc:date>2022-09-16T09:05:05Z</dc:date>
    <item>
      <title>How to configure Impala/Hive2 JDBC driver in Apache Tomcat without ClassNotFound exceptions</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-configure-Impala-Hive2-JDBC-driver-in-Apache-Tomcat/m-p/16982#M2586</link>
      <description>&lt;P&gt;I am attempting to add the Impala/Hive2 JDBC driver to an existing application that is deployed with Tomcat 7 (7.0.54). Other JDBC drivers work fine (Oracle, MS SS, SyBase).&lt;BR /&gt;&lt;BR /&gt;However, the driver never connected and always threw exceptions that would not be trapped by Java (JDK 1.7.0_55) in Eclipse (Kepler). This is being done on a Windows 8.1 Lenovo T500 laptop. There were no meaningful error messages nor stack traces.&lt;BR /&gt;&lt;BR /&gt;To find out where the errors occur, I got the Hive source code and made a simple Java program to test the JDBC connection stepping through in DEBUG. There were reference errors to missing classes that were not in the jars than specified in [Clouder's documentation][1] . There are errors in HiveConnection.java ( org.apache.hive.jdbc) for : &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; import org.apache.hadoop.hive.ql.session.SessionState; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; import org.apache.http.impl.client.DefaultHttpClient; &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I tracked down where these classes exist and added the following jars to the UserLibrary I made:&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hive-exec-0.12.0.jar&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; which contains the packages for ....hive.ql..... &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; httpclient-4.2.5.jar&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; which contains the packages for ....http.impl.client.... &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;After adding `httpclient`, there is still a reference error for&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; httpClient.addRequestInterceptor&amp;nbsp;&amp;nbsp; - message =&amp;nbsp; The type org.apache.http.HttpRequestInterceptor cannot be resolved. It is indirectly referenced from required .class files&lt;BR /&gt;&lt;BR /&gt;I tracked this to:&amp;nbsp; `httpcore-4.2.4.jar`&lt;BR /&gt;&lt;BR /&gt;The standalone Java program successfully connected to the Impala daemon. I added these jars to the Tomcat /WEB-INF/ib/ folder along with the JDBC packages as Java source code. Tomcat had problems including not being able to publish ginving an IndexOutOfBounds exception. I found this was primarily due to the `hadoop-common` jar. I was able to get it to publish by completely cleaning the Tomcat definition and then also the project and adding this jar as the last one. Still took a few attempts.&lt;BR /&gt;&lt;BR /&gt;Then, running the application also stopped with exceptions at DriverManager.getConnection(connstr). The errors were always related to not seeing various classes that were in the jar files loaded into the /WEB-INF/lib/ folder. Deleting and then re-importing them walked through these errors in the following sequence: &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; org/apache/http/client/httpclient&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (in httpclient jar) &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; org/apache/http/httprequestinterceptor (in httpcore jar) &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; org/apache/hadoop/conf/configuration&amp;nbsp;&amp;nbsp; (in hadoop-common jar) &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; org/apache/hadoop/hive/conf/hiveconf&amp;nbsp;&amp;nbsp; (in hive-common AND hive-exec jars) &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;A final odd error for `HIVE_CLI_SERVICE_PROTOCOL_V6`.&amp;nbsp;&amp;nbsp; The latter was hard to track down until I saw it in the Java code in HiveConnection.java where `HIVE_CLI_SERVICE_PROTOCOL_Vx` are added to a collection of supportedProtocols.&amp;nbsp; This is used to check the response from Impala and if Impala uses one not in the list then the connection is cancelled. In the version I have, V1-V3 are used. I found that the most recent source on SVN is up to V7 but these are not used in the JDBC code shipped with CDH5.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Doing another cycle of removing everything and then adding the library jars and then source code for JDBC (so did not add JDBC jar) into packages in my Tomcat Java/src folder: &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; org.apache.hadoop.hive.jdbc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Hive 1 driver) &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; org.apache.hive.jdbc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Hive 2 driver) &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;At long last, I was able to step through in DEBUG the HiveConnection and successfully made the communication and could check the response from Impala. It responded it was using ____V1 protocol so it was accepted.&lt;BR /&gt;&lt;BR /&gt;Since the documentation states that only some of the jars are needed but I found several more needed just to satisfy the import statements, how can I configure Tomcat so I can use just the distributed JDBC driver and its support jars? I suspect there may an issue in how Tomcat does class loading since I noticed the killer exception occuring in Catalina.jar with its classloader (no source code for this so I do not know exactly where or why).&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; [1]: &lt;A href="http://www.cloudera.com/content/cloudera-content/cloudera-docs/Impala/latest/Installing-and-Using-Impala/ciiu_impala_jdbc.html" target="_blank"&gt;http://www.cloudera.com/content/cloudera-content/cloudera-docs/Impala/latest/Installing-and-Using-Impala/ciiu_impala_jdbc.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 09:05:05 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-configure-Impala-Hive2-JDBC-driver-in-Apache-Tomcat/m-p/16982#M2586</guid>
      <dc:creator>gmalafsky</dc:creator>
      <dc:date>2022-09-16T09:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to configure Impala/Hive2 JDBC driver in Apache Tomcat without ClassNotFound exceptions</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-configure-Impala-Hive2-JDBC-driver-in-Apache-Tomcat/m-p/294356#M2587</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/6820"&gt;@gmalafsky&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for raising this question about how to configure Impala JDBC driver from a Windows machine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although the original question was raised some time ago, I would like to update this thread with the latest information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the latest Impala JDBC driver release the installation guide can be found under [1] in a PDF format.&lt;/P&gt;&lt;P&gt;Page 8. describes that "Before you use the Cloudera JDBC Driver for Impala, the JDBC&amp;nbsp;application or Java code that you are using to connect to your data must be able to access the driver JAR&amp;nbsp;files. In the application or code, specify all the JAR files that you extracted from the ZIP archive."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For Java7, please follow the guide under [2] to configure the classpath correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the detailed instructions, please follow [1] section "Installing and Using the Cloudera JDBC Driver for Impala".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For release notes, please navigate to [3].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let us know if there is any additional information is required for this thread to be marked as solved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards:&lt;/P&gt;&lt;P&gt;Ferenc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[1]&amp;nbsp;&lt;A href="https://docs.cloudera.com/documentation/other/connectors/impala-jdbc/latest/Cloudera-JDBC-Driver-for-Impala-Install-Guide.pdf" target="_blank"&gt;https://docs.cloudera.com/documentation/other/connectors/impala-jdbc/latest/Cloudera-JDBC-Driver-for-Impala-Install-Guide.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[2] &lt;A href="http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html" target="_blank"&gt;http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[3]&amp;nbsp;&lt;A href="https://docs.cloudera.com/documentation/other/connectors/impala-jdbc/latest.html" target="_blank"&gt;https://docs.cloudera.com/documentation/other/connectors/impala-jdbc/latest.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Apr 2020 13:59:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-configure-Impala-Hive2-JDBC-driver-in-Apache-Tomcat/m-p/294356#M2587</guid>
      <dc:creator>Bender</dc:creator>
      <dc:date>2020-04-20T13:59:45Z</dc:date>
    </item>
  </channel>
</rss>

