日期:2014-05-16  浏览次数:20538 次

tomcat启动后,每隔十秒报一个有关编码的MalformedByteSequenceException异常

错误信息:

2012-8-20 15:58:45 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor sinopecc.xml
2012-8-20 15:58:45 org.apache.catalina.startup.HostConfig deployDescriptor
严重: Error deploying configuration descriptor ~$xxxxxxx.xml
com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte x of x-byte UTF-8 sequence.
	at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:684)
	at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:554)
	at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1742)
	at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.arrangeCapacity(XMLEntityScanner.java:1619)
	at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipString(XMLEntityScanner.java:1657)
	at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:193)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:772)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
	at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1626)
	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:631)
	at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
	at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1385)
	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:306)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
	at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1389)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1653)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1662)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1642)
	at java.lang.Thread.run(Thread.java:662)

经过一天的排查,尝试了很多网上的办法,结果都不符合我的情况。

导致我这种情况的原因是:不知何种原因在tomcat6\conf\Catalina\localhost下面莫名其妙地多出了一个隐藏文件(我猜想是因为我曾经用过word编辑我的xml文件,因而word自动备份了一个文件名为~$xxxxx.xml的文件),所以tomcat会每隔10秒扫描这个xml文件并试图解析他,但是它确实一个二进制文件,所以tomcat会抛出一个编码方面的异常。

解决方案:删除tomcat6\conf\Catalina\localhost下面的隐藏文件(可能是系统保护的隐藏文件)