欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

Tomcat常见异常及解决方案代码实例

程序员文章站 2022-06-19 08:00:44
公司项目,开发语言为java,中间件为tomcat,运行过程中,从tomcat出现了一些异常,现将异常及解决办法记录如下,仅供参考。(不断在补充中.......)异常一:1、日志内容org.apach...

公司项目,开发语言为java,中间件为tomcat,运行过程中,从tomcat出现了一些异常,现将异常及解决办法记录如下,仅供参考。(不断在补充中.......)

异常一:

1、日志内容

org.apache.coyote.http11.abstracthttp11processor.process error parsing http request header
note: further occurrences of http header parsing errors will be logged at debug level.
java.lang.illegalargumentexception: invalid character found in method name. http method names must be tokens
at org.apache.coyote.http11.abstractnioinputbuffer.parserequestline(abstractnioinputbuffer.java:233)
at org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1017)
at org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:684)
at org.apache.tomcat.util.net.nioendpoint$socketprocessor.dorun(nioendpoint.java:1520)
at org.apache.tomcat.util.net.nioendpoint$socketprocessor.run(nioendpoint.java:1476)
at java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145)
at java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615)
at org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61)
at java.lang.thread.run(thread.java:745)

2、解决办法

在tomcat安装文件夹的 conf/catalina.properties 中最后添加一行:

org.apache.tomcat.util.buf.udecoder.allow_encoded_slash=true

异常二:

1、日志内容

com.alibaba.druid.stat.druidstatservice]unregister mbean error
javax.management.instancenotfoundexception: com.alibaba.druid:type=druidstatservice
	at com.sun.jmx.interceptor.defaultmbeanserverinterceptor.getmbean(defaultmbeanserverinterceptor.java:1095)
	at com.sun.jmx.interceptor.defaultmbeanserverinterceptor.exclusiveunregistermbean(defaultmbeanserverinterceptor.java:427)
	at com.sun.jmx.interceptor.defaultmbeanserverinterceptor.unregistermbean(defaultmbeanserverinterceptor.java:415)
	at com.sun.jmx.mbeanserver.jmxmbeanserver.unregistermbean(jmxmbeanserver.java:546)
	at com.alibaba.druid.stat.druidstatservice.unregistermbean(druidstatservice.java:374)
	at com.alibaba.druid.stat.druiddatasourcestatmanager.removedatasource(druiddatasourcestatmanager.java:202)
	at com.alibaba.druid.pool.druiddatasource$2.run(druiddatasource.java:1479)
	at java.security.accesscontroller.doprivileged(native method)
	at com.alibaba.druid.pool.druiddatasource.unregistermbean(druiddatasource.java:1475)
	at com.alibaba.druid.pool.druiddatasource.close(druiddatasource.java:1434)
	at sun.reflect.nativemethodaccessorimpl.invoke0(native method)
	at sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57)
	at sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)
	at java.lang.reflect.method.invoke(method.java:606)
	at org.springframework.beans.factory.support.disposablebeanadapter.invokecustomdestroymethod(disposablebeanadapter.java:354)
	at org.springframework.beans.factory.support.disposablebeanadapter.destroy(disposablebeanadapter.java:277)
	at org.springframework.beans.factory.support.defaultsingletonbeanregistry.destroybean(defaultsingletonbeanregistry.java:578)
	at org.springframework.beans.factory.support.defaultsingletonbeanregistry.destroysingleton(defaultsingletonbeanregistry.java:554)
	at org.springframework.beans.factory.support.defaultlistablebeanfactory.destroysingleton(defaultlistablebeanfactory.java:972)
	at org.springframework.beans.factory.support.defaultsingletonbeanregistry.destroysingletons(defaultsingletonbeanregistry.java:523)
	at org.springframework.beans.factory.support.defaultlistablebeanfactory.destroysingletons(defaultlistablebeanfactory.java:979)
	at org.springframework.context.support.abstractapplicationcontext.destroybeans(abstractapplicationcontext.java:1006)
	at org.springframework.context.support.abstractapplicationcontext.doclose(abstractapplicationcontext.java:982)
	at org.springframework.context.support.abstractapplicationcontext.close(abstractapplicationcontext.java:934)
	at org.springframework.web.context.contextloader.closewebapplicationcontext(contextloader.java:583)
	at org.springframework.web.context.contextloaderlistener.contextdestroyed(contextloaderlistener.java:116)
	at org.apache.catalina.core.standardcontext.listenerstop(standardcontext.java:4900)
	at org.apache.catalina.core.standardcontext.stopinternal(standardcontext.java:5537)
	at org.apache.catalina.util.lifecyclebase.stop(lifecyclebase.java:221)
	at org.apache.catalina.core.containerbase$stopchild.call(containerbase.java:1424)
	at org.apache.catalina.core.containerbase$stopchild.call(containerbase.java:1413)
	at java.util.concurrent.futuretask.run(futuretask.java:262)
	at java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145)
	at java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615)
	at java.lang.thread.run(thread.java:745)

2、解决办法

修改tomcat的bin目录下的catalina.sh文件,在# os specific support. $var _must_ be set to either true or false.与cygwin=false之间加上java_opts="-ddruid.registertosysproperty=true"

异常三:

1、日志内容

 

info [http-nio-80-exec-16] org.apache.coyote.http11.abstracthttp11processor.process error parsing http request header
 note: further occurrences of http header parsing errors will be logged at debug level.
 java.lang.illegalargumentexception: invalid character found in method name. http method names must be tokens
	at org.apache.coyote.http11.abstractnioinputbuffer.parserequestline(abstractnioinputbuffer.java:236)
	at org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1065)
	at org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:684)
	at org.apache.tomcat.util.net.nioendpoint$socketprocessor.dorun(nioendpoint.java:1539)
	at org.apache.tomcat.util.net.nioendpoint$socketprocessor.run(nioendpoint.java:1495)
	at java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145)
	at java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615)
	at org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61)
	at java.lang.thread.run(thread.java:745)

2、解决办法

修改tomcat安装文件夹的 conf/server.xml,在 <connector port="8080" protocol="http/1.1" connectiontimeout="20000" maxhttpheadersize ="10240" redirectport="8443" />中,maxhttpheadersize的默认值是8*1024,你只需要调成你需要的值就好了。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

相关标签: Tomcat 异常