| Author |
How to deploy a RESTful Web Service
|
Mike London
Ranch Hand
Joined: Jul 12, 2002
Posts: 949
|
|
When deploying a RESTful web service to, say, Tomcat, do you deploy a "web app" or just run a main() program on the server that sets up a port for the RESTful Web Service like this:
HttpServer server = HttpServerFactory.create("http://localhost:9998/");
server.start();
Or, you could do it either way?
Thanks in advance for suggestions.
-mike
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56224
|
|
|
All my RESTful services are web apps.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Mike London
Ranch Hand
Joined: Jul 12, 2002
Posts: 949
|
|
Bear Bibeault wrote:All my RESTful services are web apps.
Bear, you're the man. Thanks!
BTW, have you found a good tutorial that shows how to set up the GET, POST, PUT, and DELETE things in a RESTful service?
Maybe you've written something?
Thanks again in advance.
- mike
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56224
|
|
You can look up the Jersey project, an implementation of JAX-RS.
Another alternative, if you are willing to step away from the JEE stack, is the Play! framework, which makes routing really easy and has good JPA integration. (If you go this route, be sure to use an older Play version 1 instance -- Play 2 does not play well with Tomcat.)
|
 |
Mike London
Ranch Hand
Joined: Jul 12, 2002
Posts: 949
|
|
Bear Bibeault wrote:You can look up the Jersey project, an implementation of JAX-RS.
Another alternative, if you are willing to step away from the JEE stack, is the Play! framework, which makes routing really easy and has good JPA integration. (If you go this route, be sure to use an older Play version 1 instance -- Play 2 does not play well with Tomcat.)
That sounds interesting. Our project is just beginning so Play may be just the ticket!
Thanks again.
- mike
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56224
|
|
I've used Play! successfully -- but I would caution that because it's not based on Servlets and JSP, it's a pretty fair deviation from "the norm". Also, be prepared to be stuck at Play version 1. Play version 2 is a complete re-write, and (last I checked) could not be deployed on Tomcat or other JEE containers.
Just be aware of the limitations that are the price paid for the benefits.
|
 |
Mike London
Ranch Hand
Joined: Jul 12, 2002
Posts: 949
|
|
Bear Bibeault wrote:I've used Play! successfully -- but I would caution that because it's not based on Servlets and JSP, it's a pretty fair deviation from "the norm". Also, be prepared to be stuck at Play version 1. Play version 2 is a complete re-write, and (last I checked) could not be deployed on Tomcat or other JEE containers.
Just be aware of the limitations that are the price paid for the benefits.
Yeah, good point.
I need to make sure I can "deploy" a simple helloworld REST service first I guess.
The example Intellij creates is the same as the one on the Jersey site. I've tried to "deploy" it to Tomcat using the port 9998, but it doesn't run. I just get the dreaded:
I've also tried 8080.
The only way I can get the service to "deploy" is to run the main method (code below) and then the browser comes up and I can do REST calls. Is that what you meant by "deploy"? Running a main method is not, of course, how I have ever deployed a web app.
Look forward to any comments.
------------------
// modified the below a bit from the JERSEY "Helloworld" example
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56224
|
|
|
When I've used Jersey it was as a JEE (servlet-based) web app. No main(). So I'm unlikely to be of any help for that.
|
 |
Mike London
Ranch Hand
Joined: Jul 12, 2002
Posts: 949
|
|
Bear Bibeault wrote:When I've used Jersey it was as a JEE (servlet-based) web app. No main(). So I'm unlikely to be of any help for that.
Well, the Servlet is defined in web.xml. I think the main() is just for testing.
I must just be doing something wrong.
Thanks,
-mike
<?xml version="1.0" encoding="UTF-8"?>
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56224
|
|
Theere are some tips in the ServletsFaq for general servlet deployment issues. Also check for typos such as "serlvet".
Been a while since I've used Jersey, so if that's the route you're going, it might be best to open a new topic specific to the Jersey issue with "Jersey" in its subject to attract current users.
|
 |
Mike London
Ranch Hand
Joined: Jul 12, 2002
Posts: 949
|
|
Bear Bibeault wrote:Theere are some tips in the ServletsFaq for general servlet deployment issues. Also check for typos such as "serlvet".
Been a while since I've used Jersey, so if that's the route you're going, it might be best to open a new topic specific to the Jersey issue with "Jersey" in its subject to attract current users.
Will do. Appreciate your replies as always.
Thanks,
- mike
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56224
|
|
|
My pleasure!
|
 |
 |
|
|
subject: How to deploy a RESTful Web Service
|
|
|