Alvin C
Alvin C

Reputation: 1

Springdoc works with war but cannot start when embedded within an ear (Wildfly31 + JDK17)

I was using spring-core 6.1.5, springdoc-openapi-starter-webmvc-ui 2.5.0. When i packaged my application as war and deploy to Wildfly31 running on JDK17, it was working fine and I am able to access both api-docs and swagger-ui.html. However, when i packaged as ear, it was not able to startup. Both packages have the exact same classpath, except that war has the dependencies in the /lib folder while ear has the dependencies in the ear with the same jars in the war's manifest. The error is quite unexpected:

Caused by: java.lang.NoClassDefFoundError: Failed to link org/springframework/web/servlet/support/AbstractDispatcherServletInitializer (Module "deployment.springdocweb-module-7.0.0-SNAPSHOT.ear.spring-webmvc-6.1.5.jar" from Service Module Loader): org/springframework/web/context/AbstractContextLoaderInitializer
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1095)
    at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:351)
    at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:482)
    at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:276)
    at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:79)
    at org.jboss.modules.Module.loadModuleClass(Module.java:765)
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:192)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
    at [email protected]//org.wildfly.extension.undertow.deployment.ServletContainerInitializerDeploymentProcessor.loadClassInfoSet(ServletContainerInitializerDeploymentProcessor.java:277)
    at [email protected]//org.wildfly.extension.undertow.deployment.ServletContainerInitializerDeploymentProcessor.deploy(ServletContainerInitializerDeploymentProcessor.java:179)
    at [email protected]//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:172)
    ... 8 more

I am trying to upgrade my REST module previously using Springfox to Springdoc so that I can run my applicaton on JDK17 with Jakarta API. I was able to get my sample app to run on Springboot and War but just not in ear.

Upvotes: 0

Views: 61

Answers (1)

Alvin C
Alvin C

Reputation: 1

I fixed this issue by placing all the dependencies in the /lib folder of the ear file, instead of the root. It seems that after adding the springdoc-openapi-starter-webmvc-ui.jar, the autoconfigure is looking for the jars in the /lib.

Upvotes: 0

Related Questions