Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

How to deploy a RESTful Web Service

 
Bartender
Posts: 1865
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All my RESTful services are web apps.
 
Mike London
Bartender
Posts: 1865
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 1865
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 1865
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 1865
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 1865
17
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My pleasure!
 
You would be much easier to understand if you took that bucket off of your head. And that goes for the tiny ad too!
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic