Live data from Hacker News

Build RESTful web services with Java technology

ibm.com

1–10 of 30 posts

Re: Build RESTful web services with Java technology

#2
Building REST services with JAX-RS is truly pretty smooth and quick (I've been using Jersey not Wink though).

One thing I don't ever recommend is using JPA based libraries (Hibernate, EclipseLink, whatever). Run screaming away from that spec as fast as you possibly can. There are much better options for ORMs in Java that don't have the session management headache and endless string of gotchas that is JPA. Ebean is my current favorite.

As for the "framework", I haven't really found the need for one. Jersey/Jackson + Jetty + Ebean gets you 90% of the way there, just fill in whatever you want for logging and other minor support items. If you want something more pre-packaged with some of the service start/stop boilerplate built in there is dropwizard (https://github.com/codahale/dropwizard).

Re: Build RESTful web services with Java technology

#3
post #2

Building REST services with JAX-RS is truly pretty smooth and quick (I've been using Jersey not Wink though). One thing I don't ever recommend is using JPA based libraries (Hibernate, EclipseLink, whatever). Run screaming away from that spec as fast as you possibly can. There are much better options for ORMs in Java that don't have the session management headache and endless string of gotchas that is JPA. Ebean is my…

Nice. +1 for avoiding JPA. I hadn't heard of Ebean, I'll look in to that. Shameless plug, but Joist is my take on a "post-Hibernate" back-to-the-basics ORM:

http://joist.ws/

Re: Build RESTful web services with Java technology

#4
post #2

Building REST services with JAX-RS is truly pretty smooth and quick (I've been using Jersey not Wink though). One thing I don't ever recommend is using JPA based libraries (Hibernate, EclipseLink, whatever). Run screaming away from that spec as fast as you possibly can. There are much better options for ORMs in Java that don't have the session management headache and endless string of gotchas that is JPA. Ebean is my…

Thanks a lot for the pointers. I have been looking for a good java framework to learn. I will be more than happy to settle with this 90% you quoted. They look simple enough to understand in a couple of days without wrestling with tons of XML config files.

Re: Build RESTful web services with Java technology

#5
post #2

Building REST services with JAX-RS is truly pretty smooth and quick (I've been using Jersey not Wink though). One thing I don't ever recommend is using JPA based libraries (Hibernate, EclipseLink, whatever). Run screaming away from that spec as fast as you possibly can. There are much better options for ORMs in Java that don't have the session management headache and endless string of gotchas that is JPA. Ebean is my…

Ah, I'm not the only one who thinks ORMs suck! That's why I love the latest development in the Scala community towards a non-ORM solution for persistence: Slick (http://slick.typesafe.com) and Play! Anorm (http://www.playframework.org/documentation/2.0/ScalaAnorm)

Re: Build RESTful web services with Java technology

#6
post #4
post #2

Building REST services with JAX-RS is truly pretty smooth and quick (I've been using Jersey not Wink though). One thing I don't ever recommend is using JPA based libraries (Hibernate, EclipseLink, whatever). Run screaming away from that spec as fast as you possibly can. There are much better options for ORMs in Java that don't have the session management headache and endless string of gotchas that is JPA. Ebean is my…

Thanks a lot for the pointers. I have been looking for a good java framework to learn. I will be more than happy to settle with this 90% you quoted. They look simple enough to understand in a couple of days without wrestling with tons of XML config files.

I should add that my "90% of the way there" gets you a service that easily speaks JSON via REST calls. Its all you need if your frontend is backbone based or its just a service getting called by another layer. If you need to actually render web pages in response you'll need something for views/templating, freemarker is a reasonable option and JSF isn't terrible if you avoid half of it (looking at you ViewScoped). But, honestly, I would do the page rendering elsewhere, I don't think there is a good Java answer for this, maybe the Play Framework, haven't used it much yet.

In my case the Java backend exposes RESTful models via JSON which are consumed by a rails app using Her[0] a great gem that is what ActiveResource should have been. It wires up to Jersey quite easily.

[0] https://github.com/remiprev/her

Re: Build RESTful web services with Java technology

#7
post #2

Building REST services with JAX-RS is truly pretty smooth and quick (I've been using Jersey not Wink though). One thing I don't ever recommend is using JPA based libraries (Hibernate, EclipseLink, whatever). Run screaming away from that spec as fast as you possibly can. There are much better options for ORMs in Java that don't have the session management headache and endless string of gotchas that is JPA. Ebean is my…

Ah, I'm not the only one who thinks ORMs suck! That's why I love the latest development in the Scala community towards a non-ORM solution for persistence: Slick ( http://slick.typesafe.com ) and Play! Anorm ( http://www.playframework.org/documentation/2.0/ScalaAnorm )

I don't hate ORMs, but I hate when they are too intrusive. What I like about Ebean is that it was designed to only handle the simple stuff "ORMish" and provide a very smooth and easy breakdown to raw SQL so you get the best of both worlds. I also love "autotune", it tracks your call stack for queries and after it has enough statistics it'll start only fetching the fields that you actually ended up using. So if you have an object with 25 fields and one page A you only use 5 of them, it'll only fetch those 5, but since its based on a the call stack and not hardwired into the model, it can can track that you used 5 different fields on page B and optimize that query too.

Re: Build RESTful web services with Java technology

#9
I really fell in love with REST a while ago.

Besides the frontend code being much simpler (Javascript can do a lot of fancy stuff when it receives nicely structured data instead of dumb HTML) another huge benefit was enabling other people with different language backgrounds (Perl in my case) to perform their QA on the resulting API instead of manually clicking through the app (or writing quickly dying Selenium tests due to page modifications).

In the meantime even the customer does use the API for integration purposes using curl :)

Really happy with the latest developments...

Re: Build RESTful web services with Java technology

#10
post #6
post #4

Earlier quoted context omitted.

Thanks a lot for the pointers. I have been looking for a good java framework to learn. I will be more than happy to settle with this 90% you quoted. They look simple enough to understand in a couple of days without wrestling with tons of XML config files.

I should add that my "90% of the way there" gets you a service that easily speaks JSON via REST calls. Its all you need if your frontend is backbone based or its just a service getting called by another layer. If you need to actually render web pages in response you'll need something for views/templating, freemarker is a reasonable option and JSF isn't terrible if you avoid half of it (looking at you ViewScoped). But…

Someone on StackOverflow was suggesting to use RESTEasy with HTMLEasy to generate HTML automatically from REST services.
Post reply on HN