Runtime error (Springboot - app)

I’m migrating SpringBoot application from version 2.7 to version 3.15 (Java 11 → 17).

When I build a project using Gradle, I get a working jar file.

When I try to run the bootRun task, I get the error message “java.lang.NoClassDefFoundError: com/groupdocs/viewer/interfaces/FileStreamFactory”.

When the jar file is launched, the code is executed as expected.

1 Like

Hello, valentinz.

We can’t reproduce the problem in simple Gradle project with Java 17, Spring Boot v3.1.5 and GroupDocs.Viewer v23.7.
Could you please provide small simple project where the problem can be reproduced?
Or at least write which GroupDocs.Viewer version is used and provide full console output for analyzing. The problem can be connected to max MANIFEST.MF file size or to something else.

Thanks.

Hallo, Aleksey,

Thanks for the answer.
My current environment:

Java Zulu17.46+19-CA, Spring Boot v3.1.5, GroupDocs.Viewer v23.7, IntelliJ IDEA 2023.2.5 (Ultimate Edition).

Yes, I had a problem with “Unsupported size: 22465227 for JarEntry META-INF/MANIFEST.MF”, which sometimes broke the build already during compilation.

I added the recommended parameter:
./gradlew bootJar -Djdk.jar.maxSignatureFileSize=28000000
The build occurs correctly and the executable jar can be launched, despite the message:

"
./gradlew bootJar

Task:compileJava
error: error reading /Users/valentinshuravlov/.gradle/caches/modules-2/files-2.1/com.groupdocs/groupdocs-viewer/23.7/2f4caaaf2dbdb157c428cc63014dec0456a69472/groupdocs-viewer-23.7.jar; Unsupported size: 22465227 for JarEntry META-INF/MANIFEST.MF. Allowed max size: 8000000 bytes

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to Command-Line Interface in the Gradle documentation.

BUILD SUCCESSFUL in 2s
"

When I run:
"
./gradlew bootRun -Djdk.jar.maxSignatureFileSize=28000000
then I get:
Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.example.demo.app.ConvertService] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@531d72ca]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:483) ~[spring-core-6.0.13.jar:6.0.13]
at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:320) ~[spring-core-6.0.13.jar:6.0.13]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.checkLookupMethods(AutowiredAnnotationBeanPostProcessor.java:459) ~[spring-beans-6.0.13.jar:6.0.13]
… 19 common frames omitted
Caused by: java.lang.NoClassDefFoundError: com/groupdocs/viewer/interfaces/FileStreamFactory
at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402) ~[na:na]
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2504) ~[na:na]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:465) ~[spring-core-6.0.13.jar:6.0.13]
…21 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.groupdocs.viewer.interfaces.FileStreamFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) ~[na:na]
…25 common frames omitted
"

Perhaps this is a gradle problem or do you know any recipes? :slight_smile:

Thanks for the information. We will check everything.

I have the same issue. I am evaluating your product for use in a new commercial product. Once I see it working, we will subscribe with a paid for license.

I’m not doing a spring boot project, just a simple gradle project. Using gradle 8.4. Here’s my error message:

error reading /Users/bgmoon/.gradle/caches/modules-2/files-2.1/com.groupdocs/groupdocs-viewer/23.11/879d64b7a9ea2d94b546f2e7cba266a4486ba5fc/groupdocs-viewer-23.11.jar; Unsupported size: 22794305 for JarEntry META-INF/MANIFEST.MF. Allowed max size: 16000000 bytes. You can use the jdk.jar.maxSignatureFileSize system property to increase the default value.

I have also tried 23.7 just in case.

I have also cleared my gradle caches and restarted.

I’m building using IntelliJ 23.2.5, Gradle 8.4 and JDK 21 (Azul)

My build.gradle contains this:

maven {
    url 'https://repository.groupdocs.com/repo/'
}
// group docs
implementation 'com.groupdocs:groupdocs-viewer:23.11'

I see the JAR file downloaded in to my runtime class path just fine.

My test is using JUNIT 5 and this is the code:

package io.whiteStar.gui;

