Skip to Content

Is ngdbc 2.3.33 compatible with JVM 8?

After our recent upgrade to HANA Express 2.0 SP03 out Spring Boot based modules are not able to start anymore.

This is due to a java.lang.ClassNotFoundException: java.sql.ConnectionBuilder. The Exception is thrown during creation of the DataSource Bean by Spring:

Failed to introspect bean class [com.sap.db.jdbcext.DataSourceSAP] for persistence metadata: could not find class that it depends on
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:401) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:333) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:992) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:523) ~[spring-beans-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
... 37 common frames omitted
Caused by: java.lang.NoClassDefFoundError: java/sql/ConnectionBuilder
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_162]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2724) ~[na:1.8.0_162]
at java.lang.Class.getDeclaredMethods(Class.java:1998) ~[na:1.8.0_162]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613) ~[spring-core-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:489) ~[spring-core-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.buildPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:431) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:397) ~[spring-orm-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
... 40 common frames omitted

The root cause of the Exception is that com.sap.db.jdbcext.DataSourceSAP.DataSourceSAP in ngdbc 2.3.33, used by SP03, is implementing JDBC 4.3 API (for example com.sap.db.jdbcext.DataSourceSAP.createConnectionBuilder() or com.sap.db.jdbc.ConnectionSapDB.setShardingKey(ShardingKey)). This API was introduced in Java 9!

Since we are running on JRE 8, standard of SP03, this obviously will not work!

Is there any solution available to fix this issue?

As a workaround one option would be to deliver an older ngdbc version inside our fat-jar and to convince the buildpack not to override this by adding a newer driver version, which is the default right now. Can anybody hint on how to do this?

@SAP: Please provide a fully jre8-compatible ngdbc.jar!

Best regards,

Philipp

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    May 02 at 12:16 PM

    There is a general problem with Java reflection when you compile a library--ngdbc.jar in this case--with one version of the JDK but run under an older version. This issue is not new to HANA JDBC 2.3.x (which is built with JDK 9 but targets JDK 7 and later). You would encounter a similar problem using the 2.2.x driver (which is built with JDK 8 but targets JDK 6 and later) under JVM 6 or 7 if you happened to make a specific reflection call. The problem is so commonplace for libraries and frameworks that attempt to support multiple JDK versions that a new "Multi-Release JAR file" feature was introduced in JDK 9 to resolve these types of issues. See http://openjdk.java.net/jeps/238 for details.

    HANA JDBC 2.3.44 and later contain a fix for this problem; the driver is now built as a multi-release JAR. A fix will appear in HANA 2 SPS 03 Rev 31. Unfortunately there is no workaround (other than running under JDK 9) until then.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Rich,

      I have a question in regards to the shipment of the new JDBC driver. Currently there is HANA 2 SP 3 Revision 33 out there. However, the latest XSA runtime (1.0.88) still contains the 2.3.33 driver.
      Please let us know when the driver will find its way into the XSA installation.

      Thanks,
      Eik

  • Apr 25 at 09:25 PM

    Hi Philipp,
    maybe more a workaround then a real solution to the issue, you can delete the runtime using the xs cli (xs delete-runtime)

    λ xs runtimes
    Getting runtimes...
    type version id resolved active description bound apps
    -------------------------------------------------------------------------------------------------------------
    ...
    hanajdbc2 0.6 7 true true SAP HANA JDBC Driver 2.0.6 31
    hanajdbc2 3.33 9 true true SAP HANA JDBC Driver 2.3.33 14
    ...

    λ xs delete-runtime -i 9
    Really delete runtime 9 (hanajdbc2 3.33)? (y/n) > y
    Deleted runtime "hanajdbc2" version 3.33.

    λ xs runtimes
    Getting runtimes...
    type version id resolved active description bound apps
    -------------------------------------------------------------------------------------------------------------
    ...
    hanajdbc2 0.6 7 true true SAP HANA JDBC Driver 2.0.6 32
    ...

    However, this just uses the older jdbc driver. The issue with the new driver is stell there.
    Maybe someone from SAP can give some insights...

    Cheers,Eik

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 26 at 02:48 AM

    I cannot reproduce this behavior with the available information.

    Checking the current JDBC driver with JAVA 1.8 gets me this:

    C:\Program Files\SAP\hdbclient>java -version
    java version "1.8.0_171"
    Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
    Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
    
    java -jar ngdbc.jar VERSION
    package com.sap.db.jdbc, Java Platform API Specification, version 1.7, SAP HANA JDBC Driver, SAP SE, 2.3.38-e41f3a2c36e40a8bf8e2308cd77ccdb8b9bb8c13

    Can you provide a minimal reproducible example to create the error?

    Add comment
    10|10000 characters needed characters exceeded