tada / pljava

PL/Java is a free add-on module that brings Java™ Stored Procedures, Triggers, Functions, Aggregates, Operators, Types, etc., to the PostgreSQL™ backend.
http://tada.github.io/pljava/
Other
238 stars 77 forks source link

Not found JDK 11 java.net.http.HttpClient #419

Closed caseylai closed 1 year ago

caseylai commented 1 year ago

I have a simple PL/Java program of using JDK 11 (also tried 17) java.net.http.HttpClient to request another restful service. Successfully compiling by maven and install_jar and set_classpath in PostgreSQL, but when executing the function, an error is thrown for 'java.lang.NoClassDefFoundError: java/net/http/HttpClient'.

Have tried to add java.net.http jmod path to pljava.module_path, but not solve it. Could anyone help?

jcflack commented 1 year ago

I believe (without actually trying it just now) that the solution will be to include --add-modules java.net.http in pljava.vmoptions.

PL/Java does not (yet) treat your code as modular; effectively, it puts your code on the class path, not the module path. That would normally give your code the "unnamed module" behavior where dependencies don't have to be declared.

PL/Java itself, however, is modular, so there is a restricted module graph in effect before your code is loaded, and your code can only use the modules that graph includes. So --add-modules to include the modules you want in the graph should do the trick.

jcflack commented 1 year ago

The existing modules documentation in PL/Java , I see, does not explain this very well. I will add to it.

jcflack commented 1 year ago

Resolved in 1.6.5 by adding documentation for --add-modules.