• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Resource not found error in JAX-RS web service

 
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have to create web services for my project. I am new to advance java and creating Java web services for the first time. This is my servlet-



I want to call the service named "smooth" which prints content on console.

This is the web.xml file-


The url i'm using is-
http://localhost:8080/ServletExporer/HelloWorldServlet/smooth

But it gives error 404-Resource not found sometimes and sometimes it throws ClassNotFoundException.

Please tell me what wrong i'm doing.

Thanks in advance.
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the environment/setup etc... you are using this? You might need to explain more details about other aspects involved here.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The <servlet-class> attribute needs to contain the fully qualified class name of the servlet - that includes the package information, which is currently missing.

I wouldn't mix a WebServlet annotation with a servlet declaration in web.xml - use one or the other, but not both.

Lastly, I don't think you can mix a servlet with a JAX-RS service in the way you do (nor should you, even if it works). Have you tried creating a JAX-RS service without making it a servlet?
 
Astha Sharma
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for replying

Vijitha Kumara wrote:What is the environment/setup etc... you are using this? You might need to explain more details about other aspects involved here.


Please tell what details are required? I am using Tomcat as server.
 
Astha Sharma
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:The <servlet-class> attribute needs to contain the fully qualified class name of the servlet - that includes the package information, which is currently missing.

I wouldn't mix a WebServlet annotation with a servlet declaration in web.xml - use one or the other, but not both.

Lastly, I don't think you can mix a servlet with a JAX-RS service in the way you do (nor should you, even if it works). Have you tried creating a JAX-RS service without making it a servlet?


I tried writing fully qualified class name of the servlet but the url http://localhost:8080/ServletExporer/HelloWorldServlet/smooth calls the method doGet() but I want to call my web service method smooth(). How to do that?


Thanks
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
doGet is a servlet thing. That's why you should not make your JAX-RS handler a servlet.
 
Astha Sharma
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I got it. Tried selecting option web services in ecllipse and now its working fine
Thanks
 
Montana has cold dark nights. Perfect for the heat from incandescent light. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic