当我尝试使用命令mvn tomcat:deploy
将我的 HelloWorld 项目作为IBM Developerworks上的describeet部署到带有Maven 3的Tomcat 7时,我收到错误Failed to deploy application at context path /server
。< / p>
在列出的应用程序中,我的/服务器出现但无法启动。
我根据base22上的教程修改了我的maven web项目,并在pom.xml中将<url>http://localhost:8080/manager/html</url>
用于Tomcat 7部署,作为loquatic的descibet。
命令:
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 settings.xml
<server>
<id>mytomcat</id>
<username>admin</username>
<password>admin</password>
</server>
答案 0 :(得分:2)
对于Tomcat 7,您需要使用&#34; text&#34; URL。此URL是脚本用于部署的内容。 您正尝试使用&#34; gui&#34; URL。
以下是如何进行设置:
<强> Tomcat的users.xml中强>
<role rolename="manager-script"/>
<user password="script" roles="manager-script" username="script"/>
然后,在您的pom.xml中,将URL设置为:&#34; http:// localhost:8080 / manager / text /&#34;
此外,在您的maven settings.xml中,将您的用户名/密码设置为脚本/脚本。
答案 1 :(得分:2)
我收到此错误,
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
答案 2 :(得分:1)
应用程序已存在于该位置,您需要先取消部署它。
您可以先使用tomcat管理器取消部署,也可以使用
取消部署mvn tomcat:undeploy
或使用以下命令:
mvn package tomcat:redeploy
写下当前实例。
有关详细信息,请查看here
答案 3 :(得分:1)