Closed mhalbritter closed 2 years ago
With mvn clean test -P native
.
22.0
2022-04-14 15:05:43.100 DEBUG 37095 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from URL [resource:schema.sql]
2022-04-14 15:05:43.100 DEBUG 37095 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : 0 returned as update count for SQL: CREATE TABLE FOOS ( id INTEGER IDENTITY PRIMARY KEY, value VARCHAR(30) )
2022-04-14 15:05:43.100 DEBUG 37095 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executed SQL script from URL [resource:schema.sql] in 0 ms.
22.1
2022-04-14 15:03:52.677 DEBUG 36232 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from URL [resource:/schema.sql]
2022-04-14 15:03:52.677 DEBUG 36232 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : 0 returned as update count for SQL: CREATE TABLE FOOS ( id INTEGER IDENTITY PRIMARY KEY, value VARCHAR(30) )
2022-04-14 15:03:52.677 DEBUG 36232 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executed SQL script from URL [resource:/schema.sql] in 0 ms.
2022-04-14 15:03:52.677 DEBUG 36232 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from URL [resource:/schema.sql#1]
2022-04-14 15:03:52.678 WARN 36232 --- [ main] w.s.c.ServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'runner': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceScriptDatabaseInitializer': Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [resource:/schema.sql#1]: CREATE TABLE FOOS ( id INTEGER IDENTITY PRIMARY KEY, value VARCHAR(30) ); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: (Message 42S01 not found); SQL statement:
CREATE TABLE FOOS ( id INTEGER IDENTITY PRIMARY KEY, value VARCHAR(30) ) [42101-200]
2 scripts seems to be detected with 22.1 unlike 22.0.
Related invocation to get resources is done here with path = "schema.sql"
and cl = jdk.internal.loader.ClassLoaders.AppClassLoader#AppClassLoader
.
Blocked by https://github.com/oracle/graal/issues/4493, I have disabled native tests on the CI for now to unlock us.
From https://github.com/oracle/graal/issues/4493#issuecomment-1108464235
Hi @sdeleuze
From native-image perspective, the observed behavior is correct.
Looking into
spring-native/samples/jdbc-tx
you find./src/main/resources/schema.sql ./target/classes/schema.sql
By adding
--verbose
to the native-image command you can see that the image build above specifies the following classpath entries:.../spring-native/samples/jdbc-tx/src/main/resources .../spring-native/samples/jdbc-tx/target/classes
Thus
schema.sql
is visible twice from different places and since pattern"pattern": "schema.sql"
that is given byspring-aot/resource-config.json
matches in both cases we have to add them both.To fix the issue I suggest to make sure that
.../spring-native/samples/jdbc-tx/src/main/resources
is not part of the image classpath.
Looks like our classpath is botched.
This is now tracked by https://github.com/graalvm/native-build-tools/issues/234.
I've tested it with native-build-tools builds generated from their master
branch, and it works now. This change is contained in the upcoming 0.9.12 version.
build.sh
works,build.sh -t
doesn't when running with GraalVM 22.1.It looks like the initial SQL is executed twice.