Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #22767

Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc...

From Arved Sandstrom <asandstrom2@eastlink.ca>
Newsgroups comp.lang.java.programmer
Subject Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc...
References <dzdYs.98654$Sq4.71538@newsfe14.iad> <51340ae1$0$32109$14726298@news.sunsite.dk> <ma_Ys.2$PC7.1@newsfe03.iad> <5137e8ff$0$32109$14726298@news.sunsite.dk>
Message-ID <J7_Zs.1888$Nl5.1682@newsfe07.iad> (permalink)
Organization Public Usenet Newsgroup Access
Date 2013-03-07 06:39 -0400

Show all headers | View raw


On 03/06/2013 09:10 PM, Arne Vajhøj wrote:
> On 3/4/2013 4:53 AM, Arved Sandstrom wrote:
>> On 03/03/2013 10:45 PM, Arne Vajhøj wrote:
>>> On 3/1/2013 9:34 PM, Arved Sandstrom wrote:
>>>> I just had an epiphany today at work. For years upon years I have used
>>>> Java libraries which have grown increasingly cumbersome and finicky and
>>>> unreliable to do XML or JSON in a REST context...99 percent of which is
>>>> actually super-simple.
>>>>
>>>> The epiphany came when neither Jettison (the default Jersey JSON
>>>> library) nor Jackson (which is undoubtedly more modern) could, out of
>>>> the box without arcane configuration tweaks, convert a single-item list
>>>> into a JSON array. They both just converted the item into a JSON object
>>>> and forgot about the array.
>>>>
>>>> Apparently this catches out a lot of people, judging by googling. The
>>>> Jackson solutions are many. The point being - leading to my epiphany -
>>>> why the hell is this even a problem?
>>>>
>>>> I have probably wasted tens of weeks on the arcana of Jersey, Jackson,
>>>> XStream to some extent, JAXB...I'm ditching most all of it. It is an
>>>> obstacle.
>>>>
>>>> XStream I actually like for producing and consuming XML. It works
>>>> nicely. I'll keep it in the toolbox. But for almost everything I do
>>>> with
>>>> Java REST, there is no call for Jersey (nor Jackson et al. for JSON
>>>> (de-)serialization). It's a bunch of extra JARs for no added value.
>>>>
>>>> It occurred to me that for over 90 percent of my POJOs I can write
>>>> reliable toJSON() methods that *will not break* and are fully under my
>>>> control in a matter of minutes. For anything more I might give
>>>> simple-json a whirl - it actually has appealing simplicity.
>>>>
>>>> And Jersey has got to go. Why do we even drink that Kool-Aid? Once
>>>> you've got your JSON string a handful of lines of code with an HTTP
>>>> client will take care of your REST call. A lot more reliable.
>>>
>>> I think we need to split the stuff in 3 parts:
>>> A) server side framework to enable declarative JAX-RS to work in a
>>>     servlet container
>>> B) the JSON/POX serializer
>>> C) client side framework
>>>
>>> re A)
>>>
>>> I don't hear you argue against that. And I don't recall much
>>> criticism from other either.
>>  >
>>> re B)
>>>
>>> You don't like the common libraries. I know several people that
>>> don't like them either (I don't have so much personal experience).
>>>
>>> But is it really the concept that is wrong or is it just the
>>> implementations?
>>>
>>> My guess is still the implementations. I am not too keen on
>>> toJSON, toXML, toJSONAlternative, toXMLALternative etc.etc.
>>> on all DTO's.
>>>
>>> We may not always like SOAP and all the associated standards,
>>> but sometimes the "there is only one right way" philosophy
>>> do make life easier.
>>>
>>> re C)
>>>
>>> I think it is rather common to use plain HttpClient.
>>>
>>> Non-Java client to Java service is probably also a very
>>> common combination.
>>
>> For all of A, B, C, I have no problem with JSON as a data notation. I
>> have no major problems with SOAP as a protocol, or with the principles
>> of true RESTful web services [1].
>>
>> For all of A, B, C, it is specifically implementations that I have a
>> problem with. Whether language-specific APIs or libraries. JSON is
>> simple. SOAP *messages* are usually quite simple (WSDL and schemas might
>> not be, but you infrequently occupy your time with those). JSON as a
>> payload over HTTP as part of a REST method is simple. SOAP XML via HTTP,
>> JMS, SMTP is usually quite simple.
>>
>> *When we look at what is going back and forth*, that's what is simple.
>> What can be, and often is, elaborately over-engineered, clumsy, buggy,
>> and not simple are the client and server APIs and libraries.
>>
>> As to toJSON() or fromXml() type methods, I'm not overly keen on them
>> either, for maintainability reasons. We very often have to explain to
>> the client or server framework how to handle the DTO<->JSON/XML
>> conversions, and annotations are superior to hardcoding for this. Except
>> when they're not. :-)
>
> Time to write your own annotation processing library??
>
> :-)
>
> Arne
>
>
My next big Java-space web app development effort is going to be 
shifting away from JSF. I've been using the framework for 8 or 9 years, 
and I'm unhappy with it.

