Transaction functions written in java do not work for datomic:mem protocol when application is run in java 11

Hi, when https://github.com/Datomic/datomic-java-examples is run on java 11 for datomic-free library 0.9.5697 then attempting to execute transaction FN leads to an exception:

Exception in thread "main" java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException
	at datomic.promise$throw_executionexception_if_throwable.invoke(promise.clj:10)
	at datomic.promise$settable_future$reify__6471.deref(promise.clj:54)
	at clojure.core$deref.invoke(core.clj:2206)
	at datomic.promise$settable_future$reify__6471.get(promise.clj:45)

Similar case but for datomic-pro:0.9.5951 leads to:

Caused by: java.util.concurrent.ExecutionException: java.lang.ClassCastException: class org.codehaus.commons.compiler.jdk.ScriptEvaluator cannot be cast to class org.codehaus.commons.compiler.jdk.ClassBodyEvaluator (org.codehaus.commons.compiler.jdk.ScriptEvaluator and org.codehaus.commons.compiler.jdk.ClassBodyEvaluator are in unnamed module of loader 'app')
	at datomic.promise$throw_executionexception_if_throwable.invokeStatic(promise.clj:10)
	at datomic.promise$throw_executionexception_if_throwable.invoke(promise.clj:6)
	at datomic.promise$settable_future$reify__1868.deref(promise.clj:54)
	at clojure.core$deref.invokeStatic(core.clj:2228)
	at clojure.core$deref.invoke(core.clj:2214)
	at datomic.promise$settable_future$reify__1868.get(promise.clj:45)

All the same actions work fine for java11 when protocol datomic:dev is used

2 Likes

Can someone give any thoughts on this issue? Can we expect that not all features are supported by datomic in java 11 environment so far?

Hi nikolayandr,

Can you provide some more information so that we can reproduce this?

  • What program are you running when you encounter these errors?
  • What is the behavior on Java 8?

Thanks,
Stu

Oh sure, sorry for my forget.
Try datomic.samples.Functions#main in java 8 and 11, it is executed successfully for java 8 but there is an error described above for java 11.

To get Caused by: java.util.concurrent.ExecutionException: java.lang.ClassCastException: class org.codehaus.commons.compiler.jdk.ScriptEvaluator cannot be cast to class org.codehaus.commons.compiler.jdk.ClassBodyEvaluator please use datomic-pro instead of datomic-free

Hm, I can’t reproduce issue for java 11 on datomic-pro, please give me some time to determine which exact environment I had when the issues occurred, but still true for datomic-free

Let me explain the app where the issue was firstly met ad summarise what I have so far:

Pre condition: java 11, datomic-on-prem datomic-pro 0.9.5951
We have the app which does similar actions for datomic:dev and datomic:mem dbs. All transactions done for datomic:dev are executed successfully but the same actions fail for datomic:mem. The issue thrown by datomic is: java.lang.ClassCastException: class org.codehaus.commons.compiler.jdk.ScriptEvaluator cannot be cast to class org.codehaus.commons.compiler.jdk.ClassBodyEvaluator

So, having such issue I have decided to reproduce it using datamic-java-examples, but trying java 8 everything was ok, so to have equal envs I have chose to switch to java 11where I got also issue but which is different **Exception in thread “main” java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException
** So I was surprised, but then I realized that datamic-java-examples uses datomic-free library, so after switching to datomic-pro I was surprised again because all is working for datomic-pro. I have question what is wrong, why there is different behaviour for similar envs using similar datomic-pro library for the same test code, the only difference which I see now and can’t explain why the same datomic-pro library uses different commons-compiler-jdk library: datomic-pro in datomic-java-examples downloads commons-compiler-jdk-3.0.12.jar and datomic-pro in my gradle project downloads commons-compiler-jdk-3.1.2.jar.

Ok cool, I know the reason of java.lang.ClassCastException: class org.codehaus.commons.compiler.jdk.ScriptEvaluator cannot be cast to class org.codehaus.commons.compiler.jdk.ClassBodyEvaluator, for some reasons gradle downloads commons-compiler-jdk-3.1.2.jar when datomic-pro:0.9.5951 is configured to use commons-compiler-jdk-3.0.12.jar, so the only open question whether it is possible to run java transactor functions using datomic-free in java 11

For those ones who uses datomic-pro/free with java 11 + lombok(or any other library which enables annotation processor) see on this issue for janino compiler https://github.com/janino-compiler/janino/issues/129