Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New SQLite 3.43.2.0 fails when logging exceptions if the logger framework is SLF4J 1.7 #990

Closed
javiertuya opened this issue Oct 14, 2023 · 13 comments · Fixed by #993
Closed
Labels
released Issue has been released troubleshooting

Comments

@javiertuya
Copy link

Describe the bug
I'm using SLF4J 1.7 and updated to the latest SQLite 3.43.2.0. When opening a connection, a java.lang.NoSuchMethodError exception is produced at org.slf4j.Logger.atTrace()

The possible reason is that SQLite 3.43.2.0 (21c77a4) uses the new SLF4J 2.0 fluent api (e.g. org.slf4j.Logger.atTrace()) that is not available in SLF4J 1.7

To Reproduce
Open a connection using SQLite 3.43.2.0 using SLF4J 1.7 as your logging framework: the exception is raised

Expected behavior
No exception should be raised

Logs
Log trace:

'org.slf4j.spi.LoggingEventBuilder org.slf4j.Logger.atTrace()'
java.lang.NoSuchMethodError: 'org.slf4j.spi.LoggingEventBuilder org.slf4j.Logger.atTrace()'
at org.sqlite.core.NativeDB.prepare(NativeDB.java:129)
at org.sqlite.core.DB.prepare(DB.java:264)
at org.sqlite.jdbc3.JDBC3Statement.lambda$execute$0(JDBC3Statement.java:53)
at org.sqlite.jdbc3.JDBC3Statement.withConnectionTimeout(JDBC3Statement.java:459)
at org.sqlite.jdbc3.JDBC3Statement.execute(JDBC3Statement.java:42)
at org.sqlite.SQLiteConfig.apply(SQLiteConfig.java:219)
at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:70)
at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:28)
at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:19)
at org.sqlite.JDBC.createConnection(JDBC.java:106)
at org.sqlite.JDBC.connect(JDBC.java:79)
at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
at java.sql/java.sql.DriverManager.getConnection(Unknown Source)

Environment (please complete the following information):

  • OS: windows 11 and ubuntu in Github Actions
  • CPU architecture: x86_64
  • sqlite-jdbc version 3.43.2.0
  • slf4j-api version 1.7.36
@pzygielo
Copy link

pzygielo commented Oct 14, 2023

I observe similar using maven + flyway-maven-plugin:

Error:  Failed to execute goal org.flywaydb:flyway-maven-plugin:9.22.3:migrate (migrate-db-before-integration-tests) on project stacey: Execution migrate-db-before-integration-tests of goal org.flywaydb:flyway-maven-plugin:9.22.3:migrate failed: An API incompatibility was encountered while executing org.flywaydb:flyway-maven-plugin:9.22.3:migrate: java.lang.NoSuchMethodError: 'org.slf4j.spi.LoggingEventBuilder org.slf4j.Logger.atTrace()'
Error:  -----------------------------------------------------
Error:  realm =    plugin>org.flywaydb:flyway-maven-plugin:9.22.3
Error:  strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
Error:  urls[0] = file:/home/runner/.m2/repository/org/flywaydb/flyway-maven-plugin/9.22.3/flyway-maven-plugin-9.22.3.jar
Error:  urls[1] = file:/home/runner/.m2/repository/org/flywaydb/flyway-core/9.22.3/flyway-core-9.22.3.jar
Error:  urls[2] = file:/home/runner/.m2/repository/com/google/code/gson/gson/2.10.1/gson-2.10.1.jar
Error:  urls[3] = file:/home/runner/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-toml/2.15.2/jackson-dataformat-toml-2.15.2.jar
Error:  urls[4] = file:/home/runner/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.15.2/jackson-databind-2.15.2.jar
Error:  urls[5] = file:/home/runner/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.15.2/jackson-annotations-2.15.2.jar
Error:  urls[6] = file:/home/runner/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.15.2/jackson-core-2.15.2.jar
Error:  urls[7] = file:/home/runner/.m2/repository/org/apache/commons/commons-text/1.10.0/commons-text-1.10.0.jar
Error:  urls[8] = file:/home/runner/.m2/repository/org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar
Error:  urls[9] = file:/home/runner/work/stacey/stacey/target/classes/
Error:  urls[10] = file:/home/runner/.m2/repository/org/slf4j/slf4j-api/2.0.9/slf4j-api-2.0.9.jar
Error:  urls[11] = file:/home/runner/.m2/repository/org/xerial/sqlite-jdbc/3.43.2.0/sqlite-jdbc-3.43.2.0.jar
Error:  Number of foreign imports: 1
Error:  import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

with

