本文介绍了java.lang.ClassNotFoundException:org.apache.hive.service.cli.HiveSQLException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了通过spring应用程序连接配置单元,我在pom.xml中添加了下面的依赖项。

 < dependency> 
< groupId> org.apache.hive< / groupId>
< artifactId> hive-jdbc< / artifactId>
< version> 2.1.1< / version>
< /依赖关系>
< dependency>
< groupId> org.apache.thrift< / groupId>
< artifactId> libfb303< / artifactId>
< version> 0.9.3< / version>
<排除项>
<排除>
< groupId> org.apache.hive< / groupId>
< artifactId> hive-common< / artifactId>
< /排除>
< /排除>
< /依赖关系>
< dependency>
< groupId> org.apache.hive< / groupId>
< artifactId> hive-service-rpc< / artifactId>
< version> 2.1.1< / version>
< /依赖关系>








任何人都请告诉我if任何罐子我失踪或什么问题。使用相同的网址,我可以通过直线连接

  $ HIVE_HOME / bin / beeline -u jdbc:hive2:// localhost:10000 / TEST_DB 

我参考了以下网址,但它不包含答案。 b

解决方案

最后能够通过spring应用程序连接配置单元。这种类型的异常,我问我们得到了由于兼容性问题与罐子,即一些版本不兼容使用spring.Below我附上我的pom.xml进行更多的澄清。 p>

 < project xmlns =http://maven.apache.org/POM/4.0.0xmlns:xsi =http ://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation =http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd /maven-4.0.0.xsd\">
< modelVersion> 4.0.0< / modelVersion>

< artifactId> spring-hadoop-samples-hive< / artifactId>

< name> Spring Hadoop示例 - Hive< / name>

< parent>
< groupId> org.springframework.samples< / groupId>
< artifactId> spring-hadoop-samples< / artifactId>
< version> 1.0.0.BUILD-SNAPSHOT< / version>
< relativePath> ../ parent / pom.xml< / relativePath>
< / parent>

<属性>
< project.build.sourceEncoding> UTF-8< /project.build.sourceEncoding>
< spring.hadoop.version> 2.3.0.M1< /spring.hadoop.version>
< hadoop.version> 2.7.1< /hadoop.version>
< hive.version> 1.2.1< /hive.version>
<! - < hive.version> 2.1.1< /hive.version> - >
< / properties>

<依赖关系>

< dependency>
< groupId> org.springframework.data< / groupId>
< artifactId> spring-data-hadoop< / artifactId>
< version> $ {spring.hadoop.version}< / version>
<排除项>
<排除>
< groupId> org.springframework< / groupId>
< artifactId> spring-context-support< / artifactId>
< /排除>
< /排除>
< /依赖关系>

< dependency>
< groupId> org.springframework< / groupId>
< artifactId> spring-jdbc< / artifactId>
< version> $ {spring.version}< / version>
< /依赖关系>

< dependency>
< groupId> org.springframework< / groupId>
< artifactId> spring-test< / artifactId>
< version> $ {spring.version}< / version>
< /依赖关系>

< dependency>
< groupId> org.springframework< / groupId>
< artifactId> spring-tx< / artifactId>
< version> $ {spring.version}< / version>
< /依赖关系>

< dependency>
< groupId> org.apache.hadoop< / groupId>
< artifactId> hadoop-common< / artifactId>
< version> $ {hadoop.version}< / version>
< scope>编译< / scope>
< /依赖关系>

< dependency>
< groupId> org.apache.hive< / groupId>
< artifactId>配置单元 - metastore< / artifactId>
< version> $ {hive.version}< / version>
< /依赖关系>

< dependency>
< groupId> org.apache.hive< / groupId>
< artifactId> hive-service< / artifactId>
< version> $ {hive.version}< / version>
< /依赖关系>

< dependency>
< groupId> org.apache.thrift< / groupId>
< artifactId> libfb303< / artifactId>
< version> 0.9.1< / version>
< /依赖关系>

< dependency>
< groupId> org.apache.hive< / groupId>
< artifactId> hive-common< / artifactId>
< version> $ {hive.version}< / version>
< scope>运行时< / scope>
< /依赖关系>


