Issue Context and Error
I have been working to install hive server 2 in order to work with Presto, among other things. I wanted to ensure I had Hive’s JDBC interface (to port 10000) working well as I need it to enable users to easily submit partition repair queries (msck repair table) and similar things. Unfortunately, when I went to connect over JDBC, I got this error (a small part of a huge stack trace):
Required field 'serverProtocolVersion' is unset!
The Solution
I think if you carefully read the full stack-trace, you’ll see something about user impersonation… but missed it. I actually figured it out by increasing the logging level when running hive server. You can do that like this:
./hive --service hiveserver2 --hiveconf hive.server2.thrift.port=10000 --hiveconf hive.root.logger=DEBUG,console
Once I did this, I clearly saw this error:
2019-06-06T13:53:13,183 WARN [HiveServer2-Handler-Pool: Thread-36] thrift.ThriftCLIService: Error opening session: org.apache.hive.service.cli.HiveSQLException: Failed to open new session: java.lang.RuntimeException: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.authorize.AuthorizationException): User: centos is not allowed to impersonate centos
Googling this quickly helped me to find this stack overflow: https://stackoverflow.com/a/50753233/857994. The proposed solution there is to add this entry to your hive-site.xml:
<property> <name>hive.server2.enable.doAs</name> <value>false</value> </property>
After that, everything works great :).