aspose file tools*
The moose likes Web Services and the fly likes Resource not found error in JAX-RS web service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Resource not found error in JAX-RS web service" Watch "Resource not found error in JAX-RS web service" New topic
Author

Resource not found error in JAX-RS web service

Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 247

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.


Astha - OCPJP 6 (90%)
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3829

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


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41815
    
  62
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?


Ping & DNS - my free Android networking tools app
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 247

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

Joined: Oct 15, 2011
Posts: 247

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
Marshal

Joined: Mar 22, 2005
Posts: 41815
    
  62
doGet is a servlet thing. That's why you should not make your JAX-RS handler a servlet.
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 247

Yes I got it. Tried selecting option web services in ecllipse and now its working fine
Thanks
 
 
subject: Resource not found error in JAX-RS web service