4

i try to keep up with a java rest service. So i found some tutorials, which explain always the same way. But i cant get this running :(.

I made Dynamic Web Project in Version 2.5 and Tomcat 7.0 in eclipse. Then i load following jars to WEB-INF/lib

enter image description here

My Projectname is com.freespots.rest. I created following web.xml

enter image description here

Ok now iam going to create the java-class right? Well i did it Java Resources/src/com.freespots.rest.service:

enter image description here

If i start Tomcat and type url to my browser like localhost:8080/com.freespots.rest the Tomcat shows my index.html file. But if i go to url localhost:8080/com.freespots.rest/api/hello there is just a HTTP 404 Error: enter image description here

Well iam new to Java Webdevelopment and i cant figure out my Problem. I hope some guy can explain my mistake. Thanks in advance.

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
Sebi
  • 3,879
  • 2
  • 35
  • 62

2 Answers2

4

You're using the old (1.x) Jersey configuration. In Jersey 2.x, the class namescpaces and property names have changed. You should instead use

<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
    <param-name>jersey.config.server.provider.packages</param-name>
    ...

See other deployment options here

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
0

localhost:8080/com.freespots.rest this URL will run welcome page which is index.html as you said, and localhost:8080/com.freespots.rest/api/hello here no page found so 404 not found error. Try to put @Path("name") above method and call localhost:8080/com.freespots.rest/api/hello/name

Safwan Hijazi
  • 2,089
  • 2
  • 17
  • 29
  • That's not true, since you are doing a GET request on the path /hello, the method with the '@GET' annotation will be executed if no '@Path' is specified. – Hans Wouters Jul 27 '15 at 19:06