IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> Java知识库 -> Tomcat异常讲解 -> 正文阅读

[Java知识库]Tomcat异常讲解

1 Tomcat异常

1.1 起步内存溢出问题Exception in thread http-bio-8080

1.1.1异常现象

现象如下:
Tomcat7启动后,后台抛出如下异常,前台一直无法登陆

Exception in thread ““http-bio-8080”-exec-6” java.lang.OutOfMemoryError: PermGen space
Exception in thread ““http-bio-8080”-exec-9” java.lang.OutOfMemoryError: PermGen space
Exception in thread “schedulerFactory_Worker-3” java.lang.OutOfMemoryError: PermGen space
Exception in thread ““http-bio-8080”-exec-2” java.lang.OutOfMemoryError: PermGen space
Exception in thread “Timer-0” java.lang.OutOfMemoryError: PermGen space

1.1.2解决方案

tomcat指定的jdk加大启动的内存参数

-Xms128m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=128m

1.2 At least one JAR was scanned for TLDs yet contained no TLDs解决办法

在尝试以下操作前,请先关闭杀毒软件,确保不是受杀毒软件的影响;
部署的系统报如下错误,就是百度杀毒引起的。
报错内容:

Jun 03, 2013 1:09:49 PM org.apache.jasper.compiler.TldLocationsCache tldScanJar
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

这样的问题是你的页面中含有<!---->的注释,去掉就好了,tomcat7.0.20.

tomcat 7EL表达式的语法要求比较严格,例如"${owner.new}"因包含关键字new就会导致解析出错。
问题是出来了,怎么解决呢?有三种,如下:

  1. 严格遵守java规范,修改对象的属性名称,要求不包含java关键字;
  2. 修改EL表达式,例如"${owner.new}"可以修改为"${owner['new']}";
  3. 修改tomcat属性,忽略对EL表达式的关键字检查。修改$CATALINA_BASE/conf/catalina.properties文件,添加org.apache.el.parser.SKIP_IDENTIFIER_CHECK=true选项。

1.3 tomcat HTTP Status 405

出现HTTP Status 405 - HTTP method GET is not supported by this URL原因是:

  1. 继承自HttpservletServlet没有重写对于请求和响应的处理方法:doGet或doPost等方法,默认调用父类的doGet或doPost等方法。
  2. 父类HttpServlet的doGet或doPost等方法覆盖了你写的到doGet或doPost等方法。

不管是1或2,父类HttpServlet的doGet或doPost等方法默认实现是返回状态码是405的Http错误表示 对于指定资源请求方法不被允许。
解决方法:

  1. 子类重写doGet或doPost等方法。
  2. 在扩张的Servlet中重写doGet或doPost等方法来处理请求和响应时,不要调用父类的doGet或doPost等方法即去掉supper.doGet(request,response)和super.doPost(request,response);

1.4 java.lang.IllegalStateException;Cannot forward after response has been committe

当发生在如下错误的时候,有一个方案可行,
java.lang.IllegalStateException: Cannot forward after response has been committed
当你有多个跳转的页面的语句时候,好好检查一下,当 转发 或者 重定向的时候,需要在后加一个retrun 即可。
服务器中不允许多次跳转,否则会下面这个错误。

因为服务器端使用sendRedirect跳转到客户端的时候,不能在使用req.getRequestDispatcher("跳转的页面").forward(req, reqs);跳转;
所以在跳转之后,return就不会往下执行。

protected void login(HttpServletRequest req, HttpServletResponse reqs) throws ServletException, IOException {  
    // TODO Auto-generated method stub  
    if(req.getUserPrincipal()!=null){  
        String userID = req.getRemoteUser();  
        boolean bol = req.isUserInRole(USER_ROLE_ADMIN);  
        UserModel userModel =connectionDao.getUserModelByUserID(userID);  
        if(bol){  
            req.getSession().setAttribute("user",userModel);  
            reqs.sendRedirect(req.getContextPath()+"/admin/main.jsp");  
            return;  
        }else{  
            reqs.sendRedirect(req.getContextPath()+"/index.jsp");  
            return;  
        }  
    }  
}  

1.5 tomcat奇怪错误之A child container failed during start

错误详情:

严重: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/SimpleLogin]]
at java.util.concurrent.FutureTask S y n c . i n n e r G e t ( U n k n o w n S o u r c e ) a t j a v a . u t i l . c o n c u r r e n t . F u t u r e T a s k . g e t ( U n k n o w n S o u r c e ) a t o r g . a p a c h e . c a t a l i n a . c o r e . C o n t a i n e r B a s e . s t a r t I n t e r n a l ( C o n t a i n e r B a s e . j a v a : 1123 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . S t a n d a r d H o s t . s t a r t I n t e r n a l ( S t a n d a r d H o s t . j a v a : 785 ) a t o r g . a p a c h e . c a t a l i n a . u t i l . L i f e c y c l e B a s e . s t a r t ( L i f e c y c l e B a s e . j a v a : 150 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . C o n t a i n e r B a s e Sync.innerGet(Unknown Source) at java.util.concurrent.FutureTask.get(Unknown Source) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:785) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase Sync.innerGet(UnknownSource)atjava.util.concurrent.FutureTask.get(UnknownSource)atorg.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)atorg.apache.catalina.core.StandardHost.startInternal(StandardHost.java:785)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)atorg.apache.catalina.core.ContainerBaseStartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase S t a r t C h i l d . c a l l ( C o n t a i n e r B a s e . j a v a : 1549 ) a t j a v a . u t i l . c o n c u r r e n t . F u t u r e T a s k StartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask StartChild.call(ContainerBase.java:1549)atjava.util.concurrent.FutureTaskSync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor W o r k e r . r u n T a s k ( U n k n o w n S o u r c e ) a t j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor Worker.runTask(UnknownSource)atjava.util.concurrent.ThreadPoolExecutorWorker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/SimpleLogin]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
… 7 more
Caused by: java.lang.IllegalArgumentException: Invalid * in servlet mapping
at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3217)
at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3192)
at org.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1302)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1323)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:855)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:346)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
… 7 more
2012-8-23 14:28:31 org.apache.catalina.core.ContainerBase startInternal
严重: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
at java.util.concurrent.FutureTask S y n c . i n n e r G e t ( U n k n o w n S o u r c e ) a t j a v a . u t i l . c o n c u r r e n t . F u t u r e T a s k . g e t ( U n k n o w n S o u r c e ) a t o r g . a p a c h e . c a t a l i n a . c o r e . C o n t a i n e r B a s e . s t a r t I n t e r n a l ( C o n t a i n e r B a s e . j a v a : 1123 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . S t a n d a r d E n g i n e . s t a r t I n t e r n a l ( S t a n d a r d E n g i n e . j a v a : 302 ) a t o r g . a p a c h e . c a t a l i n a . u t i l . L i f e c y c l e B a s e . s t a r t ( L i f e c y c l e B a s e . j a v a : 150 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . S t a n d a r d S e r v i c e . s t a r t I n t e r n a l ( S t a n d a r d S e r v i c e . j a v a : 443 ) a t o r g . a p a c h e . c a t a l i n a . u t i l . L i f e c y c l e B a s e . s t a r t ( L i f e c y c l e B a s e . j a v a : 150 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . S t a n d a r d S e r v e r . s t a r t I n t e r n a l ( S t a n d a r d S e r v e r . j a v a : 732 ) a t o r g . a p a c h e . c a t a l i n a . u t i l . L i f e c y c l e B a s e . s t a r t ( L i f e c y c l e B a s e . j a v a : 150 ) a t o r g . a p a c h e . c a t a l i n a . s t a r t u p . C a t a l i n a . s t a r t ( C a t a l i n a . j a v a : 675 ) a t s u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e 0 ( N a t i v e M e t h o d ) a t s u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e ( U n k n o w n S o u r c e ) a t s u n . r e f l e c t . D e l e g a t i n g M e t h o d A c c e s s o r I m p l . i n v o k e ( U n k n o w n S o u r c e ) a t j a v a . l a n g . r e f l e c t . M e t h o d . i n v o k e ( U n k n o w n S o u r c e ) a t o r g . a p a c h e . c a t a l i n a . s t a r t u p . B o o t s t r a p . s t a r t ( B o o t s t r a p . j a v a : 322 ) a t o r g . a p a c h e . c a t a l i n a . s t a r t u p . B o o t s t r a p . m a i n ( B o o t s t r a p . j a v a : 451 ) C a u s e d b y : o r g . a p a c h e . c a t a l i n a . L i f e c y c l e E x c e p t i o n : F a i l e d t o s t a r t c o m p o n e n t [ S t a n d a r d E n g i n e [ C a t a l i n a ] . S t a n d a r d H o s t [ l o c a l h o s t ] ] a t o r g . a p a c h e . c a t a l i n a . u t i l . L i f e c y c l e B a s e . s t a r t ( L i f e c y c l e B a s e . j a v a : 154 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . C o n t a i n e r B a s e Sync.innerGet(Unknown Source) at java.util.concurrent.FutureTask.get(Unknown Source) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:302) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.startup.Catalina.start(Catalina.java:675) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:451) Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.core.ContainerBase Sync.innerGet(UnknownSource)atjava.util.concurrent.FutureTask.get(UnknownSource)atorg.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)atorg.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:302)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)atorg.apache.catalina.core.StandardService.startInternal(StandardService.java:443)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)atorg.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)atorg.apache.catalina.startup.Catalina.start(Catalina.java:675)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:451)Causedby:org.apache.catalina.LifecycleException:Failedtostartcomponent[StandardEngine[Catalina].StandardHost[localhost]]atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)atorg.apache.catalina.core.ContainerBaseStartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase S t a r t C h i l d . c a l l ( C o n t a i n e r B a s e . j a v a : 1549 ) a t j a v a . u t i l . c o n c u r r e n t . F u t u r e T a s k StartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask StartChild.call(ContainerBase.java:1549)atjava.util.concurrent.FutureTaskSync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor W o r k e r . r u n T a s k ( U n k n o w n S o u r c e ) a t j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor Worker.runTask(UnknownSource)atjava.util.concurrent.ThreadPoolExecutorWorker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:785)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
… 7 more
2012-8-23 14:28:31 org.apache.catalina.startup.Catalina start
严重: Catalina.start:
org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.startup.Catalina.start(Catalina.java:675)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:451)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
… 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
… 9 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:302)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
… 11 more
2012-8-23 14:28:31 org.apache.catalina.startup.Catalina start
信息: Server startup in 984 ms

错误原因:
已经发布到tomcat上的某个项目的servlet过滤器配置错误。
如在web.xml下,将过滤规则定为*就是一种错误,需要更正为/*或者其他(但是必须要有/开头,表示当前项目)

  Java知识库 最新文章
计算距离春节还有多长时间
系统开发系列 之WebService(spring框架+ma
springBoot+Cache(自定义有效时间配置)
SpringBoot整合mybatis实现增删改查、分页查
spring教程
SpringBoot+Vue实现美食交流网站的设计与实
虚拟机内存结构以及虚拟机中销毁和新建对象
SpringMVC---原理
小李同学: Java如何按多个字段分组
打印票据--java
上一篇文章      下一篇文章      查看所有文章
加:2022-03-13 21:36:26  更:2022-03-13 21:40:33 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/24 9:59:51-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码