import com.groupdocs.viewer.Viewer;
import com.groupdocs.viewer.options.HtmlViewOptions;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class GUITest {

@Test
public void viewPDF() {
    // Instantiate Viewer
    try (Viewer viewer = new Viewer("sample1.pdf"))
    {
        // Set output HTML options, one file per page
        HtmlViewOptions viewOptions =
                HtmlViewOptions.forEmbeddedResources();

        // Render PDF to HTML with embedded resources
        viewer.view(viewOptions);
    }
}

}

Tried downloading your “Demos and Examples” from GitHub to run using the same gradle setup as outlined above.

When I try to run “RunExamples” I get the same error:

error reading /Users/bgmoon/.gradle/caches/modules-2/files-2.1/com.groupdocs/groupdocs-viewer/23.11/879d64b7a9ea2d94b546f2e7cba266a4486ba5fc/groupdocs-viewer-23.11.jar; Unsupported size: 22794305 for JarEntry META-INF/MANIFEST.MF. Allowed max size: 8000000 bytes

I did some digging. It seems the fault is that the signature associated with the Manifest exceeds the maximum size allowed by the JVM (8M for JDK’s from 11 to 20 and 16M for JDK 21.). This change in enforcing the maxim manifest file size was a security issue fixed by the java community.

I have tried every way that I can think of to include this directive in the gradle invocation from IntelliJ, but no joy:

-Djdk.jar.maxSignatureFileSize=32000000

In theory, if I add this to my grade daemon launcher it should allow for a larger signature but as I say, I have not found a way to make this work.

OK, was able to get this to render. In IntelliJ, right click on your main method (with the green arrow) and select “modify run configuration”, then in the “Run” category, select the “Modify options” drop down list and on that list select “Add VM options”. A new field will present on the editor called “VM Options”, and there you can add the JVM parameter: -Djdk.jar.maxSignatureFileSize=25000000

Note at this point, you can “run” the application, but you will still get the error message about reading the manifest file exceeding the maximum file size.

Hope that helps someone else …

1 Like

@bgmoon

Thank you for sharing your findings!

Hello, do you have any news? or workarounds applicable.

I have the same problem here. In the back-end I have:

  • java 17 (openjdk 17.0.8.1 2023-08-24)
  • spring Boot 3 (more precisely: spring-boot-starter-parent 3.1.5)
  • In my maven pom.xml back-end file I added:
        <dependency>
            <groupId>com.groupdocs</groupId>
            <artifactId>groupdocs-viewer</artifactId>
            <version>21.11.1</version>
        </dependency>

I already did maven clean, maven refresh dependencies. Maven install, or trying to execute the Spring Boot application as usual from my IDE (IntelliJ Idea), even with VM options: -Djdk.jar.maxSignatureFileSize=25000000 or -Djdk.jar.maxSignatureFileSize=100000000,
prints this error to the console:

java: error reading C:\Users\bernardodepc.m2\repository\com\groupdocs\groupdocs-viewer\21.11.1\groupdocs-viewer-21.11.1.jar; Unsupported size: 20806623 for JarEntry META-INF/MANIFEST.MF. Allowed max size: 8000000 bytes

I can see in my C:\Users(...)\.m2\repository\com\groupdocs\groupdocs-viewer\21.11.1 folder that: groupdocs-viewer-21.11.1.jar has 243MB size.

Is this normal?
Do you have any workaround to suggest?
(Contrarily to what user bgmoon suggests, this error is blocking for me. My app does not run)

@Clara_Paiva

Please try using -Djdk.jar.maxSignatureFileSize=28000000 as in some cases one option is working while the other is not.

Unfortunately, at the moment we do not have a solution to this issue other than adding one of the listed in this topic command line parameters.

Thanks @vladimir.litvinchik
I confirm that workaround worked - after doing a Rebuild of the project.
(For some IDE reason probably, when I executed those suggested flags as VM options of my Spring Boot run in IntelliJ IDEa, the blocking error continued to appear. Once I rebuilt it, it started working… )

@Clara_Paiva

You’re welcome! Probably it could be due to the caching that IDE performs.

1 Like