简体   繁体   中英

maven tomcat7 deployment Error 403

Hello

I know kind of this question was put into here several times already and I read many of the answers, unfortunately, nothing worked or me so far.

What am I using:

  • Windows7
  • Tomcat 7
  • Maven - plugin 'tomcat7-maven-plugin'
  • Application has java in backend, frontend javascript

What is working so far: I can compile, build, ..., deploy the war manually and the webapp runs fine in localhost.

What I try now:

Build and automatically deploy the app with Maven. Via the tomcat-plugin I planned to deploy the generated war file automatically. I hope this thought is not already wrong; if so, please let me know.

Ok let me list what I have set in the different files and what I have executed.

Settings.xml of maven:

<server>
  <id>TomcatServer</id>
  <username>testuser</username>
  <password>testpw</password>
</server>

tomcat-users.xml:

I decided to take all, so that no role can be missed and lead to a problem. I also tried with just using "manager-gui" and with "manager-gui and admin".

<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="testuser" password="passwd" roles="manager-gui, manager-script, manager-jmx, manager-status, admin-gui, admin-script"/>

pom.xml:

...
<modelVersion>4.0.0</modelVersion>
<groupId>com.mr</groupId>
<artifactId>myWebapp</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>my Web App</name>
<url>http://maven.apache.org</url>
<dependencies>

 ...
<plugins>
        <plugin>
             <groupId>org.apache.tomcat.maven</groupId>
             <artifactId>tomcat7-maven-plugin</artifactId>
             <version>2.0</version>
             <configuration>
                 <url>http://LuklHost:port/manager</url>
                 <server>TomcatServer</server>
                 <username>testuser</username>
                 <password>passwd</password>
                 <path>/myWebapp</path>
             </configuration>
         </plugin>
</plugins>

Step to deploy:

In powershell (opened with admin-rights)

mvn tomcat:deploy

leads to following 403 error-message: (localhost needed to be "deleted")

    [INFO] Deploying war to http://localhost:8080/TripleDictionary
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.821s
[INFO] Finished at: Sat Apr 12 13:59:37 CEST 2014
[INFO] Final Memory: 18M/223M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project TripleDictionary: Ca
nnot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/deploy?path=%2FTri
pleDictionary&war= -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:depl
oy (default-cli) on project TripleDictionary: Cannot invoke Tomcat manager
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot invoke Tomcat manager
        at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:149)
        at org.codehaus.mojo.tomcat.AbstractWarCatalinaMojo.execute(AbstractWarCatalinaMojo.java:70)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 19 more
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/deploy?path=%2
FTripleDictionary&war=
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1625)
        at org.codehaus.mojo.tomcat.TomcatManager.invoke(TomcatManager.java:604)
        at org.codehaus.mojo.tomcat.TomcatManager.deployImpl(TomcatManager.java:662)
        at org.codehaus.mojo.tomcat.TomcatManager.deploy(TomcatManager.java:295)
        at org.codehaus.mojo.tomcat.AbstractDeployWarMojo.deployWar(AbstractDeployWarMojo.java:85)
        at org.codehaus.mojo.tomcat.AbstractDeployMojo.invokeManager(AbstractDeployMojo.java:85)
        at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:141)
        ... 22 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Question:

Why do I get this error? And of course how can I fix it?

Actually I really cannot put it exact, because I think I kind of checked everything, even what folder has which rights.

Hope for ideas and help.

Thanks in advance, Meru

I want to add thee solution as an 'answer', due to I searched for it hell of long and maybe somebody else does not need to spend that much time on it then. As I already have written the comment 'text' is needed to be appended to the url inside the plugins-part of the plugins in the pom.xml. Let me share what I got now:

maven>conf>settings.xml

<server>
   <id>TomcatServer</id>
   <username>testuser</username>
   <password>testpw</password>
</server>

tomcat>conf>tomcat-users.xml

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

But the most important I think was changing the URL, which also is the answer to my question.

pom.xml:

<plugin>
      <groupId>org.apache.tomcat.maven</groupId>
      <artifactId>tomcat7-maven-plugin</artifactId>
      <version>2.0</version>                 
      <configuration>
            <url>http://localhost:8080/manager/text</url>
            <server>TomcatServer</server>
            <username>testuser</username>
            <password>passwd</password>
            <path>/myWebApp</path>
       </configuration>
   </plugin>

command in powershell

mvn tomcat7:deploy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM