0

I created an API which I deployed to Tomcat Server. During development, I would start the application from Eclipse and test the end point using Postman. From Eclipse, the application runs fine. I would see my bot (created with Selenium WebDriver) starting, hitting the targeted pages, clicking the scripted elements, and finishing the process.

I modified the POM to build a WAR file which I manually deployed using Tomcat Manager App page. The WAR deployed and it is running fine as far as I can tell. I decided to run the same test using Postman; obviously changing "localhost" to the actual IP address and port. Unfortunately, I get this HTTP 405 error and I do not know why. I assume that something needs to be configured in Tomcat but I have no clue as to what specifically I need to do.

I configured Tomcat according to this and still no luck: http://www.codereye.com/2010/12/configure-tomcat-to-accept-http-put.html

2
  • Need more details on the 405 error - looks like the call might be faulty. Call and response messages would also help with debugging. Commented Mar 22, 2022 at 11:57
  • I have no more details to give. Commented Mar 22, 2022 at 12:10

1 Answer 1

0

Tomcat by default is not enabled for HTTP PUT command.

I had to configure Tomcat by modifying the web.xml and the tomcat-users.xml files.

Changes to web.xml file

  1. Needed to add readonly=false parameter
<init-param> <param-name>readonly</param-name> <param-value>false</param-value> </init-param> 
  1. Needed to add a security constraint for the role
<security-constraint> <web-resource-collection> <web-resource-name>Demo App</web-resource-name> <url-pattern>/*</url-pattern> <http-method>PUT</http-method> </web-resource-collection> <auth-constraint> <role-name>#####</role-name> </auth-constraint> </security-constraint> 

Changes to the tomcat-users.xml file

  1. Needed to add a user and role to match the added security constraint
<user name="#####" password="#####" roles="#####" /> 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.