2022-04-26 17:44题主

​Webbuilder 安装故障:java.lang.NoClassDefFoundError: javax/servlet/Filter

我现在安装了 tomcat 10.0.20,(Windows 环境下zip包)
在将 wb 文件拷贝至 webapps 后,重启 tomcat;
进入页面 http://127.0.0.1:8080/manager/html 后,wb 这个应用启动不成功;
以下是报错信息(来自于日志文件 logs\localhost.2022-04-26.log):

26-Apr-2022 17:24:44.883 信息 [main] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized()
26-Apr-2022 17:24:44.883 信息 [main] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized()
26-Apr-2022 17:24:44.885 信息 [main] org.apache.catalina.core.ApplicationContext.log ContextListener: attributeAdded('StockTicker', 'async.Stockticker@e36bb2a')
26-Apr-2022 17:24:46.440 严重 [main] org.apache.catalina.core.StandardContext.filterStart 启动过滤器异常
java.lang.NoClassDefFoundError: javax/servlet/Filter
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1013)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2527)
at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:877)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1413)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1257)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:535)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:516)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:150)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:252)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4562)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5205)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:698)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1188)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:2023)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:123)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1098)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:480)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1708)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:320)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:946)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:886)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:263)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:927)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:795)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:476)
Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1449)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1257)
... 51 more

2022-04-27 08:52#1
WebBuilder 8 servlet默认使用javax包名
tomcat 10 servlet已经更名为jakarta
解决方案:
1、使用webbuilder 8 + tomcat 8
2、如果要使用tomcat 10,可以把webbuilder 8 javax更改包名为jakarta
3、使用 WebBuilder 9,WebBuilder 9支持最新Java和Tomcat等。
2022-05-09 09:03#2
改一下包名就可以使用tomcat10了

返回开发者社区