Tomcat deploy script returns 405

泪湿孤枕 提交于 2020-05-17 07:32:22

问题


I am setting up Jenkins to learn how to implement the automated deployment of a maven project in tomcat.

tomcat-users.xml has the roles and username defined, the ones of interest

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

I have set up web.xml to allow the PUT method

<init-param>
  <param-name>readonly</param-name>
  <param-value>false</param-value>
</init-param>      

and even tried to setup the manager application to allow the PUT method for /text/* pattern

<security-constraint>
  <web-resource-collection>
    <web-resource-name>Text Manager interface (for scripts)</web-resource-name>
      <url-pattern>/text/*</url-pattern>
      <http-method>PUT</http-method>
    </web-resource-collection>
   <auth-constraint>
     <role-name>manager-script</role-name>
  </auth-constraint>
</security-constraint>

But when I request the manager deploy script from the command line I get a 405 response.

curl -u jenkins:jenkins -F filedata=target/**.war "http://localhost:8080/manager/text/deploy?path=/devops&update=true"

This is the output:

<!doctype html><html lang="es"><head><title>Estado HTTP 405 ÔÇô Method Not Allowed</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>Estado HTTP 405 ÔÇô Method Not Allowed</h1><hr class="line" /><p><b>Tipo</b> Informe de estado</p><p><b>mensaje</b> El Metodo HTTP POST no est├í soportado por esta URL</p><p><b>descripci├│n</b> El m├®todo HTTP especificado no est├í permitido para el recurso requerido.</p><hr class="line" /><h3>Apache Tomcat/8.5.42</h3></body></html>

which is an HTML response saying the HTTP POST method is not supported for that route.

I am using -F filedata=target/**.war because if I use -T option under windows the war file can't be opened

curl -v -u jenkins:jenkins -T target/**.war "http://localhost:8080/manager/text/deploy?path=/devops&update=true"

output: curl: Can't open 'target/**.war'!

And seems request Tomcat with filedata option is a POST method which it is not allowed. How can I ensure the POST verb is enabled for manager application?


回答1:


I have the same version (8.5.x) in several environments.

I just add permissions and user in xml tomcat files following these configurations:

https://stackoverflow.com/a/40722537/3957754

Then I was able to deploy war files from anywhere.

It was no necessary to modify the web.xml or the manager.

Also check this link to review how deploy wars to the tomcat and get the status:

https://stackoverflow.com/a/54292858/3957754



来源:https://stackoverflow.com/questions/56812981/tomcat-deploy-script-returns-405

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!