简体   繁体   中英

java.lang.NoSuchFieldError: type When creating a Hive table

I'm creating a hive table in code:

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;");

When running the execute command I'm getting this exception:

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)

The only clue I was able to find was it's something related to antlr-*.jar which I added as a dependency to my pom.xml - the latest version.

Note : The server is a standalone that I start in my java code.

After some investigation, and trying several antlr jars, I finally solved it by adding this maven dependency:

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

My Hadoop jars are of version 0.8.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM