SLF4J crashes jenkins

Hi, I have a project that has several spring boot starter dependencies (v3.4.5) (they in turn have slf4j v1.7.36 as a dependency.) Now i tried to make a jenkins pipeline (with a sonarqube server stage). But the
sonar-maven-plugin:3.9.1.2184
sonar-maven-plugin:3.9.1.2184
fails because an
.atInfo()
.atInfo()
method does not exist (which afaik was added in 2.0 of slf4j) I'm aware of being able to exclude the slf4j v1.7.36 from the spring starter dependencies and explicitly naming the e.g. v2.0.17, but I'd like to know if that is safe (couldnt find any direct answer online) And I'm not sure how extensive testing would need to be to ensure it's safe. TL:DR: is it safe to exclude the slf4j v1.7.36 from spring boot starter dependencies and explicitly add v2.X.X to prevent
sonar-maven-plugin:3.9.1.2184
sonar-maven-plugin:3.9.1.2184
from crashing the jenkins pipeline? thanks in advance 🙂
48 Replies
JavaBot
JavaBot2d ago
This post has been reserved for your question.
Hey @SterniXPutzig! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
dan1st
dan1st2d ago
you can alos use <dependencyManagement> but I think it isn't about dependencies at all but mybe about plugin dependencies Can you show the exact error message/sack trace?
SterniXPutzig
SterniXPutzigOP2d ago
1sec gotta check if any problematic info is in it
13:17:38 [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on Project [<Project name>]: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar: java.lang.NoSuchMethodError: 'org.slf4j.spi.LoggingEventBuilder org.slf4j.Logger.atInfo()'
13:17:38 [ERROR] -----------------------------------------------------
13:17:38 [ERROR] realm = plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184
13:17:38 [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
13:17:38 [ERROR] urls[0] = [<file>]/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.9.1.2184/sonar-maven-plugin-3.9.1.2184.jar
13:17:38 [ERROR] urls[1] = [<file>]/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
13:17:38 [ERROR] urls[2] = [<file>]/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
13:17:38 [ERROR] urls[3] = [<file>]/.m2/repository/org/codehaus/plexus/plexus-utils/3.2.1/plexus-utils-3.2.1.jar
13:17:38 [ERROR] urls[4] = [<file>]/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.16.2.588/sonar-scanner-api-2.16.2.588.jar
13:17:38 [ERROR] urls[5] = [<file>]/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
13:17:38 [ERROR] Number of foreign imports: 1
13:17:38 [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
13:17:38 [ERROR]
13:17:38 [ERROR] -----------------------------------------------------
13:17:38 [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on Project [<Project name>]: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar: java.lang.NoSuchMethodError: 'org.slf4j.spi.LoggingEventBuilder org.slf4j.Logger.atInfo()'
13:17:38 [ERROR] -----------------------------------------------------
13:17:38 [ERROR] realm = plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184
13:17:38 [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
13:17:38 [ERROR] urls[0] = [<file>]/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.9.1.2184/sonar-maven-plugin-3.9.1.2184.jar
13:17:38 [ERROR] urls[1] = [<file>]/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
13:17:38 [ERROR] urls[2] = [<file>]/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
13:17:38 [ERROR] urls[3] = [<file>]/.m2/repository/org/codehaus/plexus/plexus-utils/3.2.1/plexus-utils-3.2.1.jar
13:17:38 [ERROR] urls[4] = [<file>]/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.16.2.588/sonar-scanner-api-2.16.2.588.jar
13:17:38 [ERROR] urls[5] = [<file>]/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
13:17:38 [ERROR] Number of foreign imports: 1
13:17:38 [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
13:17:38 [ERROR]
13:17:38 [ERROR] -----------------------------------------------------
All replaced info is in [<info>] tags (help info removed due to 2000 char limit of discord) was about PluginContainerException
dan1st
dan1st2d ago
Can you show the pom.xml?
SterniXPutzig
SterniXPutzigOP2d ago
anything specific im looking for?
dan1st
dan1st2d ago
dependencies of your project and the declaration of the plugin and also parents ideally run mvn help:effective-pom and check that especially the <plugin> element of sonar is interesting
SterniXPutzig
SterniXPutzigOP2d ago
versions:
<sonar-maven-plugin.version>3.9.1.2184</sonar-maven-plugin.version>
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.language>java</sonar.language>
<sonar-maven-plugin.version>3.9.1.2184</sonar-maven-plugin.version>
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.language>java</sonar.language>
plugin:
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.9.1.2184</version>
<executions>
<execution>
<phase>none</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.9.1.2184</version>
<executions>
<execution>
<phase>none</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>
dan1st
dan1st2d ago
Is that from the effective pom?
SterniXPutzig
SterniXPutzigOP2d ago
yes
dan1st
dan1st2d ago
Can you add the following block inside the <plugin> for sonar scanner?
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.0</version>
</dependencies>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.0</version>
</dependencies>
SterniXPutzig
SterniXPutzigOP2d ago
wouldnt that collide with the 1.7.36 version for the spring starters?
dan1st
dan1st2d ago
this plugin here would be used for the sonar scanner and not for Spring And are you really using a Spring version with SLF4J 1.7? I thought it was the other direction The latest Spring Boot version (3.4.5) using SLF4J 2.0.17
SterniXPutzig
SterniXPutzigOP2d ago
dependency analysis in the the intellij maven window shows 1.7.36 for spring boot 3.4.5
SterniXPutzig
SterniXPutzigOP2d ago
seems like it, will check (might take a while, parent pom is pretty big) thanks so far already
JavaBot
JavaBot2d ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
dan1st
dan1st2d ago
You can also check the effective pom the <dependency> there is the source of truth or you can use mvn dependency:list to get a list of all used dependencies and mvn dependency:tree to get a tree showing what is dependent on what
SterniXPutzig
SterniXPutzigOP2d ago
you are right something hardcodes everything containing slf4j to 1.7.36 but it's not us
dan1st
dan1st2d ago
you can in principle overwrite it Do you have an slf4j.version in your <properties>?
SterniXPutzig
SterniXPutzigOP2d ago
sorry, which properties?
dan1st
dan1st2d ago
the <properties> block in the pom or mvn help:effective-pom
SterniXPutzig
SterniXPutzigOP2d ago
nope, the version is directly in the dependencies themselves
dan1st
dan1st2d ago
Can you check the effective pom? That should have a <properties> with an slf4j.version
SterniXPutzig
SterniXPutzigOP2d ago
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>
they all look like this no property tag
dan1st
dan1st2d ago
It isn't in the <dependencies> section If you are using Spring Boot with the <parent>, the effective POM has a <properties> section
SterniXPutzig
SterniXPutzigOP2d ago
i checked every property tag by hand and also searched for "slf4j.version" but nothing
dan1st
dan1st2d ago
Do you have a <parent> in your main pom.xml?
SterniXPutzig
SterniXPutzigOP2d ago
no
dan1st
dan1st2d ago
And you are saying you are using Spring Boot? Do you have any spring-boot-dependencies dependency?
SterniXPutzig
SterniXPutzigOP2d ago
spring boot itself + ~70 more
dan1st
dan1st2d ago
Is there anything named spring-boot-dependencies? with the -dependencies Can you show the output of mvn dependency:tree? Do you have an explicit SLF4J dependency in your pom.xml?
SterniXPutzig
SterniXPutzigOP2d ago
i have no explicit slf4j yet, but I wanted to add that. I just wanted to make sure it's safe
dan1st
dan1st2d ago
depends on what you mean with safe there is the possibility that it doesn't se the dependency you declared and ofc some conflicts are possible but if it goes wrong, you should notice
SterniXPutzig
SterniXPutzigOP2d ago
i think i got it. i overriden one of the spring boot version in the parent with another value prepared also in the parent, it was using some old helper spring boots in the background
dan1st
dan1st2d ago
? So you are using a parent? Can you just send the pom.xml?
SterniXPutzig
SterniXPutzigOP2d ago
i have my project , that has a central parent pom, that offers 2 diffrent spring boot version one is 2.X.X and one 3.X.X and as far as i can see the 2.X.X was used for any non explicit dependency in the background because that let to the 1.7.36 version of slf4j And any dependency analysis / tree/ whatever now shows correctly a v2.X.X slf4j
dan1st
dan1st2d ago
ok so does your central parent POM have a parent? Does the central parent POM use spring-boot-dependencies?
SterniXPutzig
SterniXPutzigOP2d ago
so overriding the spring boot 2 property with the V3 seems to have fixed it no the central pom is the head
dan1st
dan1st2d ago
that seems like it could be a bit dangerous depending on how you are doing that How did you overwrite it?
SterniXPutzig
SterniXPutzigOP2d ago
any project in connection with mine is V3 itself and it is generally intended to use V3 in the first place
dan1st
dan1st2d ago
yes but switching between Spring Boot 2 and 3 with a property sounds like it could result in conflicts from having stuff from both
SterniXPutzig
SterniXPutzigOP2d ago
<spring-boot-2.version> overriden with <spring-boot-3.version> names are diffrent but yeah
dan1st
dan1st2d ago
Is that a custom property from your central pom?
SterniXPutzig
SterniXPutzigOP2d ago
yes custom
dan1st
dan1st2d ago
Well ig the person setting it up knew what they did
SterniXPutzig
SterniXPutzigOP2d ago
yes, everyone uses it and i was just too dump 😄 Thank you very much for your time and effort ❤️
JavaBot
JavaBot2d ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
JavaBot
JavaBot2d ago
Post Closed
This post has been closed by <@378591387341291520>.

Did you find this page helpful?