简体   繁体   English

通过ANT部署到Tomcat

[英]Deploying to Tomcat by ANT

I'm trying to deploy WAR like in this example https://stackoverflow.com/a/4144674/758661 我正在尝试像此示例一样部署WAR https://stackoverflow.com/a/4144674/758661

DeployTask task = new DeployTask();
  task.setUrl("http://localhost:8080/manager/text");
  task.setUsername("tomcat");
  task.setPassword("s3cret");
  task.setPath("/updater");
  task.setWar(warFile.getAbsolutePath());
  task.execute();

But get an 403 error: 但是出现403错误:

Server returned HTTP response code: 403 for URL: 
http://localhost:8080/manager/text/deploy?path=%2Fupdater

I think it is because "/" has been replaced to "%2F" (password and username are like in tomcat-users.xml) 我认为这是因为“ /”已替换为“%2F”(密码和用户名类似于tomcat-users.xml)

How can I prevent replacing "/" to "%2F"? 如何防止将“ /”替换为“%2F”? Or any other ideas? 还是其他想法? Thx. 谢谢。

The replacement isn't a problem, it's normal for a parameter to be urlencoded. 替换不是问题,对参数进行urlencode编码是正常的。 The server wouldn't be able to receive it if it weren't encoded. 如果未编码,服务器将无法接收它。

And "403" means "forbidden". 并且“ 403”表示“禁止”。

I suppose it's because you have a strange URL. 我想这是因为您有一个奇怪的URL。 Replace 更换

task.setUrl("http://localhost:8080/manager/text");

by 通过

task.setUrl("http://localhost:8080/manager");

I solve it. 我解决了。

In Overview of Tomcat Server in Eclipse (right-click on server -> open) in "Server Locations" I had to choose the secons radio-button "Use Tomcat installation" (by default it set to first "Use workspace metadata". 在“服务器位置”中的Eclipse中的Tomcat服务器概述(右键单击服务器->打开)中,我必须选择secons单选按钮“使用Tomcat安装”(默认情况下,它设置为第一个“使用工作区元数据”)。

Because in default case Tomcat starts without the manager app wich needed in this case. 因为在默认情况下,Tomcat无需在这种情况下所需的管理器应用程序即可启动。

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

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