Apologies for the long question.. there seems to be other similar questions on here but none really clear up my confusion.
I'd be really grateful if someone could confirm or correct my understanding:
Java Enterprise Edition is a set of APIs for building enterprise applications, which take away the burden of developing parts of the system that aren't actually features of the application you are trying to build (i.e. messaging, transactions etc).
To do this, you can use an application server, which implements these APIs. So you could use JBoss, Glassfish, WebSphere, WebLogic etc which would provide your application with these enterprise services.
However, there are many other implementations of these individual services available such as ActiveMQ for messaging, Hibernate for persistence, OpenEJB etc.
You can download these implementations as Java libraries and include them in your application, and use the services they provide in a similar way to using the services provided by an application server.
So if my understanding is correct, my questions are:
I've read a lot of places that application servers are necessary for JEE features like EJB, but can't you just use an implementation such as OpenEJB and not need an application server at all?
Are there any features that an application server provides which you cannot get from another source?
Why would/wouldn't I choose an application server over a custom stack such as Tomcat, OpenEJB, ActiveMQ, and Hibernate?
Is Spring a complete alternative to JEE? Does it ever require an application server or always just a servlet container? Why would someone choose Spring over JEE?
Any help would be much appreciated!