My current JSF routine is - once I know what the page flow is, the model 
and viewmodels are thought through, wireframes or the equivalent are 
worked up etc - commences by using my Scala DSL to generate appropriate 
XHTML page and Java managed bean skeletons, which removes over 75% of 
the boilerplate effort. I use a Mojarra JSF (latest version) and 
Primefaces (latest version) combination to implement.

I still find it very tedious. In comparison to JPA, where 2.x really is 
a major capability step up from 1.x, I found that JSF 2.x gave me a 
small number of minor new handy capabilities, but largely formalized all 
the workarounds and custom code that I'd had available since as early as 
2007 or so for JSF 1.1, and later for JSF 1.2. For example, from 2008 
through 2011 I did a lot of JSF 1.x projects using an 
enhanced/customized JSF library (since the ability to extend JSF has 
always been there) that foresaw the majority of 2.x features. I didn't 
even switch over to 2.0 on real jobs until maybe a year after it came 
out, except for experimenting with it, mainly because there was no real 
need. This custom version, that I also enhanced myself, even did proper 
paginated AJAX'd datatables.

I use 2.1 now, like I say Mojarra + PrimeFaces (I've tried ICEFaces, 
RichFaces etc etc, but now prefer PrimeFaces), but when all is said and 
done it takes as much time to develop - page for page, removing the 
effect of me using my DSL - for 2.1 as it did for 1.1. Nothing I can 
think of really takes less time and less effort with JSF 2.x than it did 
with 1.x. Inline row editing is an example: anyone who wanted to do this 
with 1.x worked out a solution early on, and had it in their toolbox. 
That the capability is now provided out of the box by many frameworks 
like Primefaces doesn't remove the fact that I could set up inline row 
editing in 1.x just as quickly.

Sure, all of this is great for new JSF developers - but it's not 
compelling progress for me.

