tomcat部署war包出现NameNotFoundException

好久没更新博客了,最近踩到了一个深坑,花了一天时间才解决这个问题, 特此更新博客记录下。 项目是springboot 搭建的,前期的过程就不一一叙述,直接上问题,在打包成war包部署到tomcat并启动后报NameNotFoundException,具体情况如下:

javax.naming.NameNotFoundException: Name [com.rehe.safety.security.MyFilterSecurityInterceptor/securityMetadataSource] is not bound in this Context. Unable to find [com.rehe.safety.security.MyFilterSecurityInterceptor].
at org.apache.naming.NamingContext.lookup(NamingContext.java:816)
at org.apache.naming.NamingContext.lookup(NamingContext.java:173)
at org.apache.catalina.core.DefaultInstanceManager.lookupFieldResource(DefaultInstanceManager.java:589)
at org.apache.catalina.core.DefaultInstanceManager.processAnnotations(DefaultInstanceManager.java:487)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:174)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:166)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:111)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4657)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5304)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)

之前没遇到这个问题,上网一顿搜索,提供的方法有以下几种:

相关推荐