0

I'm connecting to 2 different DB, and their JDBC client both requires the package org.apache.calcite.avatica, one is using version 1.6, and another is using version 1.8, so I need to install both the versions (1.6 and 1.8), and seems that the version 1.8 is not compatible with version 1.6, when I'm using the version 1.8 instead of 1.6, the following exception was thrown:

java.lang.AbstractMethodError
    org.apache.calcite.avatica.AvaticaConnection.<init>(AvaticaConnection.java:117)
    org.apache.kylin.jdbc.KylinConnection.<init>(KylinConnection.java:51)
    org.apache.kylin.jdbc.KylinJdbcFactory.newConnection(KylinJdbcFactory.java:77)
    org.apache.calcite.avatica.UnregisteredDriver.connect(UnregisteredDriver.java:143)
    org.apache.kylin.client.method.KylinJdbcMethod.getJdbcConnection(KylinJdbcMethod.java:45)
    org.apache.kylin.client.Kylin.getJdbcConnection(Kylin.java:175)

And it seems that Maven is not designed to use like that.

So, what should I do to solve this problem?

luochen1990
  • 3,689
  • 1
  • 22
  • 37

2 Answers2

1

You can't. This isn't an issue with Maven, it's an issue with the standard Java classloading infrastructure.

Theoretically, you could use something like OSGi, which partitions off classloaders and permits multiple imports of classes with the same fully-qualified name, but that adds substantial complication.

I would make certain that the 1.8 library can't communicate with 1.6 (database drivers are usually backward-compatible), and if it can't, then reorganize your project to have an adaptation service. It seems that you may have misunderstood what Calcite is, since it itself is an adaptation layer, not a storage service, and you may simply need to update whatever queries were written in 1.6 to 1.8.

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152
  • But the problem is, the calcite requirement is not required directly by myself, but by two different db's jdbc client, and I can't change the code inside the jdbc client... – luochen1990 Jul 15 '16 at 04:54
0

I can't explain how to make Avatica 1.6 and 1.8 work alongside each other in maven. It looks as it we broke backwards compatibility in Avatica in either CALCITE-836 or CALCITE-1213, and on behalf of the Apache Calcite Avatica development team, I apologize.

I logged KYLIN-1898 to upgrade the version of Avatica that Kylin uses.

Julian Hyde
  • 1,239
  • 7
  • 10