< dependency>
< groupId> org.apache.hive< / groupId>
< artifactId> hive-jdbc< / artifactId>
< version> $ {hive.version}< / version>
< scope>运行时< / scope>
< /依赖关系>

< dependency>
< groupId> org.apache.hive< / groupId>
< artifactId> hive-shims< / artifactId>
< version> $ {hive.version}< / version>
< scope>运行时< / scope>
< /依赖关系>

< dependency>
< groupId> org.apache.hive< / groupId>
< artifactId> hive-serde< / artifactId>
< version> $ {hive.version}< / version>
< scope>运行时< / scope>
< /依赖关系>

< dependency>
< groupId> org.apache.hive< / groupId>
< artifactId> hive-contrib< / artifactId>
< version> $ {hive.version}< / version>
< scope>运行时< / scope>
< /依赖关系>


< dependency>
< groupId> org.codehaus.groovy< / groupId>
< artifactId> groovy< / artifactId>
< version> 1.8.5< / version>
< scope>运行时< / scope>
< /依赖关系>

< /依赖关系>

< repositories>
< repository>
< id> spring-milestone< / id>
< url> http://repo.spring.io/libs-milestone< / url>
< / repository>
< / repositories>

< build>
< plugins>
< plugin>
< groupId> org.codehaus.mojo< / groupId>
< artifactId> appassembler-maven-plugin< / artifactId>
< version> 1.2.2< / version>
<配置>
< repositoryLayout> flat< / repositoryLayout>
< configurationSourceDirectory> src / main / config< / configurationSourceDirectory>
< copyConfigurationDirectory> true< / copyConfigurationDirectory>
< extraJvmArguments> -Xms512m -Xmx1024m -Dhive.version = $ {hive.version}< / extraJvmArguments>
<程式>
< program>
< mainClass> org.springframework.samples.hadoop.hive.HiveApp< / mainClass>
<名称> hiveApp< /名称>
< / program>
< program>
< mainClass> org.springframework.samples.hadoop.hive.HiveClientApp< / mainClass>
< name> hiveClientApp< / name>
< / program>
< program>
< mainClass> org.springframework.samples.hadoop.hive.HiveAppWithApacheLogs< / mainClass>
< name> hiveAppWithApacheLogs< / name>
< / program>
< / programs>
< / configuration>
<执行次数>
<执行>
< id>包< / id>
<目标>
< goal>汇编< / goal>
< /目标>
< /执行>
< /执行次数>
< / plugin>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-antrun-plugin< / artifactId>
<执行次数>
<执行>
< id> config< / id>
<阶段>包< /阶段>
<配置>
<任务>
< copy todir =target / appassembler / data>
< fileset dir =data/>
< / copy>
< /任务>
< / configuration>
<目标>
< goal>跑步< / goal>
< /目标>
< /执行>
< /执行次数>
< / plugin>
< / plugins>
< / build>

< / project>

之后,您可能会在运行应用程序时遇到身份验证问题。请运行以下命令。

  hadoop fs -mkdir / tmp 
hadoop fs -chmod a + w / tmp
hadoop fs -mkdir -p / user / hive / warehouse
hadoop fs -chmod a + w / user / hive / warehouse

如果他们没有文件夹结构,那么它将创建并赋予读取和写入权限。


For connecting hive through spring application i have added below dependency in pom.xml.

<dependency>
 <groupId>org.apache.hive</groupId>
 <artifactId>hive-jdbc</artifactId>
 <version>2.1.1</version>
</dependency>
<dependency>
  <groupId>org.apache.thrift</groupId>
  <artifactId>libfb303</artifactId>
  <version>0.9.3</version>
    <exclusions>
     <exclusion>
    <groupId>org.apache.hive</groupId>
        <artifactId>hive-common</artifactId>
     </exclusion>
    </exclusions>
</dependency>
<dependency>
  <groupId>org.apache.hive</groupId>
  <artifactId>hive-service-rpc</artifactId>
  <version>2.1.1</version>
</dependency>


Any one please tell me if any jars i am missing or what is the issue.Using the same url i am able to connect through beeline

 $HIVE_HOME/bin/beeline -u jdbc:hive2://localhost:10000/TEST_DB

I have refer below url but it contains no answer

org.apache.hive.service.cli.HiveSQLException: java.lang.NoClassDefFoundError: org/apache/hadoop/ipc/CallerContext$Builder

解决方案

finally able to connect hive through spring application.This type of exception which i have asked we got due to compatibility issue with jars i.e some version are not compatible to used with spring.Below i am attaching my pom.xml for more clarification.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <artifactId>spring-hadoop-samples-hive</artifactId>

    <name>Spring Hadoop Samples - Hive</name>

    <parent>
        <groupId>org.springframework.samples</groupId>
        <artifactId>spring-hadoop-samples</artifactId>
        <version>1.0.0.BUILD-SNAPSHOT</version>
        <relativePath>../parent/pom.xml</relativePath>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <spring.hadoop.version>2.3.0.M1</spring.hadoop.version>
        <hadoop.version>2.7.1</hadoop.version>
        <hive.version>1.2.1</hive.version>
        <!-- <hive.version>2.1.1</hive.version> -->
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-hadoop</artifactId>
            <version>${spring.hadoop.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-context-support</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-common</artifactId>
            <version>${hadoop.version}</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.hive</groupId>
            <artifactId>hive-metastore</artifactId>
            <version>${hive.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.hive</groupId>
            <artifactId>hive-service</artifactId>
            <version>${hive.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.thrift</groupId>
            <artifactId>libfb303</artifactId>
            <version>0.9.1</version>
        </dependency>

        <!-- runtime Hive deps start -->
        <dependency>
            <groupId>org.apache.hive</groupId>
            <artifactId>hive-common</artifactId>
            <version>${hive.version}</version>
            <scope>runtime</scope>
        </dependency>


        <dependency>
            <groupId>org.apache.hive</groupId>
            <artifactId>hive-jdbc</artifactId>
            <version>${hive.version}</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.hive</groupId>
            <artifactId>hive-shims</artifactId>
            <version>${hive.version}</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.hive</groupId>
            <artifactId>hive-serde</artifactId>
            <version>${hive.version}</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.hive</groupId>
            <artifactId>hive-contrib</artifactId>
            <version>${hive.version}</version>
            <scope>runtime</scope>
        </dependency>

        <!-- runtime Hive deps end -->

        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy</artifactId>
            <version>1.8.5</version>
            <scope>runtime</scope>
        </dependency>

    </dependencies>

    <repositories>
        <repository>
            <id>spring-milestone</id>
            <url>http://repo.spring.io/libs-milestone</url>
        </repository>
    </repositories>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>appassembler-maven-plugin</artifactId>
                <version>1.2.2</version>
                <configuration>
                    <repositoryLayout>flat</repositoryLayout>
                    <configurationSourceDirectory>src/main/config</configurationSourceDirectory>
                    <copyConfigurationDirectory>true</copyConfigurationDirectory>
                    <!-- Extra JVM arguments that will be included in the bin scripts -->
                    <extraJvmArguments>-Xms512m -Xmx1024m -Dhive.version=${hive.version}</extraJvmArguments>
                    <programs>
                        <program>
                            <mainClass>org.springframework.samples.hadoop.hive.HiveApp</mainClass>
                            <name>hiveApp</name>
                        </program>
                        <program>
                            <mainClass>org.springframework.samples.hadoop.hive.HiveClientApp</mainClass>
                            <name>hiveClientApp</name>
                        </program>
                        <program>
                            <mainClass>org.springframework.samples.hadoop.hive.HiveAppWithApacheLogs</mainClass>
                            <name>hiveAppWithApacheLogs</name>
                        </program>
                    </programs>
                </configuration>
                <executions>
                    <execution>
                        <id>package</id>
                        <goals>
                            <goal>assemble</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>config</id>
                        <phase>package</phase>
                        <configuration>
                            <tasks>
                                <copy todir="target/appassembler/data">
                                    <fileset dir="data"/>
                                </copy>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

After that you may encounter with authentication issue while running the appliation.Please run below command for that.

hadoop fs -mkdir /tmp
hadoop fs -chmod a+w /tmp
hadoop fs -mkdir -p /user/hive/warehouse
hadoop fs -chmod a+w /user/hive/warehouse

If their is no folder structure then it will create and give the read,write permission to that.

这篇关于java.lang.ClassNotFoundException:org.apache.hive.service.cli.HiveSQLException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 20:25