Frangipanes Frangipanes - 1 year ago 308
Java Question

Unable to connect to a Kerberos-secured Phoenix datasource

I want to test pulling data from Apache HBase with a Java application. The application will use SQL-like queries via a JDBC to Apache Phoenix.

I've set up my Hadoop "cluster" on one machine using Ambari and the HortonWorks HDP 2.5 platform. I've also Kerberized the environment using Ambari's wizard, where my KDC is a seperate machine running Windows Active Directory.

Ambari shows no errors, and I am able to use
to successfully make SQL-like calls to HBase through Phoenix. I set up some example tables this way (cf. HortonWorks Phoenix & ODBC tutorial, although I had to
etc. first).

However, I am having problems creating a JDBC datasource to be used by the Java application. In my case, I am planning to host the webapp on WildFly 10.1 and I am developing with Eclipse JEE with the JBoss Tools plugin.

These are the steps I used to create the datasource:

Datasource Explorer > Database Connections > New...

  • Connection Profile: Generic JDBC

  • URL:

  • Username: hbase -I'm unsure what to put here-

  • Driver: I've created a new driver of the type "Generic JDBC Driver" and I had to add JAR files for all of the dependencies of
    . The Driver Class is

I got the connection string from an extant post in the HortonWorks community, which is why it includes the Kerberos principal and keytab used for the connection.

When I try to test the datasource connection, it churns for about 5 minutes before spitting out an error message (after something like 35 attempts). The client returns Java exceptions that the sockets are in a "closing state", and the Zookeeper logs are less helpful:

INFO [SyncThread:0:ZooKeeperServer@617] - Established session 0x157aef451560217 with negotiated timeout 40000 for client /
INFO [NIOServerCxn.Factory:] - Accepted socket connection from /
INFO [NIOServerCxn.Factory:] - Processing ruok command from /
INFO [Thread-1448:NIOServerCnxn@1007] - Closed socket connection for client / (no session established for client)

INFO [NIOServerCxn.Factory:] - Accepted socket connection from /
INFO [NIOServerCxn.Factory:] - Client attempting to establish new session at /
INFO [SyncThread:0:ZooKeeperServer@617] - Established session 0x157aef451560218 with negotiated timeout 40000 for client /
INFO [NIOServerCxn.Factory:] - Successfully authenticated client: authenticationID=hbase/hdfs.eaa.local@EAA.LOCAL; authorizationID=hbase/hdfs.eaa.local@EAA.LOCAL.
INFO [NIOServerCxn.Factory:] - Setting authorizedID: hbase
INFO [NIOServerCxn.Factory:] - adding SASL authorization for authorizationID: hbase
INFO [ProcessThread(sid:0 cport:-1)::PrepRequestProcessor@494] - Processed session termination for sessionid: 0x157aef451560218
INFO [NIOServerCxn.Factory:] - Closed socket connection for client / which had sessionid 0x157aef451560218

INFO [NIOServerCxn.Factory:] - Accepted socket connection from /
INFO [NIOServerCxn.Factory:] - Processing ruok command from /
INFO [Thread-1449:NIOServerCnxn@1007] - Closed socket connection for client / (no session established for client)

NB. is the VPN server, which my host machine is using to tunnel into the environment with the Hadoop cluster. is the machine running the cluster,

There are plenty of accepted socket connections which are then immediately closed. Occasionally the client authenticates successfully (so I'm confident in my Kerberos settings) but then there is a session termination immediately afterward.

I've also tried to deploy the Datasource directly in WildFly with
modifications. But I get lots of problems with missing dependencies that I'm not sure how to resolve without creating a new module for each required JAR (and there are a lot) for
. I followed this guide.

What can I do to fix the issue or diagnose further? I've been pulling my hair out for a couple of days now.

Answer Source

You need to add hbase-site.xml and core-site.xml to your classpath.

See How to connect to a Kerberos-secured Apache Phoenix data source with WildFly? for more information.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download