Skip to Content
0

Is ngdbc 2.3.33 compatible with JVM 8?

Apr 25 at 08:51 PM

216

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Rich Jones
May 02 at 12:16 PM
0

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.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Rich, thank you very much for the explanation.

Can you please share a link on how to run on 2.2.x? We are running on 2.0.6 right now.

0
Eik Sunke Apr 25 at 09:25 PM
1

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks for this hint. Disabling the runtime will help as well.

0
Lars Breddemann
Apr 26 at 02:48 AM
0

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?

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hi Lars,

I am note sure, how somebody achieved to put classes depending on Java 9 into a Java7-jar, but obviously it is possible ;)

Please find a demo project in https://github.com/pleusmann-conet/ngdbc-compat-test .

Cheers,

Philipp

0

Hi Lars Breddemann , can you reproduce the error using the demo project?

0

I didn't have time to look into this so far.

0