• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Jersey 2.22(JAXRS-RI) with Glassfish (v.4) giving 404 exception

 
Greenhorn
Posts: 8
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am writing my first REST program using Jersey 2.22 and Glassfish 4.While running with URI in the browser, I am getting 404 exception. When I debug, I can reach my resource but not sure why '404 Not found exception' is generated. I am trying to fix the issue but not succeeded so seeking your help.

Here is the URI, I am using to get the resource (service) -- http://localhost:8080/JAXRS_Servlet_2.4/firstJersey/startUp/sayHello

My resource file is,



My Web.xml is


Below is the optional file which I used to switch between "packages" in web.xml and class with @ApplicationPath annotation

Please try to help on how to fix the issue.
Thanks in Advance.
 
SureshSai Vavileti
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any update to the above issue...
 
Marshal
Posts: 3720
533
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

SureshSai Vavileti wrote:When I debug, I can reach my resource but not sure why '404 Not found exception' is generated


How are you determining that you reach the resource (method)?

I don't see any HTTP Method annotation for your sayHello() method. Are you assuming that @GET is understood by default?
 
SureshSai Vavileti
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ron for reply,
I understood like, GET is by default. And also when I debug to the file (Hello World.java) ,I can see sayHello () is being called. I have attached the screen shot of Debug.

URL to access the service :: http://localhost:8080/JAXRS_Servlet_2.4/firstJersey/startUp/sayHello
REST_Debug_For_Code_Ranch.png
[Thumbnail for REST_Debug_For_Code_Ranch.png]
Rest Debug
 
Ron McLeod
Marshal
Posts: 3720
533
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you need to explicitly specify the HTTP method for the resource methods. Trying including the @GET annotation and see if it behaves differently.
 
SureshSai Vavileti
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ron,

Once again would like to Thank you as it is working after @GET annotate. But this is annoying me, because I see many of 'Hello World' / 'Start up' examples where they did`t mention @GET annotate (even they did`t mention @Path to the service resource(method)). I did`t even read @GET is mandatory. How can we fix this kind of issues since I am trying to fix it since six days?
REST_Working_For_Code_Ranch.png
[Thumbnail for REST_Working_For_Code_Ranch.png]
REST_Working_Ron`s_Solution
 
SureshSai Vavileti
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any update to the above concern....
 
Ron McLeod
Marshal
Posts: 3720
533
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

SureshSai Vavileti wrote:Any update to the above concern....


Sorry - I thought the issue was resolved. What problems are you still facing?
 
SureshSai Vavileti
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Ron, Issue is resolved - the comment is related to another post. It was misplaced here.
reply
    Bookmark Topic Watch Topic
  • New Topic