Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Babashka compiled with JDBC and POSTGRESQL feature flags fails due to missing field ALLOW_ENCODING_CHANGES #1046

Closed
neuromantik33 opened this issue Nov 1, 2021 · 0 comments · Fixed by #1056

Comments

@neuromantik33
Copy link

version
Tested with tags v0.6.3, v0.6.4 and master branch.

platform
Linux drnick-xps-15-9500 5.11.0-38-generic #42~20.04.1-Ubuntu SMP Tue Sep 28 20:41:07 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

problem
When trying to build babashka with the feature flags BABASHKA_FEATURE_JDBC and BABASHKA_FEATURE_POSTGRESQL everything seems to compile fine. However starting at tag v0.6.3 (Works on v0.6.0 and before, tags in between are broken but fixed thanks to #1040), there seems to be a graal issue with org.postgresql.PGProperty). Here is a my REPL session:

$ bb --version
babashka v0.6.3
$ bb
Babashka v0.6.3 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (require '[next.jdbc :as jdbc])
nil
user=> (def ds (jdbc/get-datasource {:dbtype "postgres" :dbname "intra_prod" :host "localhost" :port 5432 :connectTimeout 60000 :queryTimeout 3600000}))
#'user/ds
user=> ds
#object[next.jdbc.connection$url_PLUS_etc$reify__12314 0x2316a296 "jdbc:postgresql://localhost:5432/intra_prod"]
user=> (try
  (def conn (jdbc/get-connection ds {:user "<redacted>" :password "<redacted>"}))
  (catch Throwable t t))
#error {
 :cause "ALLOW_ENCODING_CHANGES"
 :via
 [{:type java.lang.ExceptionInInitializerError
   :message nil
   :at [com.oracle.svm.core.classinitialization.ClassInitializationInfo initialize "ClassInitializationInfo.java" 315]}
  {:type java.lang.RuntimeException
   :message "java.lang.NoSuchFieldException: ALLOW_ENCODING_CHANGES"
   :at [org.postgresql.PGProperty <init> "PGProperty.java" 712]}
  {:type java.lang.NoSuchFieldException
   :message "ALLOW_ENCODING_CHANGES"
   :at [java.lang.Class getField "DynamicHub.java" 1109]}]
 :trace
 [[java.lang.Class getField "DynamicHub.java" 1109]
  [org.postgresql.PGProperty <init> "PGProperty.java" 710]
  [org.postgresql.PGProperty <init> "PGProperty.java" 699]
  [org.postgresql.PGProperty <init> "PGProperty.java" 695]
  [org.postgresql.PGProperty <clinit> "PGProperty.java" 33]
  [com.oracle.svm.core.classinitialization.ClassInitializationInfo invokeClassInitializer "ClassInitializationInfo.java" 375]
  [com.oracle.svm.core.classinitialization.ClassInitializationInfo initialize "ClassInitializationInfo.java" 295]
  [org.postgresql.Driver loadDefaultProperties "Driver.java" 110]
  [org.postgresql.Driver access$000 "Driver.java" 62]
  [org.postgresql.Driver$1 run "Driver.java" 96]
  [org.postgresql.Driver$1 run "Driver.java" 94]
  [java.security.AccessController doPrivileged "AccessController.java" 123]
  [org.postgresql.Driver getDefaultProperties "Driver.java" 94]
  [org.postgresql.Driver connect "Driver.java" 223]
  [java.sql.DriverManager getConnection "DriverManager.java" 677]
  [java.sql.DriverManager getConnection "DriverManager.java" 189]
  [next.jdbc.connection$get_driver_connection invokeStatic "connection.clj" 141]
  [next.jdbc.connection$url_PLUS_etc$reify__12314 getConnection "connection.clj" 357]
  [next.jdbc.connection$make_connection invokeStatic "connection.clj" 382]
  [next.jdbc.connection$fn__12327 invokeStatic "connection.clj" 406]
  [next.jdbc.connection$fn__12327 invoke "connection.clj" 406]
  [next.jdbc.protocols$fn__12130$G__12125__12137 invoke "protocols.clj" 24]
  [next.jdbc$get_connection invokeStatic "jdbc.clj" 158]
  [next.jdbc$get_connection invoke "jdbc.clj" 134]
  [sci.impl.vars.SciVar invoke "vars.cljc" 325]
  [sci.impl.analyzer$return_call$fn__2945 invoke "analyzer.cljc" 1036]
  [sci.impl.evaluator$eval invokeStatic "evaluator.cljc" 334]
  [sci.impl.evaluator$eval invoke "evaluator.cljc" 328]
  [sci.impl.evaluator$eval_def invokeStatic "evaluator.cljc" 102]
  [sci.impl.analyzer$expand_def$fn__2619 invoke "analyzer.cljc" 432]
  [sci.impl.evaluator$eval invokeStatic "evaluator.cljc" 334]
  [sci.impl.evaluator$eval invoke "evaluator.cljc" 328]
  [sci.impl.evaluator$eval_try invokeStatic "evaluator.cljc" 150]
  [sci.impl.analyzer$analyze_try$fn__2687 invoke "analyzer.cljc" 618]
  [sci.impl.evaluator$eval invokeStatic "evaluator.cljc" 334]
  [sci.impl.interpreter$eval_form invokeStatic "interpreter.cljc" 44]
  [babashka.impl.repl$repl$fn__32887 invoke "repl.clj" 74]
  [babashka.impl.clojure.main$repl$read_eval_print__18030 invoke "main.clj" 103]
  [babashka.impl.clojure.main$repl$fn__18035 invoke "main.clj" 124]
  [babashka.impl.clojure.main$repl invokeStatic "main.clj" 124]
  [babashka.impl.repl$repl invokeStatic "repl.clj" 86]
  [babashka.impl.repl$start_repl_BANG_ invokeStatic "repl.clj" 88]
  [babashka.impl.repl$start_repl_BANG_ invoke "repl.clj" 88]
  [babashka.impl.repl$start_repl_BANG_ invokeStatic "repl.clj" 89]
  [babashka.main$exec invokeStatic "main.clj" 805]
  [babashka.main$main invokeStatic "main.clj" 897]
  [babashka.main$main doInvoke "main.clj" 884]
  [clojure.lang.RestFn invoke "RestFn.java" 397]
  [clojure.lang.AFn applyToHelper "AFn.java" 152]
  [clojure.lang.RestFn applyTo "RestFn.java" 132]
  [clojure.core$apply invokeStatic "core.clj" 667]
  [babashka.main$_main invokeStatic "main.clj" 931]
  [babashka.main$_main doInvoke "main.clj" 923]
  [clojure.lang.RestFn invoke "RestFn.java" 397]
  [clojure.lang.AFn applyToHelper "AFn.java" 152]
  [clojure.lang.RestFn applyTo "RestFn.java" 132]
  [babashka.main main nil -1]]}

repro

export GRAALVM_VERSION="21.2.0"
export GRAALVM_HOME=./graalvm-ce-java11-${GRAALVM_VERSION}
export BABASHKA_FEATURE_JDBC=true
export BABASHKA_FEATURE_POSTGRESQL=true

git clone --recursive https://github.com/babashka/babashka bb
cd bb

curl -sLO https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${GRAALVM_VERSION}/graalvm-ce-java11-linux-amd64-${GRAALVM_VERSION}.tar.gz
tar -xzf graalvm-ce-java11-linux-amd64-${GRAALVM_VERSION}.tar.gz

script/uberjar
script/compile

# Attempt to connect to a postgresql instance

expected behavior
No exception when connecting (works with v0.6.0)

$ bb --version
babashka v0.6.0
$ bb
Babashka v0.6.3 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (require '[next.jdbc :as jdbc])
nil
user=> (def ds (jdbc/get-datasource {:dbtype "postgres" :dbname "intra_prod" :host "localhost" :port 5432 :connectTimeout 60000 :queryTimeout 3600000}))
#'user/ds
user=> ds
#object[next.jdbc.connection$url_PLUS_etc$reify__12314 0x2316a296 "jdbc:postgresql://localhost:5432/intra_prod"]
user=> (try
  (def conn (jdbc/get-connection ds {:user "<redacted>" :password "<redacted>"}))
  (catch Throwable t t))
#'user/conn
user=> conn
#object[org.postgresql.jdbc.PgConnection 0x6614ea76 "org.postgresql.jdbc.PgConnection@6614ea76"]
user=>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant