Tomcat – Cannot invoke Tomcat manager: FAIL – Deployed application at context path but context failed to start

tomcat

I get this error when I try to deploy a Spring application using Tomcat 7 and Maven:

Cannot invoke Tomcat manager: FAIL – Deployed application at context
path /DocumentManagerGui but context failed to start

My settings.xml file for Maven is:

<server>  
    <id>localhost</id>  
    <username>script</username>  
    <password>script</password>  
</server>  

My tomcat-users.xml file is:

<role rolename="manager-gui"/>   
<role rolename="manager-script"/>  
<role rolename="manager-jmx"/>  
<role rolename="manager-status"/>  
<role rolename="admin-gui"/>  
<role rolename="admin-script"/>  

<user username="script" password="script" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>  

My context file is in src directory META-INF folder. The content.xml is:

<?xml version="1.0" encoding="UTF-8"?>   
<Context  antiJARLocking="true" antiResourceLocking="true">

    <WatchedResource>WEB-INF/web.xml</WatchedResource>  

    <Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"  />  

    <Transaction factory="com.atomikos.icatch.jta.UserTransactionFactory" timeout="60" />  

</Context> 

My Tomcat plugin configuration in the POM file is:

<plugins>  
    <plugin>  
        <groupId>org.codehaus.mojo</groupId>  
        <artifactId>tomcat-maven-plugin</artifactId>  
        <configuration>  
            <url>http://localhost:8080/manager/text</url>  
            <path>/DocumentManagerGui</path>  
            <server>localhost</server>  
            <mode>both</mode>  
        </configuration>  
    </plugin>  
</plugins> 

Best Answer

I'd like a list of all of the common issues around this issue, with links to references and well structured tutorials.

I am afraid it is not really possible to assess all the possible problems that may trigger tomcat showing this error because the error is too generic and there is too many common cases that can trigger it. Trying to do this is pretty much like trying to guess what crashed unknown application knowing only the fact that it crashed.

What can be said for sure is that the reason of this error is that something went wrong on the application init phase.

From my practice I can think of couple generic sets of cases:

  1. PermGen Space error thrown on app init (most of the times this is a result of classloader leaks).

  2. Some exception was thrown when handling app init in ServletContextListener implementation (the reason of this might be anything from misconfiguration of some framework to unresolved class dependency).

  3. Something else. Really, there might be misconfiguration/malfunction of tomcat of some sort or tons of other reasons.

The most robust way to deal with this error it to check out:

  1. logs of your application (where you can find your logs depends on how logging is set up in your webapp)

  2. logs of tomcat (usually you can find these in {tomcat dir}/logs)

... to get more info on what caused the error and deal with root of the problem. Trying to solve this problem in other ways is more like fighting windmills.

Hope this will help.

Related Topic