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

java.lang.NoSuchMethodError: 'void org.yaml.snakeyaml.DumperOptions.setIndentWithIndicator(boolean)' #68

Closed
thelipe7 opened this issue Nov 22, 2022 · 3 comments

Comments

@thelipe7
Copy link

I am getting the following error when creating a config:
image

My code:
image

@Carleslc
Copy link
Owner

Carleslc commented Nov 23, 2022

This is not a Simple-YAML bug; it is a known issue related to a dependency clash between Velocity and Simple-YAML.

Velocity uses an older version of snakeyaml (1.26) than this library requires (1.30 or above, latest version uses 1.32). Because of this, there is a dependency clash, so even if the correct version is built with maven into your plugin through Simple-Yaml, in runtime at the moment of loading your plugin the first loaded version prevails, which sadly happens to be the older one loaded by the Velocity server.

See this comment to read a more detailed explanation for the error and the solution, which is relocation to differentiate both versions in runtime using different classpaths.

Example of maven-shade-plugin using relocation to solve the error:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-shade-plugin</artifactId>
  <version>3.4.1</version>
  <executions>
    <execution>
      <goals>
        <goal>shade</goal>
      </goals>
      <configuration>
        <relocations>
          <relocation>
            <pattern>org.yaml.snakeyaml</pattern>
            <shadedPattern>net.servidor.commons.libs.snakeyaml</shadedPattern>
          </relocation>
        </relocations>
      </configuration>
    </execution>
  </executions>
</plugin>

@Carleslc Carleslc changed the title ava.lang.NoSuchMethodError: 'void org.yaml.snakeyaml.DumperOptions.setIndentWithIndicator(boolean)' java.lang.NoSuchMethodError: 'void org.yaml.snakeyaml.DumperOptions.setIndentWithIndicator(boolean)' Nov 25, 2022
@Carleslc
Copy link
Owner

Since 1.8.3 the manual relocation is not needed as it is already included.
Add the relocation in 1.8.2 or update to 1.8.3.
I'm closing the issue. Comment if you have any doubts.

@thelipe7
Copy link
Author

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants