s2sh项目集成后发布到tomcat,启动没有错误。在web.xml中空白处敲一个空格在保存tomcat报错

web.xml文件的写法如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
	xmlns="http://java.sun.com/xml/ns/javaee" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  
  <filter>
  	<filter-name>struts2</filter-name>
  	<filter-class>
  		org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
  	</filter-class>
  </filter>
  <filter-mapping>
  	<filter-name>struts2</filter-name>
  	<url-pattern>/*</url-pattern>
  </filter-mapping>
  
  <context-param>
	<param-name>contextConfigLocation</param-name>
	<param-value>/WEB-INF/applicationContext.xml</param-value>
  </context-param>
  
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <!-- 在此处敲一下回车后保存,tomcat会自动加载。加载后报错,错误如下: -->
</web-app>



错误信息:
2010-8-2 22:04:45 org.apache.catalina.core.AprLifecycleListener init
信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\develop\Java\jdk1.6.0_11\bin;C:\develop\Tomcat\bin
2010-8-2 22:04:45 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2010-8-2 22:04:45 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 450 ms
2010-8-2 22:04:45 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2010-8-2 22:04:45 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.14
2010-8-2 22:04:46 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN No appenders could be found for logger (org.springframework.core.CollectionFactory).
log4j:WARN Please initialize the log4j system properly.
2010-8-2 22:04:56 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2010-8-2 22:05:01 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2010-8-2 22:05:01 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2010-8-2 22:05:01 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/31  config=null
2010-8-2 22:05:01 org.apache.catalina.startup.Catalina start
信息: Server startup in 16029 ms
2010-8-2 22:05:21 org.apache.catalina.startup.HostConfig checkResources
信息: Reloading context [/ydq0301_s2sh_fileupload]
2010-8-2 22:05:21 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.
2010-8-2 22:05:24 org.apache.catalina.loader.WebappClassLoader loadClass
信息: Illegal access: this web application instance has been stopped already.  Could not load java.net.BindException.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1244)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
	at com.mysql.jdbc.CommunicationsException.<init>(CommunicationsException.java:155)
	at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2652)
	at com.mysql.jdbc.MysqlIO.quit(MysqlIO.java:1345)
	at com.mysql.jdbc.Connection.realClose(Connection.java:4784)
	at com.mysql.jdbc.Connection.cleanup(Connection.java:2040)
	at com.mysql.jdbc.Connection.finalize(Connection.java:3296)
	at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
	at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
	at java.lang.ref.Finalizer.access$100(Finalizer.java:14)
	at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)
2010-8-2 22:05:24 org.apache.catalina.loader.WebappClassLoader loadClass
信息: Illegal access: this web application instance has been stopped already.  Could not load com.mysql.jdbc.Messages.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1244)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
	at com.mysql.jdbc.CommunicationsException.<init>(CommunicationsException.java:174)
	at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2652)
	at com.mysql.jdbc.MysqlIO.quit(MysqlIO.java:1345)
	at com.mysql.jdbc.Connection.realClose(Connection.java:4784)
	at com.mysql.jdbc.Connection.cleanup(Connection.java:2040)
	at com.mysql.jdbc.Connection.finalize(Connection.java:3296)
	at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
	at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
	at java.lang.ref.Finalizer.access$100(Finalizer.java:14)
	at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)
log4j:WARN No appenders could be found for logger (org.springframework.core.CollectionFactory).
log4j:WARN Please initialize the log4j system properly.
2010-8-2 22:05:24 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext


问题解决答案如下:

在启动 tomcat ,并发布应用后没有问题,但是如果重新发布就出现如下异常: 

this web application instance has been stopped already.  Could not load java.net.BindException 

this web application instance has been stopped already.  Could not load com.mysql.jdbc 

  

这是由于 MySQL 的 JDBC 驱动放在应用的 WEB-INF\lib 目录下,在重新发布时其加载了两次,故只要将其拷贝到 TOMCAT_HOME%\lib 中即可解决该问题。 

解决这两个异常可以将 MySQL 的驱动文件从 WEB-INF\lib 文件夹中移动到 %TOMCAT_HOME%\lib 中。 

你可能感兴趣的:(java,tomcat,Web,xml,mysql)