无法部署WAR文件。无法启动组件[]

时间:2014-10-13 20:18:53

标签: java jsp tomcat

我目前在将一个WAR文件部署到我的Tomcat7服务器时遇到问题(我是带有java的web dev新手)。在Eclipse中一切都很好但是当我生成一个WAR文件并将其部署到服务器时,我得到以下错误。 "无法启动组件[]"下面是日志转储。

Caused by: org.apache.catalina.LifecycleException: Failed to process either the global, per-host or context-specific context.xml file therefore the [] Context cannot be started.
    at org.apache.catalina.startup.FailedContext.startInternal(FailedContext.java:158)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 31 more
Oct 13, 2014 7:22:56 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'mysite.com'
Oct 13, 2014 7:23:11 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLHostManager: list: Listing hosts for engine [Catalina]
Oct 13, 2014 8:05:48 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'mysite.com'
Oct 13, 2014 8:06:08 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: start: Starting web application '/'
Oct 13, 2014 8:06:08 PM org.apache.catalina.core.ApplicationContext log
SEVERE: FAIL - Application at context path / could not be started
org.apache.catalina.LifecycleException: Failed to start component []
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1291)
    at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:694)
    at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:217)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at         org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:213)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:610)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:190)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
    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)
Caused by: org.apache.catalina.LifecycleException: Failed to process either the global, per-host or context-specific context.xml file therefore the [] Context cannot be started.
    at org.apache.catalina.startup.FailedContext.startInternal(FailedContext.java:158)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 31 more

当我删除/META-INF/context.xml文件时,它似乎加载得很好,但是我无法使用我的数据库连接。

我的context.xml如下。

<context>

    <Resource name="jdbc/mysitedb" auth="Container" 
        maxActive="100" maxIdle="30" maxWait="10000" 
        username="myusername" password="mypassword" 
        driverClassName="com.mysql.jdbc.Driver" 
        url="jdbc:mysql://www.mysite.com/mysitedb?autoReconnect=true" 
        logAbandoned="true" removeAbandoned="true" 
        removeAbandonedTimeout="60" type="javax.sql.DataSource" />

</context>  

我是JSP的新手,所以非常感谢任何帮助。

1 个答案:

答案 0 :(得分:6)

如果那真的是你的完整context.xml,你需要将它包装在Context元素中:

<Context>
  <Resource name="jdbc/mysitedb" auth="Container" 
    maxActive="100" maxIdle="30" maxWait="10000" 
    username="myusername" password="mypassword" 
    driverClassName="com.mysql.jdbc.Driver" 
    url="jdbc:mysql://www.mysite.com/mysitedb?autoReconnect=true" 
    logAbandoned="true" removeAbandoned="true" 
    removeAbandonedTimeout="60" type="javax.sql.DataSource" />
</Context>

您的Tomcat正在尝试加载未命名的组件。可能是那个破坏的context.xml。对于损坏的web.xml,您可能会遇到类似的错误。