ScreenshotNeo

BlogHow-to

How to Fix NoClassDefFoundError for iText’s IMetaInfo Class

Fix IMetaInfo runtime errors by aligning iText modules, checking the deployed classpath, and verifying compatibility with html2pdf.

By the ScreenshotNeo team30 September 20269 min read

How to Fix NoClassDefFoundError for iText’s IMetaInfo Class

java.lang.NoClassDefFoundError: com/itextpdf/kernel/counter/event/IMetaInfo means the JVM could not load iText’s IMetaInfo class when the application ran. If your project uses iText 7.0.4 with html2pdf, a reported fix was upgrading iText to 7.1.7; a separate html2pdf report was resolved by upgrading kernel to 7.2.5. These are case-specific fixes, not universal version recommendations. The durable remedy is to align every iText module and add-on on a compatible release, then confirm that the same artifacts are present in the deployed runtime classpath.

1. What the error means

IMetaInfo belongs to iText’s kernel package. NoClassDefFoundError is a runtime linkage error: code was compiled or loaded expecting a class, but the active class loader could not find a usable definition. That can happen even when a dependency appears in your Maven or Gradle file. The build declaration is only one input; the runtime may instead use a stale server library, a shaded archive, an incomplete container image, or a different dependency graph.

The slash-separated class name in the exception corresponds to this Java name:

com.itextpdf.kernel.counter.event.IMetaInfo

Start by determining which iText kernel JAR is actually loaded, not just which version you intended to declare.

2. Fast remediation checklist

  1. Choose one iText release compatible with your Java runtime and any add-ons such as html2pdf.
  2. Use one shared version value for all selected com.itextpdf modules.
  3. Include the modules your app uses. For a basic Java setup, iText identifies kernel, io, and layout as always needed.
  4. Inspect the resolved dependency tree and check for mixed versions, exclusions, or duplicate artifacts.
  5. Inspect the packaged application and deployment environment for older iText JARs.
  6. Clean, rebuild, redeploy, and verify the runtime classpath again.

Do not solve a missing class by adding an arbitrary second kernel JAR. Two versions on one classpath can make class loading order-dependent and lead to a different linkage error.

3. Align iText modules in Maven

Use a shared property so module versions move together. This example shows the basic modules; add only the other modules your application needs and keep their versions aligned. Select a release based on your Java version and the compatibility requirements of html2pdf or other add-ons. See iText’s installation guide and migration guidance for current dependency information.

Keep iText modules on one compatible release and remove older duplicates from the runtime classpath.
Keep iText modules on one compatible release and remove older duplicates from the runtime classpath.
<properties>
    <itext.version>7.2.5</itext.version>
</properties>

<dependencies>
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>kernel</artifactId>
        <version>${itext.version}</version>
    </dependency>
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>io</artifactId>
        <version>${itext.version}</version>
    </dependency>
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>layout</artifactId>
        <version>${itext.version}</version>
    </dependency>
</dependencies>

The version above is an example corresponding to one reported resolution, not a blanket recommendation. The research dossier identifies later iText lines too, and version choice changes over time. Check the official release and installation materials before adopting a version. If you use html2pdf, verify its compatibility guidance and synchronize its required iText Core dependencies rather than upgrading only one artifact.

Inspect Maven’s resolved graph

mvn dependency:tree -Dincludes=com.itextpdf

Look for multiple versions of kernel, io, layout, or add-ons. Also inspect the full tree if a dependency has excluded a transitive iText module. After changing the POM, run a clean package so an old compiled output or cached deployment artifact does not conceal the result.

4. Align iText modules in Gradle

Centralize the version in one place and reuse it for each module. This Groovy DSL example declares the basic modules:

ext {
    itextVersion = '7.2.5'
}

dependencies {
    implementation "com.itextpdf:kernel:${itextVersion}"
    implementation "com.itextpdf:io:${itextVersion}"
    implementation "com.itextpdf:layout:${itextVersion}"
}

Use the equivalent shared property or version catalog entry if your project uses Kotlin DSL or a Gradle version catalog. Avoid independently pinning a transitive kernel version in one subproject while other modules use a different release.

Inspect Gradle’s resolved graph

./gradlew dependencies --configuration runtimeClasspath
./gradlew dependencyInsight --dependency com.itextpdf --configuration runtimeClasspath

Check the selected version as well as the versions requested by dependencies. Gradle conflict resolution may select a version different from an individual declaration. If an add-on requests a different line, resolve the compatibility question before forcing a version across the graph.

5. Check what the application actually runs

A clean dependency report does not guarantee the deployed classpath is clean. Follow the artifact through packaging and deployment:

The deployed runtime and class loader determine which iText classes the JVM can load.
The deployed runtime and class loader determine which iText classes the JVM can load.
  1. Inspect the built artifact. For a Spring Boot executable JAR, list nested dependencies; for a WAR, inspect WEB-INF/lib; for a shaded JAR, inspect the resulting archive and shading configuration.
  2. Inspect the container or server. Check copied libraries, mounted directories, application-server shared libraries, and old deployment folders.
  3. Remove stale duplicates. Delete or replace older iText JARs that the container or server may load before the application’s own libraries.
  4. Confirm the runtime selection. In a diagnostic run, print where the class would be loaded from:
Class<?> type = Class.forName(
    "com.itextpdf.kernel.counter.event.IMetaInfo",
    false,
    Thread.currentThread().getContextClassLoader()
);
System.out.println(type.getProtectionDomain().getCodeSource().getLocation());

If this diagnostic itself throws ClassNotFoundException, the class is not visible to that class loader. If it succeeds, the printed location helps reveal whether an unexpected JAR is being used. Run the check in the same process and deployment context that exhibits the error.

6. If html2pdf is involved

html2pdf adds another compatibility constraint. The reports in the dossier describe different cases: one user with iText 7.0.4 reported success after moving to 7.1.7, while another html2pdf case was resolved with kernel 7.2.5. Treat them as evidence that an upgrade can fix a stale or incompatible dependency set, not as proof that either version is right for every project.

Check the add-on’s documented version requirements, then choose a compatible iText Core line. Keep all iText artifacts synchronized, including modules brought in transitively by html2pdf. Inspect the final runtime graph after dependency resolution. If the add-on requires a particular line, upgrading only kernel can leave binary incompatibilities elsewhere.

7. Modules and configuration to review

iText is modular. Its installation guide describes Maven coordinates under com.itextpdf and identifies the basic modules as kernel, io, and layout. Other modules, including forms, PDF/A, signing, and a Bouncy Castle adapter, depend on the features used. Do not add every module speculatively; add the required module and align its release with the rest of the selected iText set.

Check these configuration points when resolving the error:

  • Dependency scope: Ensure the dependency is available at runtime, not only during compilation or tests.
  • Exclusions: Review exclusions that may remove kernel or another required module from a transitive path.
  • Shading and minimization: Verify packaging has not removed classes or overwritten resources when creating a fat JAR.
  • Application server class loading: Determine whether parent-first loading or shared libraries expose an older release.
  • Java and add-on compatibility: Select a version supported by the actual runtime and dependent iText products.
  • License fit: iText materials describe the AGPL/community distribution and commercial licensing. Review the applicable terms for your use case.

8. Common errors and fixes

Symptom Likely cause What to do
Error remains after changing the POM Deployment still contains an old JAR, or the new artifact was not packaged. Clean the build, inspect the produced archive, remove stale server libraries, and redeploy.
Build succeeds but runtime fails Compile and runtime dependency graphs differ, or packaging omitted a dependency. Inspect Maven’s tree or Gradle’s runtimeClasspath, then inspect the deployed artifact.
A different NoSuchMethodError appears after adding kernel Mixed iText versions provide incompatible classes and methods. Align all iText modules and add-ons to one compatible release; remove duplicate JARs.
Only the application server fails A shared library or class loader is selecting a different iText copy. Check server library directories and class-loading policy; confirm the loaded code source.
html2pdf still fails after an upgrade The selected Core version may not match the add-on, or a transitive old module remains. Follow the add-on’s compatibility guidance and inspect the complete resolved runtime graph.
Class lookup works in a local shell but not in production The production image, deployment, or class loader differs from local development. Run the diagnostic inside the failing runtime and inspect that environment’s packaged files.

9. Reliability, performance, and cost considerations

This is a dependency and deployment issue, so the main reliability gain comes from making the runtime deterministic. Pin a coordinated release, keep dependency declarations centralized, and make deployment artifacts reproducible. Record the resolved dependency graph as part of release review so an add-on update cannot silently introduce a second iText line.

Do not expect a version upgrade by itself to improve PDF generation speed; the cited material addresses class availability and compatibility, not performance benchmarks. After a coordinated upgrade, use your application’s normal document-generation checks to confirm output behavior for the features it relies on. Avoid mixing versions as a shortcut: it can replace a clear missing-class failure with harder-to-diagnose linkage errors.

For cost, account for the licensing terms that apply to the iText distribution and your application. iText’s installation materials distinguish the AGPL/community distribution from commercial licensing. Review the official terms for your distribution model before release; this technical exception alone does not determine which license applies.

10. Or skip the browser setup

If you arrived here while trying to capture a rendered webpage as an image or PDF, ScreenshotNeo is a website screenshot API and MCP server. Its one-call API returns PNG, JPEG, WebP, or PDF output. For a screenshot, the cURL example is:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API docs for options and setup. It accepts cookie or consent banners and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Create a free ScreenshotNeo account to get 1,000 screenshots a month with no card.

11. FAQ

Does this mean IMetaInfo was removed from all iText versions?

No. The exception says the class was unavailable to the running application. It does not by itself establish that the class is absent from every release; verify the actual JAR and version being loaded.

Should I add only the kernel dependency?

Not automatically. Kernel contains the referenced class, but a working application may need other modules. Keep the selected modules on a compatible release and follow the setup requirements for the features in use.

Can I use the reported 7.1.7 or 7.2.5 fix directly?

Use those reports as clues, then check your Java runtime and add-on constraints. They describe different project cases and are not universal compatibility guarantees.

Why does the build file look correct when the error still happens?

The JVM loads deployed runtime artifacts. A stale JAR, class-loader boundary, packaging exclusion, or runtime scope can make that set differ from the build declaration.

12. Final verification

  • One compatible iText version is selected across modules and add-ons.
  • The required modules are present in the runtime dependency graph.
  • The packaged and deployed application contains no unintended older iText copies.
  • The class diagnostic, when used, points to the expected runtime artifact.
  • The application’s PDF path runs on the same Java runtime and deployment model used in production.

iText’s installation guide notes that each dependency corresponds to a Java JAR (and a DLL in C#). Treat the runtime artifact set as the source of truth: once it is aligned with your add-ons and deployment environment, the missing IMetaInfo class error should be addressed at its cause.