'java.lang.NoSuchMethodError' with jackson-core:2.14.1 when I upgraded to snakeyaml:2.0

754 views
Skip to first unread message

Akhil Ranjan

unread,
Feb 28, 2023, 11:18:11 PM2/28/23
to jackson-user

I use jackson-core:2.14.1 in my application, and I tried upgrading to newly released snakeyaml:2.0, to get rid of vulnerabilities in the earlier snakeyaml version.

I started getting the following runtime Exception with the jackson-core:2.14.1 + snakeyaml:2.0 combination :-

EXCEPTION=org.yaml.snakeyaml.parser.ParserImpl.<init>(Lorg/yaml/snakeyaml/reader/StreamReader;)V

java.lang.NoSuchMethodError: org.yaml.snakeyaml.parser.ParserImpl.<init>(Lorg/yaml/snakeyaml/reader/StreamReader;)V

at com.fasterxml.jackson.dataformat.yaml.YAMLParser.<init>(YAMLParser.java:191)

at com.fasterxml.jackson.dataformat.yaml.YAMLFactory._createParser(YAMLFactory.java:509)

at com.fasterxml.jackson.dataformat.yaml.YAMLFactory.createParser(YAMLFactory.java:413)

at com.fasterxml.jackson.dataformat.yaml.YAMLFactory.createParser(YAMLFactory.java:386)

at com.fasterxml.jackson.dataformat.yaml.YAMLFactory.createParser(YAMLFactory.java:15)

at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3677)

at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3645)


I then upgraded to jackson-core:2.14.2, and the above error was resolved. The latest jackson-core version worked with snakeyaml:2.0.

I'm curious above the changes in the jackson-core v2.14.2, that makes it compatible with the new snakeyaml artifact. Release notes for v2.14.2 states the following changes 
:-

2.14.2 (28-Jan-2023) #854: Backport schubfach changes from v2.15#8 (contributed by @pjfanning) #882: Allow TokenFIlter to skip last elements in arrays (contributed by Przemyslaw G) #886: Avoid instance creations in fast parser code (contributed by @pjfanning) #890: `FilteringGeneratorDelegate` does not create new `filterContext` if `tokenFilter` is null (contributed by @DemonicTutor)
Request inputs on why jackson-core:2.14.2 works with snakeyaml:2.0, but jackson-core:2.14.1 doesn't.

Tatu Saloranta

unread,
Feb 28, 2023, 11:23:35 PM2/28/23
to jackso...@googlegroups.com
As the stack trace shows, constructor of "ParserImpl":

org.yaml.snakeyaml.parser.ParserImpl.<init>(Lorg/yaml/snakeyaml/reader/StreamReader;)V

which version of YAML module 2.14.1 used was removed by SnakeYAML
version 2.0 -- 1.x -> 2.x is a major version upgrade and as such not
(guaranteed to be) backwards compatible.

Also note that the version incompatibility is not with `jackson-core`
but rather with `jackson-dataformat-yaml`.
You probably upgraded versions of both components.

Release notes for YAML module have the fix listed:

#370: (yaml) Replace use of deprecated constructor of SnakeYAML ParserImpl
(see https://github.com/FasterXML/jackson-dataformats-text/issues/370 )

Hope this helps,

-+ Tatu +-

Akhil Ranjan

unread,
Mar 1, 2023, 5:58:00 AM3/1/23
to jackson-user
Hi Tatu,

Yes, this clarifies my doubt over why v2.14.1 didn't work, but the v2.14.2 did with the new snakeyaml version. Thanks so much.

fann...@yahoo.com

unread,
Mar 3, 2023, 2:26:11 PM3/3/23
to jackson-user
Reply all
Reply to author
Forward
0 new messages