3

java.lang.NoSuchMethodError: org.yaml.snakeyaml.constructor.SafeConstructor: method ()V not found at io.swagger.v3.parser.util.DeserializationUtils$CustomSnakeYamlConstructor.(DeserializationUtils.java:397) at io.swagger.v3.parser.util.DeserializationUtils.readYamlTree(DeserializationUtils.java:209) at io.swagger.v3.parser.util.DeserializationUtils.deserializeIntoTree(DeserializationUtils.java:145) at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:168) at io.swagger.v3.parser.OpenAPIV3Parser.readLocation(OpenAPIV3Parser.java:97) at io.swagger.parser.OpenAPIParser.readLocation(OpenAPIParser.java:16) at com.atlassian.oai.validator.util.OpenApiLoader.readSwaggerParserResult(OpenApiLoader.java:79) at com.atlassian.oai.validator.util.OpenApiLoader.loadApi(OpenApiLoader.java:48) at com.atlassian.oai.validator.OpenApiInteractionValidator$Builder.build(OpenApiInteractionValidator.java:643)

This is coming after updating the version of snakeyaml from 1.3 to 2.0

Dmytro Mitin
  • 48,194
  • 3
  • 28
  • 66
sahil arya
  • 31
  • 1
  • 2
  • https://stackoverflow.com/questions/75880410/java-lang-nosuchmethoderror-org-apache-hadoop-hive-common-fileutils-mkdir-while https://stackoverflow.com/questions/35186/how-do-i-fix-a-nosuchmethoderror – Dmytro Mitin Apr 06 '23 at 10:09
  • 1
    Please provide reproduction: build files (`build.sbt`, `pom.xml` etc.), what code causes the error. [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) – Dmytro Mitin Apr 06 '23 at 10:11
  • What is snakeyaml 1.3? Mvnrepository knows 1.4-1.33, 2.0 https://mvnrepository.com/artifact/org.yaml/snakeyaml Did you mean snakeyaml 1.33 (1.3x)? – Dmytro Mitin Apr 06 '23 at 10:16
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Apr 06 '23 at 16:22

2 Answers2

1

Indeed, snakeyaml 2.0 doesn't have empty-arg constructor for the class org.yaml.snakeyaml.constructor.SafeConstructor.

In snakeyaml 1.33 such constructor existed but was deprecated.

In snakeyaml 2.0 try to replace

import org.yaml.snakeyaml.{LoaderOptions, Yaml}
import org.yaml.snakeyaml.constructor.SafeConstructor

val safeConstructor = new SafeConstructor
val yaml = new Yaml(safeConstructor)  

with

val loaderOptions = new LoaderOptions
// loaderOptions.setCodePointLimit(...)
// ...
val safeConstructor = new SafeConstructor(loaderOptions)
val yaml = new Yaml(safeConstructor)

https://bitbucket.org/snakeyaml/snakeyaml/wiki/Documentation#markdown-header-loading-yaml

https://bitbucket.org/snakeyaml/snakeyaml/src/master/src/test/java/examples/SafeConstructorExampleTest.java

Dmytro Mitin
  • 48,194
  • 3
  • 28
  • 66
0

For me it was "uap-java" lib that didn't support "snakeyaml 2.0". Upgrading to latest version (from 1.5.2 to 1.5.4 so far) solved the problem.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 03 '23 at 22:46