I'm actually not even happy anymore with frameworks that separate the 
whole business out into pages + code (e.g. JSF XHTML + managed bean 
Java, or ASP.NET MVC aspx + C# codebehind, say). I've never worked in - 
or heard of, or encountered - an environment where one team worked on 
pages and another on backing code. It's usually the same developers that 
do both. It's more productive that way. So why 2 different artifacts - 
essentially a page template + the controller/presentation model code - 
to accomplish one thing: a generated page?

While I'm not arguing for the return of classic ASP or classic JSP or a 
general migration over to PHP for everyone (I seriously dislike PHP), 
I'm not dogmatically opposed to a single artifact per generated page. As 
far as I am concerned, by abstracting away as much as we have from a 
servlet producing HTML directly, or CGI scripts or executables doing the 
same thing, we've abstracted away too far. Look at all the problems on 
StackOverflow etc that people are still wrestling with to do basic stuff 
with JSF 2.x. I suppose if you just started with web frameworks last 
year then you don't know any better, but I am not convinced we're better 
off in 2013 than we were in 2003 or close to 20 years ago, actually, not 
when discussing server-side technology.

Part of my thinking is inspired by the Scala DSL I wrote to not 
continually waste my time with JSF boilerplate. It's not a big 
conceptual step from that to a complete DSL that when executed *is* your 
web app. It's not hard to do; a number of languages already support XML 
in code, so your generators use that capability.

Not since Day One have my basic requirements in web pages changed. CRUD 
and datatable capability is 90+ percent of it, always has been, always 
will be. I'd be hard-pressed to think of a single page out of hundreds 
I've written that isn't basically CRUD. 100 percent of the time when I 
work with a JSF XHTML page or an ASP.NET MVC page, all that HTML is 
standardized adornment - it could *always* be generated. Basically, why 
don't I declare (in code) what my pages should do, and do it just once? 
And a Page object knowing how to present itself - isn't that core OO?

I can do all of my tweaking with CSS and JavaScript, as required. 
Usually just CSS, because most of the JS in my vision would be generated 
too.

We call this codebehind/backing bean coding + XHTML page writing a 
"separation of concerns". Well, no, it's not. Not when we routinely 
embed JSF XHTML or ASP.NET MVC ASPX pages with code to the extent that 
we may as well be doing scriptlets. The code we embed may simply be 
viewmodel references and action references, but it's still embedded 
code. To me all of this is simply extra effort for no real gain.

As you might guess I am pretty interested in HTML5 also. :-) Ideally 
that would be the generated product. My gut feeling is that JSF 
evolution will not be able to keep up with the real impact of HTML5 
anyway, another reason to move away.

Just some opinionating. :-) Thinking aloud.

AHS

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-01 22:34 -0400
  Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Joerg Meier <joergmmeier@arcor.de> - 2013-03-02 04:00 +0100
  Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-02 00:13 -0400
  Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2013-03-01 22:11 -0800
    Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-03-02 08:57 +0000
      Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-03 21:48 -0500
        Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-03-04 08:29 +0000
    Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-02 09:58 -0400
    Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Fredrik Jonson <fredrik@jonson.org> - 2013-03-02 14:46 +0000
      Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... markspace <markspace@nospam.nospam> - 2013-03-02 07:11 -0800
      Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-03 21:55 -0500
      Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Roedy Green <see_website@mindprod.com.invalid> - 2013-03-06 09:07 -0800
        Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-06 20:13 -0500
    Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-03 21:47 -0500
      Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... David Lamb <dalamb@cs.queensu.ca> - 2013-03-03 21:57 -0500
        Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-03 22:08 -0500
        Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-03 23:11 -0400
          Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-06 20:15 -0500
            Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-07 05:08 -0400
              Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-07 11:42 -0500
  Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-03 21:45 -0500
    Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-04 05:53 -0400
      Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-06 20:10 -0500
        Writing ones one Annotation processor (was: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc...) Joerg Meier <joergmmeier@arcor.de> - 2013-03-07 02:17 +0100
          Re: Writing ones one Annotation processor Arne Vajhøj <arne@vajhoej.dk> - 2013-03-06 20:36 -0500
        Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-07 06:39 -0400
          Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-07 11:41 -0500
            Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-07 20:28 -0400
              Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-07 21:24 -0500
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-08 05:49 -0400
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-03-08 12:20 +0000
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Leif Roar Moldskred <leifm@dimnakorr.com> - 2013-03-08 12:06 -0600
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-08 20:44 -0400
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-11 18:07 -0400
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Joerg Meier <joergmmeier@arcor.de> - 2013-03-11 23:27 +0100
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-11 18:33 -0400
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-11 21:12 -0300
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-11 20:24 -0400
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-03-11 21:38 -0300
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-11 20:58 -0400
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Robert Klemme <shortcutter@googlemail.com> - 2013-03-13 08:04 +0100
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-11 17:57 -0400
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Lew <lewbloch@gmail.com> - 2013-03-11 16:46 -0700
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-11 20:27 -0400
                Re: Mini-rant on Java REST (JAX-RS), JSON, XML, JAXB etc... Arne Vajhøj <arne@vajhoej.dk> - 2013-03-11 17:54 -0400

csiph-web