Reputation: 479
I have been trying to create a simple maven web based project to be confident about maven. I have added tomcat7 plugin in my pom.xml to use it as a server. But when i started to deploy my war file to tomcat by using
tomcat7:deploy
it is throwing an error as follows,
[INFO] Deploying war to http://127.0.0.1:8080/MavenWeb
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.585s
[INFO] Finished at: Wed Jan 30 16:03:06 IST 2013
[INFO] Final Memory: 9M/24M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.0:deploy (default-cli) on project MavenWeb: Cannot invoke Tomcat manager: Connection to http://127.0.0.1:8080 refused: Connection refused -> [Help 1]
My plugin section in pom.xml is as follows.
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://127.0.0.1:8080/manager/html</url>
<warFile>/home/shebin/Maven Folder/MavenWeb/target/MavenWeb.war</warFile>
<server>TomcatServer</server>
<path>/MavenWeb</path>
<username>tomcat</username>
<password>tomcat</password>
</configuration>
</plugin>
.m2/settings.xml and /home/shebin/apache-maven-3.0.4/conf/settings.xml
<server>
<id>TomcatServer</id>
<username>tomcat</username>
<password>tomcat</password>
</server>
/home/shebin/apache-tomcat-7.0.35/conf/tomcat-users.xml
<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>
I have came through various solution and nothing is working in my way. My Maven version is 3.0.4 and using tomcat7 plugin.
Upvotes: 1
Views: 20242
Reputation: 465
I got this working too thanks to points in this post.. Things I got stuck on were: The POM file - you need a slash on the beginning of the path (or it tried to install it under /manager/ and fails):
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://10.54.17.35:8080/manager/text</url>
<server>LoginForTomcat</server>
<path>/displayService</path>
</configuration>
</plugin>
provide server credentials in ~/.m2/settings.xml:
<servers>
<server>
<id>LoginForTomcat</id>
<username>figgy</username>
<password>passw0rd</password>
</server>
</servers>
On the tomcat server, you need to define manager-script and manager-jmx:
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<user username="figgy" password="passw0rd" roles="manager-gui,manager-script,manager-jmx"/>
Looking over this everything here is in the posts above, posting this to clarify things.
Upvotes: 2
Reputation: 2486
The url in configuration of maven plugin should be <url>http://127.0.0.1:8080/manager/text</url>
which corresponds to the role manager-script
.
Also, it is worth noted that after changing the roles
in {TOMCAT_HOME}/conf/tomcat-users.xml
, you have to restart the tomcat server for reloading the configuration. I know this is a common sense, but my experience told me that some of you may really stuck at here.
Upvotes: 3
Reputation: 101
I ran into the same issue. You'll need to add an extra role to the mix: manager-jmx. So your tomcat-users.xml file should have.
<user username="tomcat" password="tomcat" roles="manager-script, manager-jmx"/>
Upvotes: 2
Reputation: 14054
This error message
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.0:deploy (default-cli) on project MavenWeb: Cannot invoke Tomcat manager: Connection to http://127.0.0.1:8080 refused: Connection refused -> [Help 1]
insinuates this is authentication related. Try and change this
<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>
to
<role rolename="manager-script"/>
<user username="tomcat" password="tomcat" roles="manager-script"/>
Access from the maven plugin will not happen over the browser based admin client :)
Upvotes: 2