Reputation: 1678
I'm posting this after weeks of effort. I try and try because I felt guilty of posting this because there are thread similar to this. But still I'm getting slightly different error. So what I have is a very simple spring(no need to be spring of course bcz problem is with maven) application with maven.
This is plugins section from my pom.
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://localhost:8080/manager</url>
<username>tomcat</username>
<password>s3cret</password>
<path>/Test</path>
<port>8080</port>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
Earlier I have problems with maven tomcat plugin not working with tomcat 7 etc etc but now with "tomcat7-maven-plugin" there are solved. I'm using 'http://localhost:8080/manager
' as the URL. For almost all threads about this maven tomcat compiler plugin are about build failure. But my build succeed(I run as tomcat7:deploy). Problem is tomcat is replying
tomcatManager status code:403, ReasonPhrase:Forbidden
along with the html that we see when we got a authentication failure on browser. The same code works fine under my Linux box. I try different scenarios of using server element in settings.xml which is inside .m2 and inside maven_home/conf etc. Still not working.
As I figure out maven cannot authenticate tomcat. username and password is find and I can log in using GUI. So expecting a help here.
p.s - my tomcat-users.xml fiel
<role rolename="manager-gui" />
<user username="tomcat" password="s3cret" roles="manager-gui"/>
Upvotes: 9
Views: 6265
Reputation: 675
After trying several things the following configuration worked for me. Please give it a try
tomcat-users.xml
<role rolename="manager-gui"/>
<user password="tomcat" roles="manager-gui" username="tomcat"/>
pom.xml
<!-- Maven Tomcat Plugin -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<url>http://localhost:8080/manager/html</url>
<username>tomcat</username>
<password>tomcat</password>
<update>true</update>
<path>/Test</path>
</configuration>
</plugin>
Upvotes: 0
Reputation: 1
Sometimes when all from the above criteria are matched and You still get the error there is a chance that You are using mvn tomat7:deploy command. And at the same time the server is maintained by Eclipse wchich dosen't go heand in heand. You could stop the server in Eclipse IDE and than try again with the mvn command.
Upvotes: 0
Reputation: 1678
Today I tried same application with Tomcat 7. I need to change plugin artifactId to "tomcat7-maven-plugin". And I have to change the url as "http://localhost:8080/manager
". After doing these changes deploy works fine. Also I figure out that maven read settings.xml inside .m2 folder. There is also a settings.xml file inside mvaen_home/conf but it is not the one it read. Another thing I found is there is no undeploy for tomcat7 for tomcat6 there was a undeploy.
Upvotes: 0
Reputation: 1678
I could get tomcat deploy work but environment is different. So anyway I'm going to tell how I could do it since may be It'll help someone.
In this case I have tomcat6 as my web container and I'm using eclipse Helios as the IDE.
First of all I have haven environmental variables set as described in the maven web site(Maven download installation help). Which means environmental variables M2_HOME and M2 are set and M2 is in my path variable.
Then in eclipse I have maven installation folder, local repository(In case if it is not default) and settings.xml file correctly. (These setting are in Window -> Preferences -> Maven -> Installations and User settings)
In tomcat_home\conf\tomcat-users.xml I have created user with the role manager-script.(Note that here I use tomcat6)
< role rolename="manager-script"/>
< user password="s3cret" roles="manager-script" username="tomcat"/>
In POM.xml I have maven tomcat plugin defined as follows.
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://localhost:8080/manager</url>
<server>TomcatServer</server>
</configuration>
</plugin>
Then on eclipse Run Configurations I create a configuration to run goal "tomcat6:deploy" ( This site from apache says tomcat:deploy is the goal but it didn't work).
Which runs perfectly and deploy my app to the container. Once it is deployed app need to be undeplyed using "tomcat6:undeploy" before deploying again.
I'm not a expert about this and still I have doubts on some facts. But since I saw this question in lots of places I thought this will help someone it the same problem.
Thank you
Upvotes: 0
Reputation: 2310
Url is not correct try with :
<url>http://localhost:8080/manager/text</url>
what is the content of tomcat-users.xml file. Did you correctly set permissions ? See http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html
Upvotes: 10