繁体   English   中英

Eclipse WebApp 部署在 Maven 和 Tomcat 导致错误:“无法在上下文路径部署应用程序”

[英]Eclipse WebApp deploying over Maven with Tomcat results in Error: 'Failed to deploy application at context path'

当我尝试按照IBM Developerworks中的描述将我的HelloWorld项目部署到 Tomcat 7 和 Maven 3 时,使用命令mvn tomcat:deploy Failed to deploy application at context path /server

在列出的应用程序中,我的 /server 出现但无法启动。

I modified my maven web project according to the tutorial at base22 and applied the fix <url>http://localhost:8080/manager/html</url> for Tomcat 7 deployment in the pom.xml as descibet at loquatic .

命令:

mvn tomcat:deploy

错误:

[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project server: Cannot
invoke Tomcat manager: FAIL - Failed to deploy application at context path /server -> [Help 1]

Tomcat tomcat-users.xml

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

项目 web.xml

<servlet>
  <servlet-name>Jersey REST Service</servlet-name>
<servlet-class>
  com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
  <init-param>
    <param-name>com.sun.jersey.config.property.packages</param-name>
    <param-value>sample.hello.resources</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
  <servlet-name>Jersey REST Service</servlet-name>
  <url-pattern>/rest/*</url-pattern>
</servlet-mapping>

-e 的错误:

PS C:\Users\Dom\work\server> mvn tomcat:deploy -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.elexess:server:war:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:tomcat-maven-plugin is missing. @ line 58, column 18
[WARNING] 'repositories.repository.layout' for maven-repository.java.net uses the unsupported value 'legacy', artifact r
esolution might fail. @ line 52, column 14
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building server Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> tomcat-maven-plugin:1.1:deploy (default-cli) @ server >>>
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ server ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ server ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ server ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\Dom\work\server\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ server ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.7.2:test (default-test) @ server ---
[INFO] Surefire report directory: C:\Users\Dom\work\server\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
There are no tests to run.

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ server ---
[INFO] Packaging webapp
[INFO] Assembling webapp [server] in [C:\Users\Dom\work\server\target\server]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\Users\Dom\work\server\src\main\webapp]
[INFO] Webapp assembled in [85 msecs]
[INFO] Building war: C:\Users\Dom\work\server\target\server.war
[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored
(webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true')
[INFO]
[INFO] <<< tomcat-maven-plugin:1.1:deploy (default-cli) @ server <<<
[INFO]
[INFO] --- tomcat-maven-plugin:1.1:deploy (default-cli) @ server ---
[INFO] Deploying war to http://localhost:8080/server
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.017s
[INFO] Finished at: Tue Jun 14 08:00:14 CEST 2011
[INFO] Final Memory: 8M/164M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project server: Cannot
invoke Tomcat manager: FAIL - Failed to deploy application at context path /server -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1
:deploy (default-cli) on project server: Cannot invoke Tomcat manager: FAIL - Failed to deploy application at context pa
th /server

        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
        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:319)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot invoke Tomcat manager: FAIL - Failed to deploy applica
tion at context path /server

        at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:145)
        at org.codehaus.mojo.tomcat.AbstractWarCatalinaMojo.execute(AbstractWarCatalinaMojo.java:70)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        ... 19 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

项目 pom.xml

<build>
        <finalName>server</finalName>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <configuration>
                         <url>http://localhost:8080/manager/html</url>
                         <server>mytomcat</server>
                         <path>/${project.build.finalName}</path>
                </configuration>
            </plugin>
        </plugins>
    </build>

Maven 设置。xml

<server>
        <id>mytomcat</id>
        <username>admin</username>
        <password>admin</password>
</server>

我得到这个错误,

  Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project projectname: 
Cannot invoke Tomcat manager: FAIL - Application already exists at path /path

然后我将配置从mvn tomcat:deploy替换为mvn tomcat:redeploy

对于 Tomcat 7,您需要使用“文本”URL 进行部署。 这个 URL 是脚本用来部署的。 您正在尝试使用“gui”URL 进行部署。

设置方法如下:

tomcat-users.xml

<role rolename="manager-script"/>
<user password="script" roles="manager-script" username="script"/>

然后,在您的 pom.xml 中,您将 URL 设置为:“http://localhost:8080/manager/text/”

此外,在您的 maven settings.xml 中,将您的用户名/密码设置为脚本/脚本。

该应用程序已存在于该位置,您需要先取消部署它。

您可以先使用 tomcat 管理器或通过 maven 使用

mvn tomcat:undeploy

或使用以下命令:

mvn package tomcat:redeploy

覆盖当前实例。

欲了解更多信息,请看这里

tomcat maven 插件使用页面说

默认的 Tomcat 管理器 URL 是http://localhost:8080/manager

我认为您必须从配置中删除/html部分。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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