JDBC downgraded to older version but still facing UnsupportedClassVersionError

daniel_adornes Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Dataiku DSS Adv Designer, Registered Posts: 30 ✭✭✭✭✭

This is a solved problem worth sharing with the community and a potential opportunity for evolving DSS.

I had a database driver for jre11 under my DATA_DIR/lib/jdbc/ directory. I was able to successfully deploy an API Service to Kubernetes cluster (thus based on the api-deployer base image), but when querying an enrichment endpoint (which needed to connect to the database) the request failed with an error like this:

java.lang.UnsupportedClassVersionError: com/microsoft/sqlserver/jdbc/SQLServerDriver has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

I tried many things that didn't solve it:

  • Replace the jar file for a jre8 version
  • Downgrade my Design Node's Java version (from 11 to 8), which didn't really make sense, since the error was in the Docker container built from the Docker base image, which in turn basically runs as an isolated new VM in the Kubernetes cluster.
  • Deleted my Docker images (all of them) and rebuilt all of them again, pushing them again to my remote image repository.

Though I did all of these steps described above, when I built my deployment I could still see in the logs the old jar being included (!!!!). Even after rebuilding all the Docker images and redeploying the API Service several times.

What SOLVED the problem:

There was a temporary/cached directory under `DATA_DIR/tmp/api_deployer/name-of-my-deployment/dockerbuildcontext/lib-jdbc/`

I deleted the root folder `DATA_DIR/tmp/api_deployer/name-of-my-deployment` and redeployed my API Service and the jre11 jar file was no more there, FINALLY

My Conclusion

Maybe if a jar file is upgrade under lib/jdbc, the cached/tmp files won't be a problem because the latest version of the jar will prevail in runtime. However, if you are trying to downgrade a jar file (maybe due to an error like `UnsupportedClassVersionError` ) you will need to delete that.

Also, maybe these tmp files should be discarded automatically, when the base images are rebuilt. Somehow, this cached data seems to be useful in some aspects but prone to errors like this.

Best Answer

  • CoreyS
    CoreyS Dataiker Alumni, Dataiku DSS Core Designer, Dataiku DSS Core Concepts, Registered Posts: 1,150 ✭✭✭✭✭✭✭✭✭
    Answer ✓

    Hey @daniel_adornes
    thank you for sharing your observation, solution, and suggestion. We appreciate your desire to share your knowledge with the rest of us!

    If you think it warrants it, I would suggest proposing the potential opportunity to evolve DSS you identify as a Product Idea. Thanks again!


Setup Info
      Help me…