phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gabriel Reid (JIRA)" <>
Subject [jira] [Commented] (PHOENIX-2032) is broken after PHOENIX-2013
Date Wed, 10 Jun 2015 07:13:00 GMT


Gabriel Reid commented on PHOENIX-2032:

My experience with stuff like this (ServiceLoader API) is that it typically leads to weird
and difficult-to-debug issues like this :-)

I just took a look, and what I can see is that the {{META-INF/services/java.sql.Driver}} file
contains the following:

so the PhoenixDriver will be loaded/attempted last.

What I also noticed when running psql through a debugger is that in {{java.sql.DriverManager#loadInitialDrivers}}
(around line 509 in my JDK) is the following handling while using the ServiceLoader API to
load drivers on the classpath:
  while(driversIterator.hasNext()) {;
} catch(Throwable t) {
  // Do nothing
return null;

What I see happening is that there is an attempt made to load {{org.apache.phoenix.queryserver.client.Driver}}
via {{Class.forName}} in the call to {{}} in that loop, and that throws
and exception (probably a ClassNotFoundException, because I don't think that driver is packaged
in the jar in question). That breaks out of the loop completely, so {{org.apache.phoenix.jdbc.PhoenixDriver}}
never gets loaded via the ServiceLoader API.

I'm guessing the best fix for this (apart from probably fixing that catch-call clause in DriverManager)
is to fix the assembly building for that assembly to only contain a reference to {{org.apache.phoenix.jdbc.PhoenixDriver}}
in {{META-INF/services/java.sql.Driver}}. I guess the other option (actually probably better)
is to ensure that the thin driver is fully included in the jar file being used by psql.

> is broken after PHOENIX-2013
> ------------------------------------
>                 Key: PHOENIX-2032
>                 URL:
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 5.0.0, 4.5.0, 4.4.1
>            Reporter: Sergio Peleato
>            Assignee: Nick Dimiduk
>            Priority: Blocker
>         Attachments: PHOENIX-2032.00.patch
> psql is no longer able to load the phoenix driver after PHOENIX-2013.
> {noformat}
> $ ./bin/ localhost examples/WEB_STAT.sql                                     
> java.sql.SQLException: No suitable driver found for jdbc:phoenix:localhost
>         at java.sql.DriverManager.getConnection(
>         at java.sql.DriverManager.getConnection(
>         at org.apache.phoenix.util.PhoenixRuntime.main(
> {noformat}
> Hat-tip to [] for tracking down the breaking change.

This message was sent by Atlassian JIRA

View raw message