Reputation: 103
I'm developing an RESTful web service and I want to expose my data through it. I have a database (Derby), where I have two tables ('User' and 'Schedule').
Now, I want to type the name of the user and obtain their schedule. I can put the name using POST method, but I must check if the user is registered in the database and only then I send it's schedule.
I have created the entity classes and the session beans for the database.
In the web service, I have created two object from the type facade, like:
UserFacade user = new UserFacade();
ScheduleFacade schedule = new ScheduleFacade();
I assumed that I could use the entitymanager in the userfacade class, but always when I test the web service I receive a NullPointerException.
How can I access the database using the web service?
Upvotes: 0
Views: 1345
Reputation: 2489
You will have to create a J2EE web application and deploy it into compatible servlet container (Tomcat, Jetty, etc).
There are several frameworks, that support RESTful services such as Jersey (http://jersey.java.net/) or Restlet (http://www.restlet.org/). Both of this frameworks have documentation and examples that are sufficient to get started.
Also, if my memory serves me well, Restlet framework has a small embeddable http server. So, initially you can avoid extra complexity with real J2EE web applications.
Upvotes: 1