Quick revision
The short answer
NoSuchMethodError means our code was compiled against a version of JsonFactory that has this createParser method, but the class found at run time comes from a different, usually older, jackson-core that lacks it. Either two jackson-core versions are reachable or the build resolved an older one through a transitive dependency. We find out why with mvn dependency:tree -Dverbose or gradle dependencyInsight, confirm which jar was loaded with -verbose:class or getCodeSource(), and fix it by aligning versions with a BOM and enforcing convergence in the build.
What to remember
In this answer, we saw that NoSuchMethodError means the class at run time comes from a different version than the one we compiled against, here an older jackson-core chosen through a transitive dependency or a second copy on the class path. mvn dependency:tree -Dverbose and gradle dependencyInsight show which version won and why, getCodeSource and -verbose:class show which jar the JVM really used, and a BOM such as Spring Boot's dependency management or jackson-bom, enforced with dependencyConvergence, fixes and prevents it.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
NoSuchMethodError means our code was compiled against a version of JsonFactory that has this createParser method, but the class found at run time comes from a different, usually older, jackson-core that lacks it. Either two jackson-core versions are reachable or the build resolved an older one through a transitive dependency. We find out why with mvn dependency:tree -Dverbose or gradle dependencyInsight, confirm which jar was loaded with -verbose:class or getCodeSource(), and fix it by aligning versions with a BOM and enforcing convergence in the build.
Why this question is asked
This is the most common failure after a dependency upgrade, and it confuses people because everything compiled. The compiler checked our code against one jar, and the JVM ran it against another. Interviewers ask it because the fix is easy once we know where to look, and because the prevention is a build discipline every team needs. In this answer, we will recap what the error means, see how the mismatch arises, find the cause with the build tools, confirm it at run time, and fix and prevent it.
1A Quick Recap: What NoSuchMethodError Means
When javac compiles a call such as factory.createParser(input), it records in our class file a symbolic reference: the class com.fasterxml.jackson.core.JsonFactory, the method name createParser, and its exact parameter and return types. At run time, the first time that call executes, the JVM resolves the reference against whatever JsonFactory class was actually loaded. If that class has no method with that exact name and descriptor, the JVM throws NoSuchMethodError, a LinkageError.
The message in the question even shows the descriptor the JVM looked for, including the return type JsonParser. So the error is never about our code being wrong; it is about the class at run time being a different version from the one at compile time.
2How the Mismatch Arises
With Maven or Gradle, we rarely declare jackson-core ourselves. It arrives transitively, through jackson-databind, through Spring Boot's starters, through an SDK or a client library. Each of those declares the version it was built with, and the build tool picks one version for the whole application. Maven picks the nearest declaration in the dependency tree, and on a tie the first one declared; Gradle picks the highest requested version unless told otherwise.
6 messages in order. Play them, or step through them one at a time.
Maven resolves one version per artifact; the winner depends on tree position, not on which is newer.
So after the upgrade, our code and the new jackson-databind were compiled against jackson-core 2.17, but an older SDK higher in the tree declares jackson-core 2.13 directly, and Maven's nearest-wins rule picks 2.13. The second way is two copies on the class path, for example a fat jar of some tool that bundles its own unshaded copy of jackson-core, where the first one on the class path wins.
3Finding the Cause in the Build
The build tool can tell us which version won and why.
The verbose Maven tree shows the losing request with omitted for conflict, which names both versions and the path to each. For Gradle, dependencyInsight explains why a version was selected. If the build shows only one version but the error persists, the second copy is coming from somewhere the build does not manage, such as a fat jar, a shaded jar, or the server's own lib directory.
4Confirming Which Jar Loaded the Class
At run time, we can ask the JVM directly where the class came from.
Notice that getCodeSource names the exact jar, which settles arguments about what is deployed. Jackson also publishes a PackageVersion class with its version. The -verbose:class output is useful when we cannot change code, and works for any library.
5Fixing It and Keeping It Fixed
The fix is to make every module agree on one version. In a Spring Boot project, Boot's dependency management already pins Jackson to a tested version, and the simplest fix is often to remove explicit version overrides and let it apply. Elsewhere we import jackson-bom, a bill of materials that pins all Jackson modules to the same version together.
The Maven Enforcer plugin's dependencyConvergence rule fails the build whenever two paths request different versions of the same artifact, so the next conflict is found at build time instead of in production. Gradle's equivalent is failOnVersionConflict() in the resolution strategy, or platforms and version catalogs. If the conflicting copy is inside a fat jar we cannot change, we exclude that dependency or ask its maintainers to shade with relocated packages. One more caution for the near future: Spring Boot 4 moves to Jackson 3, whose packages begin with tools.jackson rather than com.fasterxml.jackson, so mixing the two produces different errors, such as missing classes; check your version.
6Follow-up questions
Why did it compile if the method is missing?
Because compilation and execution can use different class paths. We compiled against the jackson-core version our IDE or a module resolved, which had the method, while the packaged application resolved a different version. The compiler cannot know what the deployment will contain; the JVM only finds out when the call is first resolved, which can be long after start-up.
Is the fix always to take the newer version?
Usually, because libraries tend to keep old methods for a while, so the newer version satisfies both callers. But not always: a newer version may remove methods an older dependency uses, producing the same error in another place. That is why a BOM with versions tested together, such as Spring Boot's, is safer than picking the maximum by hand, and why tests should run on the packaged artifact.
7Conclusion
In this answer, we saw that NoSuchMethodError means the class at run time comes from a different version than the one we compiled against, here an older jackson-core chosen through a transitive dependency or a second copy on the class path. mvn dependency:tree -Dverbose and gradle dependencyInsight show which version won and why, getCodeSource and -verbose:class show which jar the JVM really used, and a BOM such as Spring Boot's dependency management or jackson-bom, enforced with dependencyConvergence, fixes and prevents it.
Open with
NoSuchMethodError at run time when everything compiled means the JVM loaded a different version of the class than the one I compiled against. My code and the new jackson-databind were built against a jackson-core that has that createParser method, but the jackson-core on the run-time class path is older and does not.
Then, if they want more
That happens in two ways: either the build resolved an older version through a transitive dependency, because Maven picks the nearest declaration and some SDK declares an old jackson-core, or two copies are on the class path, for example one inside a fat jar, and the older one comes first.
To find it, I run mvn dependency:tree -Dverbose filtered on jackson-core, which shows the winning version and the ones omitted for conflict with their paths, or gradle dependencyInsight for Gradle. To confirm what actually ran, I print JsonFactory.class.getProtectionDomain().getCodeSource().getLocation(), or start with -verbose:class and look for the jar JsonFactory was loaded from.
The fix is to align versions: in Spring Boot, let Boot's dependency management pin Jackson and remove overrides; otherwise import jackson-bom so all Jackson modules share one version. Then I add the Maven Enforcer dependencyConvergence rule, or failOnVersionConflict in Gradle, so the next divergence fails the build instead of production.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Spring Boot 4
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "After a dependency upgrade, a service fails at runtime with java.lang.NoSuchMethodError...": https://scrivio-interview-library.netlify.app/java/class-loading/b6ffd38628/