解决IDEA配置tomcat启动报错问题

在配置servlet不同路径时遇上以下两个错误:

java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
 java.lang.ClassNotFoundException: org.apache.jsp.index_jsp;

对于第一个问题,我上网查阅了很多资料后发现,可能是tomcat版本冲突导致,catalina log如下:

19-Feb-2018 08:26:44.175 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.5.28
19-Feb-2018 08:26:44.175 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Feb 6 2018 23:10:25 UTC
19-Feb-2018 08:26:44.175 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.5.28.0
19-Feb-2018 08:26:44.191 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows 7
19-Feb-2018 08:26:44.191 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            6.1
19-Feb-2018 08:26:44.191 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          x86
19-Feb-2018 08:26:44.191 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             C:\Program Files\Java\jdk1.8.0_141\jre
19-Feb-2018 08:26:44.191 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_141-b15
19-Feb-2018 08:26:44.191 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
19-Feb-2018 08:26:44.191 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         F:\apache-tomcat-8.5.28
19-Feb-2018 08:26:44.191 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         F:\apache-tomcat-8.5.28
19-Feb-2018 08:26:44.191 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=F:\apache-tomcat-8.5.28\conf\logging.properties
19-Feb-2018 08:26:44.191 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
19-Feb-2018 08:26:44.191 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
19-Feb-2018 08:26:44.191 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
19-Feb-2018 08:26:44.191 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
19-Feb-2018 08:26:44.191 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=F:\apache-tomcat-8.5.28
19-Feb-2018 08:26:44.191 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=F:\apache-tomcat-8.5.28
19-Feb-2018 08:26:44.191 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=F:\apache-tomcat-8.5.28\temp
19-Feb-2018 08:26:44.191 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library [1.2.16] using APR version [1.6.3].
19-Feb-2018 08:26:44.206 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
19-Feb-2018 08:26:44.206 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
19-Feb-2018 08:26:44.830 信息 [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.0.2m  2 Nov 2017]
19-Feb-2018 08:26:45.080 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
19-Feb-2018 08:26:45.517 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
19-Feb-2018 08:26:45.581 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
19-Feb-2018 08:26:45.597 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
19-Feb-2018 08:26:45.597 信息 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 2422 ms
19-Feb-2018 08:26:45.643 信息 [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
19-Feb-2018 08:26:45.643 信息 [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.28
19-Feb-2018 08:26:45.675 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [F:\apache-tomcat-8.5.28\webapps\docs]
19-Feb-2018 08:26:46.423 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [F:\apache-tomcat-8.5.28\webapps\docs] has finished in [748] ms
19-Feb-2018 08:26:46.423 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [F:\apache-tomcat-8.5.28\webapps\examples]
19-Feb-2018 08:26:47.059 严重 [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: 
 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/examples]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1141)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1875)
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:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [Pipeline[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/examples]]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5125)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.authenticator.FormAuthenticator[/examples]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:182)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 12 more
Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
at org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1186)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 14 more

19-Feb-2018 08:26:47.075 严重 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Error deploying web application directory [F:\apache-tomcat-8.5.28\webapps\examples]
 java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/examples]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:756)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1141)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1875)
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:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

我先试着删除其他Tomcat版本,重新配置tomcat环境变量并重新部署Tomcat。发现并没有解决问题,再次上网查阅,发现getContextPath()在servlet2.5特有。于是试着删除原先jar包中的servlet-api.jar,然后重新部署项目。发现了第二个问题,log如下:

19-Feb-2018 09:59:51.534 严重 [http-nio-8080-exec-3] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [jsp] in context with path [/Happy] threw exception [java.lang.ClassNotFoundException: org.apache.jsp.index_jsp] with root cause
 java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:129)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:60)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:159)
at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:171)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:380)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

19-Feb-2018 10:03:45.289 严重 [http-nio-8080-exec-1] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [jsp] in context with path [/Happy] threw exception [Unable to compile class for JSP] with root cause
 java.lang.ClassNotFoundException: com.sun.el.ExpressionFactoryImpl
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1291)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
at javax.el.FactoryFinder.newInstance(FactoryFinder.java:83)
at javax.el.FactoryFinder.find(FactoryFinder.java:193)
at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:185)
at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:156)
at org.apache.jasper.compiler.PageInfo.<init>(PageInfo.java:80)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:117)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:374)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:351)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:335)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:595)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:368)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

再次查阅资料,发现是缺少jar包。因为jdk1.8的扩展jar包里没有servlet相关api,故IDEA会导入失败。

此时需要导入jar包,之前我是下载相关api

然后放到下图目录中

为了防止出现缺少jar包问题,建议直接去tomcat目录下的lib中找到servlet-api.jar,直接复制到ext中。然后再重新部署一下tomcat,问题解决。

总结

到此这篇关于解决IDEA配置tomcat启动报错问题的文章就介绍到这了,更多相关IDEA配置tomcat启动报错内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

(0)

