• 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

Requested resource is not available using Hibernate

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ya'll,

I hope this is any easy one. I don't seem to be hitting my RESTful webservices. I am using Hibernate and checked and all my entity classes are working. I've even retrieved data from the database but I cannot hit the web service. I am using Tomcat 7 and Eclipse IDE.

here's my pom


here's my service


I have a web xml but there is really nothing in it. The url i am wanting to hit is http://localhost:8080/HibEx1/service/getEmployees. Is th a correct URL?
Any help would be appreciated. I also tried changing my Path to "/service" and that did not work either. I am getting a Http Status 404 "The requested resource is not available.
Thanks

 
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you try:

1. http://localhost:8080/HibEx1/getEmployees
2. http://localhost:8080/getEmployees

Is your service published? Did you check that?
 
jawann jefferson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your reply,

Yes I tried both of those links and they did not work. I am not sure what you mean by publish. I have deployed the project to the Tomcat server through eclipse Luna and also through creating a WAR file and copying it to the Webapps folder in Tomcat. Is there something i missed?
 
Arun Kumarr
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your service or controller is started and bound to a particular path, during start up of your web application, you will have logs which will say starting service, binding to path ... etc.,
Are you able to see any such logs during start up?
 
Arun Kumarr
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your service or controller is started and bound to a particular path, during start up of your web application, you will have logs which will say starting service, binding to path ... etc.,
Are you able to see any such logs during start up?
 
jawann jefferson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my catalina log i have this:

INFO: Deploying web application archive C:\ApacheTomcat\apache-tomcat-7.0.59\webapps\HibEx1.war
Mar 24, 2015 8:17:18 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive C:\ApacheTomcat\apache-tomcat-7.0.59\webapps\HibEx1.war has finished in 427 ms
Mar 24, 2015 8:17:18 AM org.apache.catalina.startup.HostConfig deployDirectory

During startup in eclipse i do not see anything with where the words "bind" is used or anything that says starting service.
 
Arun Kumarr
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post your web.xml and any other configuration files you are using as part of your war?

The "service" or "/service" doesn't matter. You can specify without forward slash.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you deploying application from Eclipse.Check the below changes.

1 . Server settings in Eclipse.

Right click the Server------> open---------->Check the server location.

Check the Radio button on Use Custome location.give the Server path where you are installed the Tomcat.

Change the deployment path as "Webapps".

Thanks.
 
jawann jefferson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is my web.xml


hibernate.cgf.xml


employee.hbm.xml



 
jawann jefferson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, I was able to check the server location but there wasn't any radio button that would allow me to customize the setting.
 
Arun Kumarr
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me take couple of steps back and ask you this question.
Since you are trying this based on some example or tutorial, can you post the tutorial link or example link on which you are currently developing and learning?
 
jawann jefferson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's the link for the original Hibernate tutorial i followed which worked.
hibernate


This is the youtube link i am using to try to connect it with RESTful services
youtube link
 
Arun Kumarr
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe hibernate is not the issue here.
From the you tube link, are you sure you are including all the dependencies for the project?
If you have missed any, can you check what you have missed and try to understand what is the role of that jar.

In general, have you developed a java web application before?
 
jawann jefferson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've only developed them through other REST tutorials. Which I got to work so i figured, hey, why not try to connect the two ya know?

Thank you for helping me with this. I really appreciate your time.
 
Arun Kumarr
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For your rest sample project, what are the maven dependencies you had. Can you post them?
Can you also check that you have "all" the jars present in the web-inf folder of your rest project is also present in your new rest-hibernate project?
 
jawann jefferson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This are all of my Maven dependecies



This is my redone web.xml


Here is a snapshot of all my dependencies



I checked and for the restful project i do have all the dependencies that he has in his file. As for the my old REST project I was not using RESTeasy like he his. So i believe they would be different.
Also Maven has all of the dependencies and there is nothing in my WebInf/lib file. Should there be?
For my old project i was using Jersey. I could post those if it would help.
 
Arun Kumarr
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Also Maven has all of the dependencies and there is nothing in my WebInf/lib file. Should there be?


I assume you are mentioning the newly built rest-hibernate project. Yes, you should be having the jars unless they are in the application server class path.
I believe the Service file is not getting picked up because of the jars not present in the class path and there should be some sort of bootstrapping happening in your web.xml which reads the service classes (using annotation) and binds it as services.
 
jawann jefferson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok Update:

I think something is happening. I commented out pretty much all my web.xml file only leaving "displayname" active.
I created a wrapper class for the service:

RestEasyWrapper



Now the server will start but I'm still getting a 404 error.
Now, when I add /service to the Url a different window pops up (looks like ie) and i get another 404 error. But i get an error in the console now

[http-bio-8080-exec-8] ERROR org.jboss.resteasy.core.ExceptionHandler - failed to execute
javax.ws.rs.NotFoundException: Could not find resource for full path: http://localhost:8080/HibEx1/service
at org.jboss.resteasy.core.registry.ClassNode.match(ClassNode.java:73)
at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48)
at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:444)
at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:234)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:171)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
[http-bio-8080-exec-10] ERROR org.jboss.resteasy.core.ExceptionHandler - failed to execute


and this after i add /getEmployees

javax.ws.rs.NotFoundException: Could not find resource for full path: http://localhost:8080/HibEx1/service/getEmployees
at org.jboss.resteasy.core.registry.ClassNode.match(ClassNode.java:73)
at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48)
at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:444)
at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:234)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:171)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)



 
Ranch Hand
Posts: 253
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
strip "/Service" from your Restful service. As you already provided "/Service" in your bootstrapping application. This post is one year back. But still just want to give information. Thanks.
reply
    Bookmark Topic Watch Topic
  • New Topic