H2 Console : NoClassDefFoundError on javax.servlet.http.HttpServlet

2,268 views
Skip to first unread message

Benoit Delagarde

unread,
Dec 8, 2021, 9:06:06 AM12/8/21
to WildFly
Hello,

I'm try to use the H2Console Servlet. I have add it in my web.xml, but i get the following error :

08:50:11,732 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.subunit."DivingReservationEAR.ear"."DivingReservationWeb.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."DivingReservationEAR.ear"."DivingReservationWeb.war".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment "DivingReservationWeb.war" of deployment "DivingReservationEAR.ear"
        at org.jboss...@18.0.0.Beta5//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:189)
        at org.jb...@1.4.13.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
        at org.jb...@1.4.13.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
        at org.jb...@1.4.13.Final//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
        at org.jbos...@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jbos...@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
        at org.jbos...@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
        at org.jbos...@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.NoClassDefFoundError: Failed to link org/h2/server/web/WebServlet (Module "com.h2database.h2" version 1.4.197 from local module loader @30c93896 (finder: local module finder @59a008ba (roots: D:\Documents\Mes Applications\DiveManager\wildfly-26.0.0.Beta1\modules,D:\Documents\Mes Applications\DiveManager\wildfly-26.0.0.Beta1\modules\system\layers\base))): javax/servlet/http/HttpServlet
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
        at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:350)
        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:753)
        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 org.jboss...@26.0.0.Beta1//org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.checkDeclaredApplicationClassAsServlet(JaxrsScanningProcessor.java:412)
        at org.jboss...@26.0.0.Beta1//org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.scanWebDeployment(JaxrsScanningProcessor.java:255)
        at org.jboss...@26.0.0.Beta1//org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.deploy(JaxrsScanningProcessor.java:105)
        at org.jboss...@18.0.0.Beta5//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:182)
        ... 8 more


As I understand this error, the problerm  come from the class "javax.servlet.http.HttpServlet" witch is not in the classpath of the H2Console classloader.
This make me crazy because in th esame web.xml, I have another Servlet (javax.faces.webapp.FacesServlet) witch deploy correctly, and in cant imagine there is no need of the HttpServlet class in this servlet (by definition).

I believe there is some problem in the class path priority and the fact that the H2 librairy is loaded for the need of Wildlfy.

Can someone help me?

Brian Stansberry

unread,
Dec 8, 2021, 10:46:22 AM12/8/21
to WildFly
This is likely because in https://issues.redhat.com/browse/WFLY-14814 we (deliberately) removed the H2 module's dependency on the javax.servlet.api module.

To restore support for this I suggest you do the following:

1) cd $WILDFLY_HOME
2) mkdir -p modules/javax/servlet/api/h2
3) In that dir create a 'module.xml' file with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<module-alias xmlns="urn:jboss:module:1.9" name="javax.servlet.api:h2" target-name="javax.servlet.api"/>

Note that this won't work with WildFly Preview as H2 doesn't support the jakarta.* namespace.


I filed https://issues.redhat.com/browse/WFLY-15814 to make sure I cover this point in the WF 26 Final release announcement.

I also filed https://issues.redhat.com/browse/WFLY-15815 to note this in the Datasource subsystem section of the Admin Guide, although I'm not sure if that will happen in the WF 26 docs.

Benoit Delagarde

unread,
Dec 8, 2021, 12:22:49 PM12/8/21
to WildFly
Hello, 

The solution work fine in both Wildfly 25.0.1-Final and in Wildfly 26.0.0-Beta 1 

;-) 

Thank you. 

Brian Stansberry

unread,
Dec 8, 2021, 1:16:35 PM12/8/21
to WildFly
Great; thanks for the question and the report that it works!
Reply all
Reply to author
Forward
0 new messages