The error you're encountering — that the class Event for SnakeYAML cannot be found — typically occurs when there's a version incompatibility or missing dependency involving SnakeYAML in your project.
You mentioned using Fasterxml Jackson 2.18.2, which is quite recent, and this version has removed internal dependencies on SnakeYAML due to licensing changes (SnakeYAML transitioned from Apache 2.0 to a restrictive license starting with version 1.30).
Let’s break down what’s likely happening and how to fix it:
🔍 Root Cause
- Starting with Jackson 2.16, support for SnakeYAML was removed from Jackson's
jackson-dataformat-yaml module.
- If your code or another library you're using relies on
jackson-dataformat-yaml, and it's trying to use classes like org.yaml.snakeyaml.event.Event, it may fail if:
- You are using an old version of SnakeYAML (before removal).
- Or you are using Jackson 2.16+ but still referencing YAML-related functionality that requires SnakeYAML.
✅ Solution Options
✅ Option 1: Downgrade Jackson to 2.15.x (if you need SnakeYAML)
If you depend on YAML parsing via Jackson and don't want to change code yet, you can downgrade Jackson to version 2.15.3, which includes built-in SnakeYAML support:
<!-- Maven -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.3</version>
</dependency>
⚠️ Note: This is not recommended long-term due to potential security fixes in newer versions.
✅ Option 2: Use SnakeYAML directly (if you need YAML parsing)
If your project needs YAML parsing and you're okay using SnakeYAML directly (not through Jackson), you can add it explicitly:
<!-- Maven -->
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.33</version> <!-- Or latest compatible version -->
</dependency>
Then, update your code to use org.yaml.snakeyaml.Yaml instead of Jackson’s YAML module.
✅ Option 3: Migrate to Jackson YAML plugin (recommended for future-proofing)
Jackson now recommends replacing the old SnakeYAML-based jackson-dataformat-yaml with its successor:
👉 Jackson YAML Plugin
It uses Jackson core abstractions, not SnakeYAML.
To use it:
<!-- Maven -->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.18.2</version>
</dependency>
This replaces the older YAML support without relying on SnakeYAML.
Make sure your code doesn’t reference any SnakeYAML-specific classes like Event.
🛠 How to Fix Your Specific Error
If the error is something like:
java.lang.NoClassDefFoundError: org/yaml/snakeyaml/event/Event
That means some part of your application or a dependency is expecting SnakeYAML to be present.
So:
-
Check your direct or transitive dependencies:
Run:
mvn dependency:tree
or
gradle dependencies
-
Add missing SnakeYAML (if needed temporarily):
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.33</version>
</dependency>
-
Or refactor code to avoid SnakeYAML entirely by using Jackson’s new YAML plugin or another format/parser.
🧪 Summary
| Scenario | Action |
|---|
| Using Jackson ≥ 2.16 and need YAML support | Use jackson-dataformat-yaml (new plugin) |
| Need SnakeYAML for existing code | Add it explicitly (org.yaml:snakeyaml) |
| Want to keep using Jackson YAML with SnakeYAML | Downgrade Jackson to ≤ 2.15.3 |
📌 Final Tip
Avoid mixing old Jackson YAML support (based on SnakeYAML) with newer Jackson versions. It leads to class loading issues like the one you're seeing.
Let me know if you'd like help checking your dependencies or refactoring code!