Re: [h2] H2DB breaks GraalVM native image production

2022-01-10 Thread Evgenij Ryazanov
Hello!

I think you need to force inclusion of org.h2.store.fs.disk.* classes into 
compiled program somehow, H2 loads them dynamically through reflection and 
NPE here mean they weren't found.

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/2088769e-47bb-49db-a2fd-53749604ef4dn%40googlegroups.com.


Re: [h2] H2DB breaks GraalVM native image production

2022-01-07 Thread Behrang
Hi Noel,

Adding that dependency solved that problem, but the program still breaks at 
runtime, this time with another error.

I have uploaded some sample code 
here: https://github.com/behrangsa/xyz-fs/tree/feature/graal

When I run the program with plain old Java, it runs fine and creates an 
empty database at ~/Crash.

When I run it through native-image, the executable crashes with:

org.h2.jdbc.JdbcSQLNonTransientException: (Message HY000 not found) 
[5-204]
at 
org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:340)
at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:117)
at org.h2.Driver.connect(Driver.java:59)
at java.sql.DriverManager.getConnection(DriverManager.java:681)
at java.sql.DriverManager.getConnection(DriverManager.java:252)
at xyz.behrang.fs.Main.main(Main.java:10)
Caused by: java.lang.NullPointerException
at org.h2.store.fs.FilePath.get(FilePath.java:87)
at org.h2.store.fs.FileUtils.isAbsolute(FileUtils.java:139)
at org.h2.engine.ConnectionInfo.getName(ConnectionInfo.java:457)
at org.h2.engine.Engine.openSession(Engine.java:49)
at org.h2.engine.Engine.openSession(Engine.java:222)
at org.h2.engine.Engine.createSession(Engine.java:201)
at 
org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)

I run this program under Linux. Under another OS it may work. But looks 
like native image doesn't like something about the way FilePath class is 
written.

On Wednesday, January 5, 2022 at 11:02:30 PM UTC+11 Noel Grandin wrote:

> You're missing the the JTS geometry classes
>
> Caused by: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError: 
> com.oracle.graal.pointsto.constraints.UnresolvedElementException: 
> Discovered unresolved type during parsing: 
> org.locationtech.jts.geom.Geometry. 
> To diagnose the issue you can use the --allow-incomplete-classpath option. 
> The missing type is then reported at run time when it is accessed the first 
> time.
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/318c581a-5965-4dfb-a69f-3c9fab887e8dn%40googlegroups.com.


Re: [h2] H2DB breaks GraalVM native image production

2022-01-05 Thread Noel Grandin
You're missing the the JTS geometry classes

Caused by: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError:
com.oracle.graal.pointsto.constraints.UnresolvedElementException:
Discovered unresolved type during parsing: org.locationtech.jts.geom.Geometry.
To diagnose the issue you can use the --allow-incomplete-classpath option.
The missing type is then reported at run time when it is accessed the first
time.

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/CAFYHVnV73jadeeMvF4UnKCLWLnjLQeUeMLQ5ooCCjdos5fKeoQ%40mail.gmail.com.


[h2] H2DB breaks GraalVM native image production

2022-01-05 Thread Behrang
Hi,

I am working on a small project where I use h2db as an embedded database. I 
want to compile this project using graalvm and use the produced binary.

However the dependency breaks the build. Are there any workarounds 
available?

*Sample build log:*

$ mvn -Pnative clean package
[INFO] Scanning for projects...
[INFO] 
[INFO] -< xyz.behrang:xyz-fs 
>-
[INFO] Building xyz-fs 1.0-SNAPSHOT
[INFO] [ jar 
]-
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ xyz-fs ---
[INFO] Deleting 
/home/behrangsa/Documents/Projects/github.com/behrangsa/xyz-fs/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ 
xyz-fs ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered 
resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ xyz-fs ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, 
i.e. build is platform dependent!
[INFO] Compiling 4 source files to 
/home/behrangsa/Documents/Projects/github.com/behrangsa/xyz-fs/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) 
@ xyz-fs ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered 
resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory 
/home/behrangsa/Documents/Projects/github.com/behrangsa/xyz-fs/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ 
xyz-fs ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ xyz-fs ---
[INFO] No tests to run.
[INFO] 
[INFO] --- native-maven-plugin:0.9.9:test (test-native) @ xyz-fs ---
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ xyz-fs ---
[INFO] Building jar: 
/home/behrangsa/Documents/Projects/github.com/behrangsa/xyz-fs/target/xyz-fs-1.0-SNAPSHOT.jar
[INFO] 
[INFO] --- native-maven-plugin:0.9.9:build (build-native) @ xyz-fs ---
[INFO] ImageClasspath Entry: com.h2database:h2:jar:2.0.204:compile 
(file:///home/behrangsa/.m2/repository/com/h2database/h2/2.0.204/h2-2.0.204.jar)
[INFO] ImageClasspath Entry: commons-codec:commons-codec:jar:1.15:compile 
(file:///home/behrangsa/.m2/repository/commons-codec/commons-codec/1.15/commons-codec-1.15.jar)
[INFO] ImageClasspath Entry: commons-io:commons-io:jar:2.11.0:compile 
(file:///home/behrangsa/.m2/repository/commons-io/commons-io/2.11.0/commons-io-2.11.0.jar)
[INFO] ImageClasspath Entry: xyz.behrang:xyz-fs:jar:1.0-SNAPSHOT 
(file:///home/behrangsa/Documents/Projects/github.com/behrangsa/xyz-fs/target/xyz-fs-1.0-SNAPSHOT.jar)
[INFO] Executing: 
/home/behrangsa/.sdkman/candidates/java/current/bin/native-image -cp 
/home/behrangsa/.m2/repository/com/h2database/h2/2.0.204/h2-2.0.204.jar:/home/behrangsa/.m2/repository/commons-codec/commons-codec/1.15/commons-codec-1.15.jar:/home/behrangsa/.m2/repository/commons-io/commons-io/2.11.0/commons-io-2.11.0.jar:/home/behrangsa/Documents/Projects/github.com/behrangsa/xyz-fs/target/xyz-fs-1.0-SNAPSHOT.jar
 
-H:Class=xyz.behrang.fs.Main -H:Name=findex
[findex:56102]classlist: 614.69 ms,  0.96 GB
[findex:56102](cap): 377.03 ms,  0.96 GB
[findex:56102]setup:   1,329.99 ms,  0.96 GB
[findex:56102] analysis:   3,875.41 ms,  2.31 GB
Fatal error:com.oracle.graal.pointsto.util.AnalysisError$ParsingError: 
Error encountered while parsing 
org.h2.value.ValueToObjectConverter.valueToObject(java.lang.Class, 
org.h2.value.Value, org.h2.jdbc.JdbcConnection) 
Parsing context:
   at 
org.h2.value.ValueToObjectConverter.valueToObject(ValueToObjectConverter.java:281)
   at org.h2.schema.FunctionAlias$JavaMethod.execute(FunctionAlias.java:474)
   at 
org.h2.schema.FunctionAlias$JavaMethod.getValue(FunctionAlias.java:345)
   at org.h2.expression.function.JavaFunction.getValue(JavaFunction.java:40)
   at org.h2.command.dml.Call.update(Call.java:52)
   at org.h2.command.CommandList.executeRemaining(CommandList.java:49)
   at org.h2.command.CommandList.update(CommandList.java:66)
   at org.h2.command.Command.executeUpdate(Command.java:252)
   at org.h2.engine.Engine.openSession(Engine.java:258)
   at org.h2.engine.Engine.createSession(Engine.java:201)
   at 
org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)
   at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:117)
   at org.h2.Driver.connect(Driver.java:59)
   at java.sql.DriverManager.getConnection(DriverManager.java:681)
   at java.sql.DriverManager.getConnection(DriverManager.java:252)
   at xyz.behrang.fs.commands.Init.run(Init.java:35)
   at xyz.behrang.fs.Main.main(Main.java:28)
   at com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:147)
   at