javaweb tomcat 严重: 启动过滤器异常
错误代码严重: 启动过滤器异常
java.lang.ClassNotFoundException: cn.itcast.goods.web.filter.LoginFilter
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1407)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1215)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:538)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:519)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:149)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:249)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:101)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4613)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5256)
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:696)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1185)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1933)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1095)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:477)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1618)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:319)
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:835)
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.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
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:772)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:476)
十二月 09, 2021 3:35:27 下午 org.apache.catalina.core.StandardContext filterStart
严重: 启动过滤器异常
java.lang.ClassNotFoundException: cn.itcast.goods.admin.web.filter.AdminLoginFilter
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1407)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1215)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:538)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:519)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:149)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:249)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:101)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4613)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5256)
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:696)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1185)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1933)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1095)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:477)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1618)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:319)
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:835)
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.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
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:772)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:476)
十二月 09, 2021 3:35:27 下午 org.apache.catalina.core.StandardContext startInternal
严重: 一个或多个筛选器启动失败。完整的详细信息将在相应的容器日志文件中找到
十二月 09, 2021 3:35:27 下午 org.apache.catalina.core.StandardContext startInternal
严重: 由于之前的错误,Context启动失败
十二月 09, 2021 3:35:27 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Web应用程序目录的部署已在毫秒内完成
十二月 09, 2021 3:35:27 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: 把web 应用程序部署到目录
十二月 09, 2021 3:35:27 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Web应用程序目录的部署已在毫秒内完成
十二月 09, 2021 3:35:27 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: 把web 应用程序部署到目录
十二月 09, 2021 3:35:27 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Web应用程序目录的部署已在毫秒内完成
十二月 09, 2021 3:35:27 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: 把web 应用程序部署到目录
十二月 09, 2021 3:35:27 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Web应用程序目录的部署已在毫秒内完成
十二月 09, 2021 3:35:27 下午 org.apache.coyote.AbstractProtocol start
信息: 开始协议处理句柄["http-nio-8080"]
十二月 09, 2021 3:35:27 下午 org.apache.catalina.startup.Catalina start
信息: 毫秒后服务器启动 LoginFilter 未定义
这个 Bean 没有配置 xml 文件
或者没有配置 Bean 注解
或者容器启动没有扫描到改类,packageScan 配置不对 仔细检查下cn.itcast.goods.web.filter.LoginFilter 这个类是否有问题,以及配置这个类以及包的配置文件或注解是否正确,问题应该就能解决了。:loveliness: 前面两层楼的说得对 Vvvvvoid 发表于 2021-12-9 16:08
LoginFilter 未定义
这个 Bean 没有配置 xml 文件
或者没有配置 Bean 注解
package cn.itcast.goods.web.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
public class LoginFilter implements Filter {
public void destroy() {
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
/*
* 1. 获取session中的user
* 2. 判断是否为null
* > 如果为null:保存错误信息,转发到msg.jsp
* > 如果不为null:放行
*/
HttpServletRequest req = (HttpServletRequest) request;
Object user = req.getSession().getAttribute("sessionUser");
if(user == null) {
req.setAttribute("code", "error");//为了显示X图片
req.setAttribute("msg", "您还没有登录,不能访问本资源");
req.getRequestDispatcher("/jsps/msg.jsp").forward(req, response);
} else {
chain.doFilter(request, response);//放行
}
}
public void init(FilterConfig fConfig) throws ServletException {
}
}
看了下,没啥问题啊 Goldrepo 发表于 2021-12-9 17:24
仔细检查下cn.itcast.goods.web.filter.LoginFilter 这个类是否有问题,以及配置这个类以及包的配置文件或 ...
代码在上边,看了下。没啥问题 本帖最后由 ycbb123 于 2021-12-9 20:40 编辑
987857149 发表于 2021-12-9 18:42
代码在上边,看了下。没啥问题
编辑了,回复错了 987857149 发表于 2021-12-9 18:42
代码在上边,看了下。没啥问题
检查下报错的环境是不是少了jar包,看你这个类是继承javax.servlet.Filter(来自servlet-api-XXX.jar)
java.lang.ClassNotFoundException: cn.itcast.goods.web.filter.LoginFilter
删除一下缓存重新启动一下 这个报错很明显了,你用到了这个类的依赖,但是在容器中没有找到这个类的实例,应该是在项目启动的时候没有加载类对象到容器中,看下是不是注解或者配置文件没加
页:
[1]