Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

jdbc-tx tests don't work with GraalVM 22.1 #1584

Closed
mhalbritter opened this issue Apr 14, 2022 · 7 comments
Closed

jdbc-tx tests don't work with GraalVM 22.1 #1584

mhalbritter opened this issue Apr 14, 2022 · 7 comments
Assignees
Labels
type: regression A bug that is also a regression
Milestone

Comments

@mhalbritter
Copy link
Contributor

build.sh works, build.sh -t doesn't when running with GraalVM 22.1.

It looks like the initial SQL is executed twice.

@mhalbritter mhalbritter added the type: regression A bug that is also a regression label Apr 14, 2022
@mhalbritter mhalbritter added this to the 0.12.0 milestone Apr 14, 2022
@sdeleuze
Copy link
Contributor

sdeleuze commented Apr 14, 2022

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.

@sdeleuze
Copy link
Contributor

Related invocation to get resources is done here with path = "schema.sql" and cl = jdk.internal.loader.ClassLoaders.AppClassLoader#AppClassLoader.

@sdeleuze
Copy link
Contributor

sdeleuze commented Apr 14, 2022

Blocked by oracle/graal#4493, I have disabled native tests on the CI for now to unlock us.

@sdeleuze sdeleuze added the status: blocked An issue that's blocked on an external project change or another issue label Apr 14, 2022
sdeleuze added a commit to sdeleuze/spring-native that referenced this issue Apr 14, 2022
@mhalbritter mhalbritter self-assigned this Apr 25, 2022
@mhalbritter
Copy link
Contributor Author

mhalbritter commented Apr 25, 2022

From oracle/graal#4493 (comment)

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 by spring-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.

@LilPoppy
Copy link

Same here

@sdeleuze
Copy link
Contributor

This is now tracked by graalvm/native-build-tools#234.

@mhalbritter
Copy link
Contributor Author

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.

@sdeleuze sdeleuze removed the status: blocked An issue that's blocked on an external project change or another issue label Jun 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: regression A bug that is also a regression
Development

No branches or pull requests

3 participants