Search code examples
apache-hivebeelineapache-sentry

Config hive with sentry: NullPointerException privilegeObj is null for


I've followed the guide step by step. But error occured when I tried to grant privilege to the role:

0: jdbc:hive2://localhost:10000/> GRANT ALL ON SERVER server1 TO ROLE admin_role;
Error: Error while compiling statement: FAILED: NullPointerException privilegeObj is null for 
TOK_GRANT
   TOK_PRIVILEGE_LIST
      TOK_PRIVILEGE
         TOK_PRIV_ALL
   TOK_PRINCIPAL_NAME
      TOK_ROLE
         admin_role
   TOK_PRIV_OBJECT
      TOK_SERVER_TYPE
         server1 (state=42000,code=40000)

I'm login to beeline as hive and the password is correct, create role is ok, and i can see the roles:

0: jdbc:hive2://localhost:10000/> show roles;
+-------------+--+
|    role     |
+-------------+--+
| test        |
| admin_role  |
+-------------+--+

but I cannot get current roles:

0: jdbc:hive2://localhost:10000/> show current roles;
+-------+--+
| role  |
+-------+--+
+-------+--+

Solution

  • Found the reason:

    hive-exec.jar of sentry and hive come frem DIFFERENT versions. The constants, such as :TOK_PRIV_OBJECT, in the two jars has different values.

    Really tricky!