0

So ive been following the following guide as to how to get maven tomcat7 and cucumber up and running together to run my integration tests.

Integration tests with maven and tomcat

When I run mvn clean install my tests comeback with a 404 not found all the time?!

My entire code is here

What am i doing wrong? I dont understand having tried everything... ?!

Matt
  • 2,713
  • 5
  • 27
  • 35

2 Answers2

1

The issue was down to tomcat7-maven-plugin 2.2, used version 2.0 and it works fine,...

Matt
  • 2,713
  • 5
  • 27
  • 35
0

404 means that's a client error. Your server is running and responding with that HTTP code to tell you that you did something wrong. Most commonly the error is a wrong path in the URL. Your log say that your server is up and running at http://localhost:8099/foo. Your test tries to access http://localhost:8099/foo/test, which seems to be not available. Are you sure the path is a defined resource? Did you set some file extension on the resource, maybe? Or maybe you have set wrong request headers or something. It's hard to say without seeing the code. For debugging's sake you could run the server standalone and issue HTTP methods on the resources using a REST testing tool or your browser.

Hubert Grzeskowiak
  • 15,137
  • 5
  • 57
  • 74
  • I've booted the server standalone and the /foo/test page responds as expected, i dont understand why it wont be able to route to /foo/test. https://gist.github.com/anonymous/84a046f6339c3c3655aa8e04bb80da7f – Matt Feb 08 '17 at 13:32
  • Wait, `/foo.test` or `/foo/test`? – Hubert Grzeskowiak Feb 08 '17 at 13:33
  • /foo/test is what ive tried in my browser and returns back hello world as per the gist – Matt Feb 08 '17 at 13:36
  • I've updated the original question with a copy of my pom – Matt Feb 08 '17 at 13:48
  • I've just created another gist with my entire files, are you able to give it a look and see if you can spot what i am doing wrong @Hubert – Matt Feb 08 '17 at 16:31
  • I don't have time to go into details, but you might want to test your project piece by piece. E.g. test starting of the server by maven, then test the integration tests against a previously started server etc. Also: Not sure it's an error, but in your pom.xml you have a weird tomcat URL with port and path defined, despite these values being set separately. – Hubert Grzeskowiak Feb 08 '17 at 16:40
  • I have started the server, then ran the integration tests and they run as expected, with 200's. Its just when using the tomcat7-maven-plugin its bring back 404, interestingly there is no content either from the 404? The weird tomcat URL was in error but doesnt affect the results :( :( – Matt Feb 08 '17 at 16:46
  • You could try starting the server using maven and then test it manually through the browser. – Hubert Grzeskowiak Feb 08 '17 at 16:48
  • finally figured it out,... tomcat7-maven-plugin works with version 2.0, doesnt with version 2.2 – Matt Feb 08 '17 at 16:57
  • Oh wow. No wonder it took you hours to figure it out. Good job and thanks for reporting back. – Hubert Grzeskowiak Feb 08 '17 at 16:58