0
votes

I am trying to deploy my maven application on tomcat using

mvn tomcat:deploy

and getting this error

  [ERROR] BUILD ERROR
  [INFO] ------------------------------------------------------------------------
  [INFO] Cannot invoke Tomcat manager

In maven2/conf/setting.xml I have added

  <server>
   <id>TomcatServer</id>
   <username>tomcat</username>
   <password>tomcat</password>
  </server>

Inside tomcat-users.xml I have added

   <role rolename="admin"/>
   <user username="tomcat" password="tomcat" roles="tomcat,manager-gui,admin"/>

Inside my pom.xml I put

    <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <url>http://127.0.0.1:8080/manager/text</url>
                <server>TomcatServer</server>
                <path>/myproject</path>                 
            </configuration>
        </plugin>

Even I tried to deploy the war using tomcat-manager. It deployes but does not start and when I start the the war it says

     FAIL - Application at context path /mywar.net could not be started
FAIL - Encountered exception org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/mywar.net]]

please let me know if you need more detail

1
Can you try running mvn tomcat6:run or mvn tomcat7:run tomcat.apache.org/maven-plugin-2.2/run-mojo-features.htmlprashanth
Hi prashanth, I tried above commands and getting build error with The plugin 'org.apache.maven.plugins:maven-tomcat7-plugin' does not exist or no valid version could be foundHarry
You get this error because tomcat user doesn't contains a manager-script role. Try to add this role and rerun the command tomcat:deploySkizzo
maven-tomcat7-plugin does not exist means, that maven is unable to download from the repository. See these links stackoverflow.com/questions/3714080/tomcat-7-maven-plugin and georgik.sinusgear.com/2011/11/13/apache-tomcat-7-maven-pluginprashanth
Hi Skizzo, I added manager-script and run mvn tomcat7:run then its giving me error INFO: Starting Servlet Engine: Apache Tomcat/6.0.29 Apr 08, 2014 10:34:22 PM org.apache.catalina.core.StandardContext filterStart SEVERE: Exception starting filter springSecurityFilterChain.. I think its trying to run tomcat 6 instanceHarry

1 Answers

1
votes

The user in your tomcat-users.xml should have manager-script and manager-jmx roles. It also should not have manager-gui role, as this is for users that will use the tomcat manager website, instead of a script that will deploy automatically.