Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to deploy a RESTful Web Service

 
Mike London
Ranch Hand
Posts: 1192
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All my RESTful services are web apps.
 
Mike London
Ranch Hand
Posts: 1192
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1192
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1192
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1192
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1192
4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My pleasure!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic