Java 在试图用maven向tomcat部署战争时得到403分
已经在这里找到了很多条目来修复我的问题,但都不起作用。我不知道我做错了什么。。。我总是在tomcat上收到403。 我使用的是ApacheTomcat版本7.0.32 输出:Java 在试图用maven向tomcat部署战争时得到403分,java,maven,tomcat,deployment,Java,Maven,Tomcat,Deployment,已经在这里找到了很多条目来修复我的问题,但都不起作用。我不知道我做错了什么。。。我总是在tomcat上收到403。 我使用的是ApacheTomcat版本7.0.32 输出: [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Homeserver 1.0 [INFO] -----
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Homeserver 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> tomcat-maven-plugin:1.1:deploy (default-cli) @ homeserver >>>
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ homeserver ---
[WARNING] Using platform encoding (ISO-8859-1 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/pi/git/homeserver/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ homeserver ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.3:testResources (default-testResources) @ homeserver ---
[WARNING] Using platform encoding (ISO-8859-1 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/pi/git/homeserver/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ homeserver ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ homeserver ---
[INFO] Surefire report directory: /home/pi/Maven/homeserver/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-war-plugin:2.4:war (default-war) @ homeserver ---
[INFO] Packaging webapp
[INFO] Assembling webapp [homeserver] in [/home/pi/Maven/homeserver/homeserver-1.0]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/pi/git/homeserver/WebContent]
[INFO] Webapp assembled in [1759 msecs]
[INFO] Building war: /home/pi/Maven/homeserver/homeserver-1.0.war
[INFO]
[INFO] <<< tomcat-maven-plugin:1.1:deploy (default-cli) @ homeserver <<<
[INFO]
[INFO] --- tomcat-maven-plugin:1.1:deploy (default-cli) @ homeserver ---
[INFO] Deploying war to http://localhost:8080/homeserver
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:41.489s
[INFO] Finished at: Fri Sep 13 18:19:11 CEST 2013
[INFO] Final Memory: 8M/20M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project homeserver: Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/deploy?path=%2Fhomeserver&war= -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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中使用了
<url>http://localhost:8080/manager/html</url>
因此,它似乎与pom有关…根据,您可能不需要定义url作为默认(http://localhost:8080/manager
)应该是正确的
更重要的是,pom.xmlserver
字段需要使用与settings.xmlserver>id
字段相同的服务器名称才能使用登录凭据
另外,如果您还没有安装,您将需要安装Tomcat的管理器部分,因为它不是默认安装的一部分。(运行:apt get install tomcat7 admin)首先,
http://localhost:8080/manager
是默认的tomcat管理应用程序;因此,您可能不想与您的Web应用程序发生冲突
请点击此处:
使用Manager web应用程序有三种方法
作为在浏览器中使用的具有用户界面的应用程序。在这里
是一个示例URL,您可以在其中用网站替换localhost
主机名:http://localhost/manager/html/
第二,为了修复URL,您不需要在pom中提及URL。通常,部署后,URL为:
http://<your_server_name>/<webapp-name>/<welcome page>
http:////
其中webapp name通常是不带扩展名的war文件名,欢迎页面是web.xml中定义的任何页面。在没有欢迎文件名的情况下,您需要提到资源/URL以及应用程序主目录的相对路径 我找到了解决办法。我用错了球。应该是正确的 mvn tomcat7:deploy而不是tomcat:deploy () 通过偏离这个目标,maven没有接受我的tomcat7 maven插件 只是RTFM
感谢您的帮助对我来说,解决方案是在URL末尾设置不带/text的URL
<url>http://localhost:8081/manager</url>
http://localhost:8081/manager
注意,我在这里使用的是8081端口。谢谢您的回复。我做了你提到的所有步骤,但仍然面临同样的问题。当我添加到我的帖子中时,似乎没有从pom.xml文件中读取配置。
[DEBUG] Configuring mojo 'org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy' with basic configurator -->
[DEBUG] (f) charset = ISO-8859-1
[DEBUG] (f) contextFile = /home/pi/Maven/homeserver/homeserver-1.0/META-INF/context.xml
[DEBUG] (f) ignorePackaging = false
[DEBUG] (f) mode = war
[DEBUG] (f) packaging = war
[DEBUG] (f) path = /homeserver
[DEBUG] (f) update = false
[DEBUG] (f) url = http://localhost:8080/manager
[DEBUG] (f) version = 1.1
[DEBUG] (f) warFile = /home/pi/Maven/homeserver/homeserver-1.0.war
[DEBUG] -- end configuration --
[INFO] Deploying war to http://localhost:8080/homeserver
[DEBUG] No server specified for authentication - using defaults
<url>http://localhost:8080/manager/html</url>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<server>TomcatServer</server>
<url>http://192.168.34.252:8080/manager/text</url>
<path>/mycontext</path>
</configuration>
</plugin>
[DEBUG] Configuring mojo 'org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy' with basic configurator -->
[DEBUG] (f) charset = ISO-8859-1
[DEBUG] (f) contextFile = C:\temp\homeserver\homeserver-1.0\META-INF\context.xml
[DEBUG] (f) ignorePackaging = false
[DEBUG] (f) mode = war
[DEBUG] (f) packaging = war
[DEBUG] (f) path = /homeserver
[DEBUG] (f) update = false
[DEBUG] (f) url = http://localhost:8080/manager
[DEBUG] (f) version = 1.1
[DEBUG] (f) warFile = C:\temp\homeserver\homeserver-1.0.war
[DEBUG] -- end configuration --
[INFO] Deploying war to http://localhost:8080/homeserver
[DEBUG] No server specified for authentication - using defaults
http://<your_server_name>/<webapp-name>/<welcome page>
<url>http://localhost:8081/manager</url>