Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
SureshSai Vavileti
Greenhorn
Posts: 8
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Any update to the above issue...
 
Ron McLeod
Saloon Keeper
Posts: 1429
207
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • 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
  • 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
Saloon Keeper
Posts: 1429
207
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Any update to the above concern....
 
Ron McLeod
Saloon Keeper
Posts: 1429
207
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Sorry Ron, Issue is resolved - the comment is related to another post. It was misplaced here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!