相关推荐

  • 解决应用启动失败但tomcat不报错的方法

    发现问题 最近遇到了一个奇葩的问题就是应用启动失败,但是tomcat没有报任何的日志出来,log4j.properties日志级别写的是debug级别也没用. 解决过程 遇到这种情况,可以试着在web应用的classpath目录添加一个logging.properties文件来试一下 handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler ##################################

  • 解决idea导入ssm项目启动tomcat报错404的问题

    用idea写ssm项目,基于之前一直在用spring boot 对于idea如何运行ssm花费了一番功夫 启动Tom act一直在报404 我搜了网上各种解决办法都不行,花费一天多的时间解决不了 就是在pom中添加下面代码 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin<

  • Tomcat启动时报错:java.lang.UnsatisfiedLinkError的解决

    问题 之前tomcat启动老是报错,虽然不影响项目的启动运行,但是有强迫症的程序员会心里不爽: 如下: 问题分析 由于本机安装的jdk版本与tomcat中使用的jdk版本不一致导致的. 解决方法 后面我把原先tomcat启动环境用的jdk1.7改为了本机安装的jdk1.8就不在报错. 具体过程: 在myeclipse中点击window→preference→在搜索框中输入Tomcat→选择安装的tomcat版本,我这里是选择Tomcat 7.x→点击JDK→在Tomcat 7.x JDK nam

  • tomcat启动报错:java.util.zip.ZipException的解决方法

    发现问题 早上起来报错误,Jenkins打包到tomcat服务器,死活启动不起来,一些定时任务也没跑成功. 报错如下: org.apache.catalina.startup.ContextConfig.beforeStart Exception fixing docBase for context [/test] java.util.zip.ZipException: error in opening zip file at java.util.zip.ZipFile.open(Native

  • CentOS 6.5上的Tomcat启动报错问题解决方法

    这里有两个错误: 1.第一个错误,APR的问题,错误详情: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path 2.第二个错误,错误详情: Exception in thread "main" java.lang.InternalError        

  • 解决IDEA配置tomcat启动报错问题

    在配置servlet不同路径时遇上以下两个错误: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String:  java.lang.ClassNotFoundException: org.apache.jsp.index_jsp: 对于第一个问题,我上网查阅了很多资料后发现,可能是tomcat版本冲突导致,catalina log如下: 19-Feb-2018

  • 解决SpringBoot webSocket 资源无法加载、tomcat启动报错的问题

    问题描述: 1. 项目集成WebSocket,且打包发布tomcat时出现websocket is already in CLOSING or CLOSE state这样的问题,建议参考"解决方法二",但是"解决方法一"请要了解查看 ,因为解决方法二是在一的基础上进行更正 2. 如果出现javax.websocket.server.ServerContainer not available这样的错误,请参考"解决方法一"中步骤3 解决方法一:(常

  • 解决springboot项目不配置数据源启动报错问题

    目录 springboot项目不配置数据源启动报错 springboot配置双数据源报错 springboot项目不配置数据源启动报错 spring boot默认会加载 org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration 在启动类上加上 @SpringBootApplication(exclude={DataSourceAutoConfiguration.class, HibernateJpaAutoCo

  • 解决Idea的tomcat启动报多个listener的错误问题

    错误截图 找不到出错的异常位置在哪里.解决办法:在resources目录下创建一个logging.properties的文件,然后重启 handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler ############################################################ # Handler specific properties. # Describes speci

  • 解决springboot整合cxf启动报错,原因是版本问题

    springboot整合cxf启动报错 错误信息如下 [DEBUG] 2021-01-26 11:28:47,848 [main] org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter - Application failed to start due to an exception org.springframework.beans.factory.NoSuchBeanDefinitionException: N

  • 解决idea启动报错javax.imageio.IIOException的问题

    idea启动报错javax.imageio.IIOException,解决点击ok打不开的问题 问题根源javax.imageio.IIOException: Can't get input stream from URL 出现该问题原因,根本原因就是因为下载了自定义idea背景图片的插件,如果你点击确定可以打开,百度有解决方案. 针对点击确定会闪退 点击确定之后出现闪退无法打开idea 1.点击确定,闪退之后 2.找到C盘的用户目录下, idea的异常都记录在这里 : 3.点击其中一个最新的文

  • mysql启动报错:The server quit without updating PID file的几种解决办法汇总

    1.目录权限问题 对mysql的安装目录和数据目录分别进行授权 #chown -R mysql.mysql /usr/local/mysql #chown -R mysql.mysql /data/mysql #service mysqld start 2.可能进程里已经存在mysql进程 解决方法:用命令“ps -ef|grep mysqld”查看是否有mysqld进程,如果有使用“kill -9 进程号”杀死,然后重新启动mysqld! 3.可能是第二次在机器上安装mysql,有残余数据影响

  • react创建项目启动报错的完美解决方法

    目录 一.预备知识: 二.创建项目步骤: 三.启动项目时可能出现的报错: 四.Todolist项目相关库: 五.GitHub搜索案例相关库: 六.尚硅谷路由案例相关库: 七.UI库案例相关库: 八.redux相关库: 一.预备知识: npm (也可以用yarn,本文以npm为例) npm介绍 全称为Node Package Manager,是随同NodeJS一起安装的包管理工具. 允许用户从NPM服务器下载别人编写的第三方包到本地使用. 允许用户从NPM服务器下载并安装别人编写的命令行程序到本地

随机推荐