404 when accessing Jersey app in Tomcat 7

后端 未结 2 1448
我寻月下人不归
我寻月下人不归 2021-01-25 04:01

I am a newby in web development and I am struggling to create a simple rest web service using jersey, packed as an independent war file, to be deployed on tomcat 7.

I ha

相关标签:
2条回答
  • 2021-01-25 04:14

    This is similar to this SO question: "No provider classes found: when running Jersey REST example application".

    The message "No provider classes found" is fine, no need to worry about it. For the URL http://localhost:8080/rest/hello to work your WAR file needs to be called rest.war. Then rest becomes the context root. All the paths you define in the project's annotations are relative to the context root.

    0 讨论(0)
  • 2021-01-25 04:14

    if you have called your project in eclipse: rest, so you should get the correct message: "Hello world!" from tomcat with the url:

    http://localhost:8080/rest/hello.
    

    If you for example have called your project: MyHello, with the code you posted the correct url should be:

    http://localhost:8080/MyHello/hello
    

    (The reason is that Eclipse create by default a war called as the name of the project and publish it to the tomcat server you have added in your configuration)

    Let me know

    0 讨论(0)
提交回复
热议问题