Im my project we are using spring boot 2.6.6 version. When I run the below test class separately I am getting below error.
java.lang.NoSuchMethodError: 'void org.yaml.snakeyaml.LoaderOptions.setMaxAliasesForCollections(int)'
If the class runs as part of mvn install its executing without any issues.
@SpringBootTest(webEnvironment = RANDOM_PORT, classes = TestApplication.class)
@ContextConfiguration(classes = {WireMockConfig.class})
class ToastNotificationControllerIT {
@LocalServerPort
private int port;
@BeforeEach
void setUp() throws IOException {
}
@Test
void test() {
}
}
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.boot.env.OriginTrackedYamlLoader.createYaml(OriginTrackedYamlLoader.java:69)
The following method did not exist:
'void org.yaml.snakeyaml.LoaderOptions.setMaxAliasesForCollections(int)'
The calling method's class, org.springframework.boot.env.OriginTrackedYamlLoader, was loaded from the following location:
jar:file:/C:/dev/.m2/repository/org/springframework/boot/spring-boot/2.6.6/spring-boot-2.6.6.jar!/org/springframework/boot/env/OriginTrackedYamlLoader.class
The called method's class, org.yaml.snakeyaml.LoaderOptions, is available from the following locations:
jar:file:/C:/dev/.m2/repository/org/yaml/snakeyaml/1.23/snakeyaml-1.23-android.jar!/org/yaml/snakeyaml/LoaderOptions.class
jar:file:/C:/dev/.m2/repository/org/yaml/snakeyaml/1.29/snakeyaml-1.29.jar!/org/yaml/snakeyaml/LoaderOptions.class
The called method's class hierarchy was loaded from the following locations:
org.yaml.snakeyaml.LoaderOptions: file:/C:/dev/.m2/repository/org/yaml/snakeyaml/1.23/snakeyaml-1.23-android.jar
I tried exculde the org.yaml dependency from spring boot starter dependency. But the issue is still not resolved.
My Dependency Tree:
[INFO] com.selva.test:test-api:jar:1.0.6
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.6.6:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.6.6:compile
[INFO] | | +- org.springframework.boot:spring-boot:jar:2.6.6:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.6.6:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.6.6:compile
[INFO] | | | \- org.apache.logging.log4j:log4j-to-slf4j:jar:2.17.2:compile
[INFO] | | | \- org.apache.logging.log4j:log4j-api:jar:2.17.2:compile
[INFO] | | +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.29:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.6.6:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.13.2:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.2:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.13.2:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.6.6:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.60:compile
[INFO] | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.60:compile
[INFO] | +- org.springframework:spring-web:jar:5.3.18:compile
[INFO] | | \- org.springframework:spring-beans:jar:5.3.18:compile
[INFO] | \- org.springframework:spring-webmvc:jar:5.3.18:compile
[INFO] | \- org.springframework:spring-expression:jar:5.3.18:compile
[INFO] +- org.springframework.boot:spring-boot-starter-validation:jar:2.6.6:compile
[INFO] | +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.60:compile
[INFO] | \- org.hibernate.validator:hibernate-validator:jar:6.2.3.Final:compile
[INFO] | +- jakarta.validation:jakarta.validation-api:jar:2.0.2:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.4.3.Final:compile
[INFO] | \- com.fasterxml:classmate:jar:1.5.1:compile
[INFO] +- org.springframework.cloud:spring-cloud-starter-openfeign:jar:3.1.1:compile
[INFO] | +- org.springframework.cloud:spring-cloud-starter:jar:3.1.1:compile
[INFO] | | +- org.springframework.cloud:spring-cloud-context:jar:3.1.1:compile
[INFO] | | \- org.springframework.security:spring-security-rsa:jar:1.0.10.RELEASE:compile
[INFO] | | \- org.bouncycastle:bcpkix-jdk15on:jar:1.68:compile
[INFO] | | \- org.bouncycastle:bcprov-jdk15on:jar:1.68:compile
[INFO] | +- org.springframework.cloud:spring-cloud-openfeign-core:jar:3.1.1:compile
[INFO] | | \- io.github.openfeign.form:feign-form-spring:jar:3.8.0:compile
[INFO] | | \- io.github.openfeign.form:feign-form:jar:3.8.0:compile
[INFO] | +- org.springframework.cloud:spring-cloud-commons:jar:3.1.1:compile
[INFO] | | \- org.springframework.security:spring-security-crypto:jar:5.6.2:compile
[INFO] | +- io.github.openfeign:feign-core:jar:11.8:compile
[INFO] | \- io.github.openfeign:feign-slf4j:jar:11.8:compile
[INFO] +- io.github.openfeign:feign-httpclient:jar:11.8:compile
[INFO] | \- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.4.15:compile
[INFO] | \- commons-codec:commons-codec:jar:1.15:compile
[INFO] +- org.projectlombok:lombok:jar:1.18.22:compile (optional)
[INFO] +- org.mapstruct:mapstruct:jar:1.4.2.Final:compile
INFO] | +- commons-beanutils:commons-beanutils:jar:1.9.4:compile
[INFO] | | +- commons-logging:commons-logging:jar:1.2:compile
[INFO] | | \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] | +- io.opentracing.contrib:opentracing-spring-web-starter:jar:4.1.0:compile
[INFO] | | +- io.opentracing.contrib:opentracing-spring-web:jar:4.1.0:compile
[INFO] | | | \- io.opentracing.contrib:opentracing-web-servlet-filter:jar:0.4.0:compile
[INFO] | | +- io.opentracing.contrib:opentracing-tracerresolver:jar:0.1.8:compile
[INFO] | | \- io.opentracing.contrib:opentracing-spring-tracer-configuration-starter:jar:0.3.1:compile
[INFO] | | \- io.opentracing:opentracing-noop:jar:0.33.0:compile
[INFO] | +- javax.servlet:javax.servlet-api:jar:4.0.1:compile
[INFO] | +- org.aspectj:aspectjweaver:jar:1.9.7:compile
[INFO] | \- org.springframework.boot:spring-boot-starter-aop:jar:2.6.6:compile
[INFO] +- org.springdoc:springdoc-openapi-ui:jar:1.5.11:compile
[INFO] | +- org.springdoc:springdoc-openapi-webmvc-core:jar:1.5.11:compile
[INFO] | | \- org.springdoc:springdoc-openapi-common:jar:1.5.11:compile
[INFO] | | +- io.swagger.core.v3:swagger-models:jar:2.1.11:compile
[INFO] | | +- io.swagger.core.v3:swagger-annotations:jar:2.1.11:compile
[INFO] | | +- io.swagger.core.v3:swagger-integration:jar:2.1.11:compile
[INFO] | | | \- io.swagger.core.v3:swagger-core:jar:2.1.11:compile
[INFO] | | | \- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.13.2:compile
[INFO] | | \- io.github.classgraph:classgraph:jar:4.8.69:compile
[INFO] | +- org.webjars:swagger-ui:jar:3.52.3:compile
[INFO] | \- org.webjars:webjars-locator-core:jar:0.48:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.6.6:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:2.6.6:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.6.6:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.6.0:compile
[INFO] | | \- net.minidev:json-smart:jar:2.4.8:compile
[INFO] | | \- net.minidev:accessors-smart:jar:2.4.8:compile
[INFO] | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile
[INFO] | | \- jakarta.activation:jakarta.activation-api:jar:1.2.2:compile
[INFO] | +- org.assertj:assertj-core:jar:3.21.0:test
[INFO] | +- org.hamcrest:hamcrest:jar:2.2:test
[INFO] | +- org.junit.jupiter:junit-jupiter:jar:5.8.2:test
[INFO] | | +- org.junit.jupiter:junit-jupiter-params:jar:5.8.2:test
[INFO] | | \- org.junit.jupiter:junit-jupiter-engine:jar:5.8.2:test
[INFO] | | \- org.junit.platform:junit-platform-engine:jar:1.8.2:test
[INFO] | +- org.mockito:mockito-core:jar:4.0.0:test
[INFO] | | +- net.bytebuddy:byte-buddy:jar:1.11.22:test
[INFO] | | +- net.bytebuddy:byte-buddy-agent:jar:1.11.22:test
[INFO] | | \- org.objenesis:objenesis:jar:3.2:test
[INFO] | +- org.mockito:mockito-junit-jupiter:jar:4.0.0:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] | +- org.springframework:spring-core:jar:5.3.18:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.3.18:compile
[INFO] | +- org.springframework:spring-test:jar:5.3.18:test
[INFO] | \- org.xmlunit:xmlunit-core:jar:2.8.4:compile
[INFO] +- com.github.javafaker:javafaker:jar:1.0.2:test
[INFO] | +- org.apache.commons:commons-lang3:jar:3.12.0:compile
[INFO] | +- org.yaml:snakeyaml:jar:android:1.23:test
[INFO] | \- com.github.mifmif:generex:jar:1.0.2:test
[INFO] | \- dk.brics.automaton:automaton:jar:1.11-8:test
[INFO] +- com.github.tomakehurst:wiremock:jar:2.27.2:compile
[INFO] | +- org.eclipse.jetty:jetty-server:jar:9.4.45.v20220203:compile
[INFO] | | +- org.eclipse.jetty:jetty-http:jar:9.4.45.v20220203:compile
[INFO] | | \- org.eclipse.jetty:jetty-io:jar:9.4.45.v20220203:compile
[INFO] | +- org.eclipse.jetty:jetty-servlet:jar:9.4.45.v20220203:compile
[INFO] | | +- org.eclipse.jetty:jetty-security:jar:9.4.45.v20220203:compile
[INFO] | | \- org.eclipse.jetty:jetty-util-ajax:jar:9.4.45.v20220203:compile
[INFO] | +- org.eclipse.jetty:jetty-servlets:jar:9.4.45.v20220203:compile
[INFO] | | +- org.eclipse.jetty:jetty-continuation:jar:9.4.45.v20220203:compile
[INFO] | | \- org.eclipse.jetty:jetty-util:jar:9.4.45.v20220203:compile
[INFO] | +- org.eclipse.jetty:jetty-webapp:jar:9.4.45.v20220203:compile
[INFO] | | \- org.eclipse.jetty:jetty-xml:jar:9.4.45.v20220203:compile
[INFO] | +- org.eclipse.jetty:jetty-proxy:jar:9.4.45.v20220203:compile
[INFO] | | \- org.eclipse.jetty:jetty-client:jar:9.4.45.v20220203:compile
[INFO] | +- com.google.guava:guava:jar:20.0:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.13.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.13.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.13.2.2:compile
[INFO] | +- org.xmlunit:xmlunit-legacy:jar:2.8.4:compile
[INFO] | +- org.xmlunit:xmlunit-placeholders:jar:2.8.4:compile
[INFO] | +- org.ow2.asm:asm:jar:7.0:compile
[INFO] | +- net.sf.jopt-simple:jopt-simple:jar:5.0.3:compile
[INFO] | +- com.github.jknack:handlebars:jar:4.0.7:compile
[INFO] | | \- org.antlr:antlr4-runtime:jar:4.7.1:compile
[INFO] | +- com.github.jknack:handlebars-helpers:jar:4.0.7:compile
[INFO] | +- com.flipkart.zjsonpatch:zjsonpatch:jar:0.4.4:compile
[INFO] | \- commons-fileupload:commons-fileupload:jar:1.4:compile
[INFO] | \- commons-io:commons-io:jar:2.2:compile
[INFO] +- au.com.dius.pact.consumer:junit5:jar:4.2.12:test
[INFO] | +- au.com.dius.pact:consumer:jar:4.2.12:test
[INFO] | | +- au.com.dius.pact.core:model:jar:4.2.12:test
[INFO] | | | +- au.com.dius.pact.core:support:jar:4.2.12:test
[INFO] | | | | +- org.antlr:antlr4:jar:4.9.2:test
[INFO] | | | | | +- org.antlr:antlr-runtime:jar:3.5.2:test
[INFO] | | | | | +- org.antlr:ST4:jar:4.3:test
[INFO] | | | | | +- org.abego.treelayout:org.abego.treelayout.core:jar:1.0.3:test
[INFO] | | | | | +- org.glassfish:javax.json:jar:1.0.4:test
[INFO] | | | | | \- com.ibm.icu:icu4j:jar:61.1:test
[INFO] | | | | +- io.github.microutils:kotlin-logging-jvm:jar:2.0.10:test
[INFO] | | | | +- com.michael-bull.kotlin-result:kotlin-result-jvm:jar:1.1.12:test
[INFO] | | | | \- com.google.code.findbugs:jsr305:jar:3.0.2:test
[INFO] | | | +- au.com.dius.pact.core:pactbroker:jar:4.2.12:test
[INFO] | | | +- org.apache.commons:commons-collections4:jar:4.4:test
[INFO] | | | +- javax.mail:mail:jar:1.5.0-b01:test
[INFO] | | | | \- javax.activation:activation:jar:1.1:test
[INFO] | | | +- org.apache.tika:tika-core:jar:1.27:test
[INFO] | | | \- io.ktor:ktor-http-jvm:jar:1.3.1:test
[INFO] | | | +- org.jetbrains.kotlinx:atomicfu:jar:0.14.1:test
[INFO] | | | +- org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:1.5.2:test
[INFO] | | | +- org.jetbrains.kotlinx:kotlinx-coroutines-core-common:jar:1.3.3:test
[INFO] | | | \- io.ktor:ktor-utils-jvm:jar:1.3.1:test
[INFO] | | | \- io.ktor:ktor-io-jvm:jar:1.3.1:test
[INFO] | | +- au.com.dius.pact.core:matchers:jar:4.2.12:test
[INFO] | | | +- xerces:xercesImpl:jar:2.12.0:test
[INFO] | | | | \- xml-apis:xml-apis:jar:1.4.01:test
[INFO] | | | +- org.atteo:evo-inflector:jar:1.2.2:test
[INFO] | | | \- com.github.ajalt:mordant:jar:1.2.1:test
[INFO] | | | \- com.github.ajalt:colormath:jar:1.2.0:test
[INFO] | | +- com.googlecode.java-diff-utils:diffutils:jar:1.3.0:test
[INFO] | | +- org.json:json:jar:20160212:test
[INFO] | | +- io.netty:netty-handler:jar:4.1.75.Final:test
[INFO] | | | +- io.netty:netty-common:jar:4.1.75.Final:test
[INFO] | | | +- io.netty:netty-resolver:jar:4.1.75.Final:test
[INFO] | | | +- io.netty:netty-buffer:jar:4.1.75.Final:test
[INFO] | | | +- io.netty:netty-transport:jar:4.1.75.Final:test
[INFO] | | | \- io.netty:netty-codec:jar:4.1.75.Final:test
[INFO] | | +- org.apache.httpcomponents:httpmime:jar:4.5.13:test
[INFO] | | +- org.apache.httpcomponents:fluent-hc:jar:4.5.13:test
[INFO] | | +- io.ktor:ktor-server-netty:jar:1.4.1:test
[INFO] | | | +- org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.6.10:test
[INFO] | | | +- org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.6.10:test
[INFO] | | | +- org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:jar:1.5.2:test
[INFO] | | | | \- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:jar:1.5.2:test
[INFO] | | | +- io.ktor:ktor-server-host-common:jar:1.4.1:test
[INFO] | | | | +- io.ktor:ktor-server-core:jar:1.4.1:test
[INFO] | | | | | \- com.typesafe:config:jar:1.3.1:test
[INFO] | | | | \- io.ktor:ktor-http-cio-jvm:jar:1.4.1:test
[INFO] | | | +- io.netty:netty-codec-http2:jar:4.1.75.Final:test
[INFO] | | | | \- io.netty:netty-codec-http:jar:4.1.75.Final:test
[INFO] | | | +- org.eclipse.jetty.alpn:alpn-api:jar:1.1.3.v20160715:test
[INFO] | | | +- io.netty:netty-transport-native-kqueue:jar:4.1.75.Final:test
[INFO] | | | | +- io.netty:netty-transport-native-unix-common:jar:4.1.75.Final:test
[INFO] | | | | \- io.netty:netty-transport-classes-kqueue:jar:4.1.75.Final:test
[INFO] | | | \- io.netty:netty-transport-native-epoll:jar:4.1.75.Final:test
[INFO] | | | \- io.netty:netty-transport-classes-epoll:jar:4.1.75.Final:test
[INFO] | | \- io.ktor:ktor-network-tls-certificates:jar:1.4.1:test
[INFO] | | \- io.ktor:ktor-network-tls-jvm:jar:1.4.1:test
[INFO] | | \- io.ktor:ktor-network-jvm:jar:1.4.1:test
[INFO] | +- org.jetbrains.kotlin:kotlin-stdlib:jar:1.6.10:test
[INFO] | | +- org.jetbrains:annotations:jar:13.0:test
[INFO] | | \- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.6.10:test
[INFO] | +- org.jetbrains.kotlin:kotlin-reflect:jar:1.6.10:test
[INFO] | \- org.junit.jupiter:junit-jupiter-api:jar:5.8.2:test
[INFO] | +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] | +- org.junit.platform:junit-platform-commons:jar:1.8.2:test
[INFO] | \- org.apiguardian:apiguardian-api:jar:1.1.2:test
Can Anyone help me to resolve this issue.
Any help will be greatly appreciated !!!
Issue resolved when adding snakeyaml latest dependency in pom and removed the old one in m2 folder and exclude snakeyaml from javafaker dependency.