java.lang.NoSuchFieldError:type创建Hive表时

时间:2013-10-14 22:27:54

标签: java maven hadoop hive

我正在代码中创建一个hive表:

HiveInterface client = new HiveServer.HiveServerHandler();
client.execute("CREATE TABLE u_data (" +
        "userid INT," +
        " movieid INT," +
        " rating INT" +
        ")" +
        " ROW FORMAT DELIMITED " +
        "FIELDS TERMINATED BY '\\t' " +
        "STORED AS TEXTFILE;");

运行execute命令时,我遇到了这个异常:

java.lang.NoSuchFieldError: type
at org.apache.hadoop.hive.ql.parse.HiveLexer.mKW_CREATE(HiveLexer.java:1601)
at org.apache.hadoop.hive.ql.parse.HiveLexer.mTokens(HiveLexer.java:6360)
at org.antlr.runtime.Lexer.nextToken(Lexer.java:85)
at org.antlr.runtime.BufferedTokenStream.fetch(BufferedTokenStream.java:143)
at org.antlr.runtime.BufferedTokenStream.sync(BufferedTokenStream.java:137)
at org.antlr.runtime.CommonTokenStream.setup(CommonTokenStream.java:137)
at org.antlr.runtime.CommonTokenStream.LT(CommonTokenStream.java:94)
at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:546)
at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:437)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:417)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:337)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:889)
at org.apache.hadoop.hive.service.HiveServer$HiveServerHandler.execute(HiveServer.java:191)

我能找到的唯一线索是它与antlr-*.jar相关的东西,我作为依赖项添加到我的pom.xml - 最新版本。

注意:服务器是我在java代码中启动的独立服务器。

1 个答案:

答案 0 :(得分:0)

经过一番调查,并尝试了几个antlr罐子,我终于通过添加这个maven依赖来解决它:

<dependency>
   <groupId>org.antlr</groupId>
   <artifactId>antlr</artifactId>
   <version>3.0.1</version>
</dependency>

我的Hadoop jar版本为0.8.1