Now, I've been using Spring for the last 2 years and am writing, by
all measures, the best code of my career: highly covered, loosely
coupled, low CRAPload.
So, my question is: Why do I need Java EE? What does it give me that
Spring cannot? These questions are not rhetorical and I have an open
mind on this. I just don't have the knowledge or experience to answer
these myself. BTW, I'm talking about the full-on Java EE requiring a
Java EE applicaiton server, not the more ubiquitous parts of the spec
like servlets that can be handled with a web server like Tomcat/
Jetty. Also, I know that I can use Spring and Java EE together, but
my question is: Why bother?
Incidentally, here are some reasons why I am averse to using Java EE
(mostly EJB3):
- Added deployment complexity of installing/maintaining an application
server
- Requires app redeploy to test code changes (this is a big one for
me)
- Marries me to an API. The "not standards-based" argument is
commonly levied against Spring, but I never did buy that. Just
because an API is a standard doesn't make the lock-in entailed with
its use any less real. From a code maintenance perspective, the
ability to swap out vendor implementations buys me nothing. Given the
choice between locking-in to a proprietary or standard API, of course
the prudent choice is the latter. But Spring apps are dependent only
on the functionality that it provides, not on any API. So, the choice
here is between locking-in to a standard or using Spring and locking-
in to nothing.
Replies based on practical experience would be much appreciated.
I wrote a doclet recently, which I am very proud of - I think it's way
cool in it's practicle simplicity...
http://catchpole.net/bonsaidoc.html
Something which occured to me in the process. The simple power of
interfaces is one of Javas strong points. Its as though Sun didn't
know what they had in their hands, using things such as:
- Static method entry point for Doclets
- non-interfaced "secret squirred" methods for original
"externalizible" interface.
- Using class extension rather than interfaces for many EE classes,
forcing an implementation and compile time dependencies... but maybe
that was their point. :)
On Nov 12, 2:19 pm, Kevin Wong <kevin.peter.w...@gmail.com> wrote:
> I recently listened to a presentation by Gavin King on Seam. He
> describes Seam and, among other things, argues the superiority of its
> approach over that of light containers such as Spring.
I think Seam is meant to be a full-stack, one-stop shop, much like
Rails - and if that's what you need, great. Its not necessarily the
flexibility of Spring to be anything and everything, but that's OK if
that's not what you need.
>
> Now, I've been using Spring for the last 2 years and am writing, by
> all measures, the best code of my career: highly covered, loosely
> coupled, low CRAPload.
>
> So, my question is: Why do I need Java EE? What does it give me that
> Spring cannot?
Chances are, if you're asking, you probably don't need the additional
things EE provides, that would be my first thought. That said, doing
things like managing distributed transactions isn't trivial and its
something that EE provides (or is supposed, some implementations are
better than others). So, if you need to use JMS (receive a message)
then do some work (both locally and maybe with a remote system, either
via web service or say an RMI call) and then send another message or
two out on JMS - and you want all that to either succeed or fail
together, with the common ACID properties we all know and love - then
you'll probably want something like EE to manage that for you. Of
course, there are other things, as well, but again - if you're asking,
you probably don't need it.
> These questions are not rhetorical and I have an open
> mind on this. I just don't have the knowledge or experience to answer
> these myself. BTW, I'm talking about the full-on Java EE requiring a
> Java EE applicaiton server, not the more ubiquitous parts of the spec
> like servlets that can be handled with a web server like Tomcat/
> Jetty. Also, I know that I can use Spring and Java EE together, but
> my question is: Why bother?
>
> Incidentally, here are some reasons why I am averse to using Java EE
> (mostly EJB3):
> - Added deployment complexity of installing/maintaining an application
> server
eh, not really that big a deal. Sure, if you're using Websphere, its a
bit more of a pain, but JBoss, for example, is no more a pain to setup/
maintain/install in its "standard" configurations than Tomcat/Jetty/
Resin.
> - Requires app redeploy to test code changes (this is a big one for
> me)
Nope. We use "exploded" .ear deploys all the time that allow us to
update JSPs, etc. without having to redeploy. Using an IDE like
Eclipse, MyEclipse, etc. (probably Netbeans & IntelliJ, too) that is
"attached" to the VM running your container (this goes for Tomcat or
EE containers) allows you to hot-swap in code changes as well, as long
as the VM itself likes what you're swapping in (this isn't an EE
limitation, per se).
> - Marries me to an API. The "not standards-based" argument is
eh, ok - maybe. But, really - you want to keep your "core" code as
POJOs and just throw in a quick layer here or there when you need to
do something special. Many EE things are just annotations now, or
going that way - so that's fairly unobtrusive (not that I'm ra-ra-ing
for EE). Also, advanced things in Spring aren't any less "married" to
Spring's APIs - if you start doing AOP with Spring & AspectJ, you'll
be writing your advice to those APIs, which won't be compatible with
other AOP implementations.
This is what I've found - we actually use Spring in an EE container
(JBoss) and I've started looking at Seam and I've done a project with
Hibernate/EJB3 and GWT, so I guess I've done a bit of everything
you've mentioned. I think the principles you've learned that's lead to
your writing less CRAPful code will carry through to anything else you
want to do. I'm constantly looking for ways I can inject dependencies,
wrap things in interceptors, etc. - irrespective of the underlying
implementations I'm using.
Hope this helps!
> Chances are, if you're asking, you probably don't need the additional
> things EE provides, that would be my first thought. That said, doing
> things like managing distributed transactions isn't trivial and its
> something that EE provides (or is supposed, some implementations are
> better than others). So, if you need to use JMS (receive a message)
> then do some work (both locally and maybe with a remote system, either
> via web service or say an RMI call) and then send another message or
> two out on JMS - and you want all that to either succeed or fail
> together, with the common ACID properties we all know and love - then
> you'll probably want something like EE to manage that for you. Of
> course, there are other things, as well, but again - if you're asking,
> you probably don't need it.
There seem to be standalone JTA and JMS implementations that can be
easily integrated with Spring without the need for a JEE server
(http://www.javaworld.com/javaworld/jw-04-2007/jw-04-xa.html?fsrc=rss-
index). I have no need for distributed transactions or JMS currently,
but might in the future.
That being said, you have to keep the historical context and business
objectives of the guiding companies in mind, Spring is a direct result
of J2EE/EJB 2.x's failings but now we have the EJB 3 and related
standards. I know you prefer not to hear the "not standards-based"
argument, but even Spring 2.5 is moving towards compatibility with the
new annotations. Standards are a good thing and Spring shouldn't
really be pit against JEE in a feature by feature war, they can
interoperate using standards.
On Nov 13, 12:23 pm, Kevin Wong <kevin.peter.w...@gmail.com> wrote:
> There seem to be standalone JTA and JMS implementations that can be
> easily integrated with Spring without the need for a JEE server
> (http://www.javaworld.com/javaworld/jw-04-2007/jw-04-xa.html?fsrc=rss-
> index). I have no need for distributed transactions or JMS currently,
> but might in the future.
OpenEJB 3 can be embedded in Tomcat and doesn't require a JEE server
(it uses OpenJPA and ActiveMQ for JMS) and as mentioned earlier you
can use a collapsed ear format "hot-swap in code changes" and avoid
deployment issues.
regards,
Dario Laverde
http://javanotebook.com
The nice thing is that you can continue not using a container and if
you ever get to the point where you want to try and see if a container
simplifies things, then your app (by virtue of using Spring) should be
fairly easy to bring up in a decent EE container like JBoss,
Glassfish, WebSphere, etc.
For the record, there's a great many other things that these
containers provide, that aren't necessarily part of the EE spec, but
that these vendors have delivered to meet their customers needs.
Things like clustering, distributed caches, transactional caches, high
availability singletons (singleton running in a cluster w/ failover),
session replication in a cluster, session replication in a subset of a
cluster (if you run big clusters), web service abstractions, etc.
Taken individually, some of these things can also be run independently
(and many, if not most, started off that way) - but again, if you need
these things to work in harmony, then do you want to be on the hook
for that?
The application I'm working on now will run in a JBoss cluster, with
session replication (using JGroups), caching with OSCache, HA
singleton running certain "singleton" threads, XA transactions with WS-
TX and JTA (2-phase commit over a series of web service invocations)
as well as receiving and sending messages via JMS over IBM MQ Series
and accessing and storing data in Oracle and DB2. Its a fairly big
applications and I for one am happy that I don't have to worry about
these things "just working" (mostly because there's another group at
this company that does - and they can lean on JBoss/Redhat).
So, in short, one of the differences may just be - are you in an
"enterprise" where your deployment platform needs to meet the needs of
hundreds of applications using oodles of various legacy tech, or not?
Unfortunately Sun has smeared the line for EE and made it seem that if
you're writing web-apps, you need EE - that's definitely not the case.
Cheers,
Brice
But then: things should be better if you are using OSS (different
culture and you can debug and fix things yourself). And my main
experience was mixing BEA WebLogic with IBM's WebSphere MQ, which is
probably on the bad end of the spectrum of things to do -- but it is
what happens if your client has certain types of product policies. It
worked, but somehow we as a project had to learn quite a few skills
that I'd consider admin/product support.
So I'd personally tend towards integrated solutions. That's of course
only a tendency and there are many other factors to consider -- just
don't forget to ask the question who is going to support problems with
the platform you come up with in the end. That answer can be "we
will", but then make sure you budget for that. Unfortunately it is not
necessarily as easy as just plugging things together.
Cheers,
Peter
Of course, this supposes that you're paying for support (though even
free support is often better than figuring it out yourself). The
company I'm at right now has a JBoss (RedHat) support contract (and an
IBM one), so when we find problems, we have someone to lean on ;-) We
don't have a Spring support contract (would that be Interface21? do
they even do open-ended support? dunno) - but we still manage to use
Spring quite effectively.
Cheers,
Brice
On Nov 13, 5:42 pm, "Peter Becker" <peter.becker...@gmail.com> wrote:
> My experience is that mixing JEE products from different vendors can
> be a pain -- things don't necessarily work well together and of course
> everyone involved says it's not their fault.
>
> But then: things should be better if you are using OSS (different
> culture and you can debug and fix things yourself). And my main
> experience was mixing BEA WebLogic with IBM's WebSphere MQ, which is
> probably on the bad end of the spectrum of things to do -- but it is
> what happens if your client has certain types of product policies. It
> worked, but somehow we as a project had to learn quite a few skills
> that I'd consider admin/product support.
>
> So I'd personally tend towards integrated solutions. That's of course
> only a tendency and there are many other factors to consider -- just
> don't forget to ask the question who is going to support problems with
> the platform you come up with in the end. That answer can be "we
> will", but then make sure you budget for that. Unfortunately it is not
> necessarily as easy as just plugging things together.
>
> Cheers,
> Peter
>
The whole multi-tier vendor-agnostic thing to me is an example of
something that looks good on paper, but in practice rarely works out
for most. It certainly didn't for us when juggling Oracle ADF for a
few years.
Having a thin/simple solution might bind your more to one vendor, but
chances are productivity in this category is so much more powerful
that it would not really cost more to move to another and rewrite some
stuff compared to dealing with a chaotic database/ORM/persistancy/
validation/presentation/server/configuration stack. This can be
witnessed in several places, perhaps most noticably in RoR and .NET
3.5 where i.e. a database is just a dumb data container and nothing
more.
/Casper
(a) the standard itself is not that good, e.g. forgets some scenarios
or is inspecific or even inconsistent -- AFAIK early versions of
Bluetooth fell into that category
(b) they are not enforced properly
I think point (b) is quite interesting. In theory consumer power could
enforce a standard, but it's like assuming voters cast sensible votes
-- sounds good in theory, but in practice other effects can easily
override the sensible behaviour. As example: SQL was a standard as
long as NIST tested it (and no US government agency bought anything
not succeeding the test), it broke apart when NIST stopped the
testing.
I think Sun is doing the right thing with the TCKs and certification
programs. You can still get something that is kind of JEE but not 100%
-- it just won't be certified. If you want to play the safe(r) game,
you take only certified components.
Coming back to JEE: I must admit that I never bothered to fully read
the JEE spec or actually really check who's certified and who's not (I
think that TCK is only a recent thing and I haven't been in any
position to chose a JEE platform lately). But the issues I remember
were all on a level that I strongly suspect will not be covered in the
specs: the administration side. Basic things like the web.xml might be
defined, but all the other configuation issues are always
vendor-specific and I suspect that they always will be -- a lot of
these things can be OS-specific, too. We have had issues on the Java
API levels, but that's the stuff you can easily file as a but
somewhere. The problem is the stuff everyone declares to be someone
else's problem, which means in the end it is yours since you are the
only one who cares. If it is covered in the spec it is easy to tell
who's fault it is if it doesn't work the way it should.
Peter