Caused by: java.lang.NoSuchMethodError: 'org.slf4j.spi.LoggingEventBuilder org.slf4j.Logger.atTrace()'
    at org.sqlite.core.NativeDB.prepare (NativeDB.java:129)
    at org.sqlite.core.DB.prepare (DB.java:264)
    at org.sqlite.jdbc3.JDBC3Statement.lambda$execute$0 (JDBC3Statement.java:53)
    at org.sqlite.jdbc3.JDBC3Statement.withConnectionTimeout (JDBC3Statement.java:459)
    at org.sqlite.jdbc3.JDBC3Statement.execute (JDBC3Statement.java:42)
    at org.sqlite.SQLiteConfig.apply (SQLiteConfig.java:219)
    at org.sqlite.SQLiteConnection.<init> (SQLiteConnection.java:70)
    at org.sqlite.jdbc3.JDBC3Connection.<init> (JDBC3Connection.java:28)
    at org.sqlite.jdbc4.JDBC4Connection.<init> (JDBC4Connection.java:19)
    at org.sqlite.JDBC.createConnection (JDBC.java:106)
    at org.sqlite.JDBC.connect (JDBC.java:79)

Just guessing - classworlds lists slf4j-api v2 but I suppose it's too late as maven (3.8, 3.9) itself uses slf4j v1.7 and Logger is (probably) already loaded and configured at this moment.

In my case the actual logger is of org.slf4j.impl.MavenSimpleLogger class then.

@gotson
Copy link
Collaborator

gotson commented Oct 14, 2023

You need slf4j 2

@javiertuya
Copy link
Author

@gotson It is a little more complicated. For instance, I have 4 applications using slf4j 1.7 that had a regression due to this issue. Until now, I had a 50% success rate in making them work:

  • A library application, successfully migrated to slf4j 2.0
  • A Spring Boot server that can't be migrated to slf4j 2.0. Fortunately, the server does not use sqlite, the failures appeared in an single integration test module that I migrated to slf4j 2.0
  • A second Spring Boot server that can't be migrated to slf4j 2.0 and I have not found any workaround until now
  • A java application that was ALREADY using slf4j 2.0, but after the sqlite update, some JBehave tests fail. Surprisingly, they pass when running in Eclipse, but fail when running from maven in a GitHub Action (this is in line with what @pzygielo guessed)

@gotson
Copy link
Collaborator

gotson commented Oct 16, 2023

It seems to me that those are dependency problems in your project / builds.

@vietk
Copy link
Contributor

vietk commented Oct 16, 2023

Hello,
Same here, the dependency on SLF4J 2.0 introduced here is breaking our application and we have not yet migrated out of 1.7.x
The problem is logging dependencies should be treated with care because it's widely used in all projects/applications.

Looking at the PR it seems the contribution is making use of the new SLF4J fluent API which is supposed to bring some performance improvements, despite there are no benchmarks associated to it.
SLF4J fluent API usage has its equivalent to the traditional log.error|info|trace|() method, so I think except, if this project has a real motivation of using the fluent API, it should revert to the traditional log interface.
If need be I can try to do a PR on this repo
WDYT ?

@javiertuya
Copy link
Author

I completely agree with the two latest comments, it is a clear dependency problem that @vietk explain very well. The point is that here, a change in a patch version is forcing an update to the major version of other components (e.g. I guess that if I update Spring Boot from v2.7 to 3.1 the problem will disappear, but this will also require an update to Java 17).

@gotson
Copy link
Collaborator

gotson commented Oct 16, 2023

version is forcing an update to the major version of other components

That would only be relevant if the project was using semVer, which is not the case.

@ninniuz
Copy link

ninniuz commented Oct 16, 2023

This is preventing us from using v3.43.2.0 in a Gradle Plugin because of this limitation in Gradle

gotson added a commit that referenced this issue Oct 18, 2023
Closes: #990
Co-authored-by: Gauthier Roebroeck <[email protected]>
@gotson
Copy link
Collaborator

gotson commented Oct 18, 2023

3.43.2.1-SNAPSHOT has been published, please give it a try and report whether it is working better. Once i get sufficient reports that it works fine, i will publish the new version.

@ninniuz
Copy link

ninniuz commented Oct 18, 2023

@gotson I confirm 3.43.2.1-SNAPSHOT solves the issue on my side.

@javiertuya
Copy link
Author

@gotson I confirm that this snapshot solves my issues. Thanks @vietk for the fix

@gotson gotson added the released Issue has been released label Oct 19, 2023
@gotson
Copy link
Collaborator

gotson commented Oct 19, 2023

🎉 This issue has been resolved in 3.43.2.1 (Release Notes)

@vietk
Copy link
Contributor

vietk commented Oct 19, 2023

Build fixed on my side too, thanks @gotson for the reactivity

Marthym added a commit to Marthym/baywatch that referenced this issue Dec 2, 2023
Marthym added a commit to Marthym/baywatch that referenced this issue Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Issue has been released troubleshooting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants