Reputation: 421
I've read the wikipedia articles. I've browsed the Oracle tutorials. I've Googled, binged and Yahooed, and still, I am choking on the most basic fundamentals of Java EE (5+).
Must all Java EE architectures involve an application server, such as JBoss or GlassFish, at some point? Essentially, is the concept of the application server fundamental to Java EE, and why/why not?
Beyond application servers, are there any other major components that a Java EE architecture depends on? If so, what are they and how do they "snap into" the architecture and relate to the application server?
I'm really choking on the concept of EJBs. From everything I've been able to find on them, I can't tell if EJB is a specification for developers to use (whereby complying with the EJB spec produces a unit of code that can be called a "bean"), or if its like any other Java library, like JDBC or JMS.
(a) In the King's English, without using advanced, already-in-the-know concepts or marketing buzzwords, what is EJB? Can you provide a few quick & dirty examples of (an) EJB?
(b) How does EJB interface/interact with an application server?
(c) What is an EJB "container", and what does it do?
It seems to me like there are a lot of top-level components that make up a Java EE backend, and that for each type of these components, there are a lot of both open- and closed-source varieties out there that you, the system engineer, must choose from.
Seeing that I am so confused on Java EE fundamental already, below is a list of some products I have heard about. I am simply asking for someone to help me categorize these products so I can see, in plain sight, what they are. For instance, if I list "GlassFish" and "JBoss", then they might appear in the category of "Application Servers." If I list "Tomcat" and "WebSphere", they might appear under "Servlet Engines", etc.
The list:
5. What's the difference between Java EE 6 and Java EE 6 "Web Profile"?
Upvotes: 25
Views: 4796
Reputation: 11906
Bozho gave an excellent answer to your question, so I'll just add this one thing.
The reason you're struggling is not because they are hard to learn, because there are a lot to learn and you are trying to learn them all at the same time. If you were to learn them one at a time, you'd be fine.
The easiest way to get started is Servlet and JSP. Most Java EE applications use these technologies and novice developers will be given these tasks in most projects, so they are practical. Servlet and JSP are specification that lets you to generate mostly web pages with dynamic(= variable) content. Tomcat is a web container that implements Servlet and JSP and provides a run-time environment for Servlet and JSP components. I recommend Tomcat because it is open-source, and has the largest market share.
I'd recommend Core Servlets and Javaserver Pages by Marty Hall for a beginner's book. It's a very easy read.
Upvotes: 3
Reputation: 38163
Bozho indeed gave an excellent answer. For some additional details about Java EE the following answer I gave to an other question might be relevant: Frameworks for Layering reusable Architectures
You might also want to read the article I edited on wikipedia about EJB: http://en.wikipedia.org/wiki/Enterprise_JavaBean
To add a little to sub-question 3:
You can see an EJB container as kind-of extended JVM. The 'normal' JVM offers the service of automatically managing the memory for Java classes. The EJB container offers additional services like automatically managing transactions and pooling.
To make a regular class an EJB is really simple. You only have to add the @Stateless annotation:
@Stateless
public class SomeBean {
// ...
}
After this, all methods in the bean are automatically transactional and instances of SomeBean are automatically pooled instead of re-created whenever they are needed.
An important thing to realize is that this kind of "managed beans" can not be instantiated with the regular new operator. They have to be injected via an annotation. If you use the analogy with the normal JVM again, you could say this annotation is a kind of "managed new operator":
public class SomeOtherManagedBean {
@EJB
SomeBean someBean;
}
The catch is that injection here only works in other managed beans. From an unmanaged environment you can bootstrap an instance via a JNDI lookup.
In Java EE, EJB beans are traditionally meant to contain only pure business logic. In the last version of Java EE, Java EE 6, an attempt has been started to bring the managed bean concept in a unified component model to all parts of the application. This is done via the CDI specification, which also defines a component type simply called "managed bean". It is possible that the EJB model will eventually be retrofitted as a set of CDI annotations.
Upvotes: 5
Reputation: 597096
No. You can run multiple parts of JavaEE in containers that are not applications servers. Servlets/JSP/JSF you can run on a servlet container. JPA - you can use with any setup.
All parts of the JavaEE "family" can be used standalone, i.e. outside of application servers. Servlet containers. JMS providers. JTA managers. Even EJB containers.
EJB before version 3 provided a set of interfaces you should implement in order for your classes to be managed by the EJB container. Since 3.0 the EJB spec defines mainly annotations (from the developer perspective). Apart from that it is a specification on how the EJB container (part of application servers) should handle your EJBs
Glassfish, JBoss and Geronimo (and a few others) are full-featured application servers. Tomcat, Jetty and Spring tc server are just servlet containers - they only handle the servlet/jsp part of JavaEE. They may have additional features (like the enterprise monitoring features of tc server). Hibernate is an implementation of JPA - object-relational mapping (in short - you work with objects rather than with JDBC). RabbitMQ is a message queue, and I'm not even sure it conforms to the JMS spec (part of JavaEE). GemFire has nothing to do with JavaEE
The "Web Profile" includes only some parts (the most often used ones in web applications) of JavaEE - servlets, jsp, CDI, JPA, JSF, EJB (lite). It does not include stuff like JMS, JAX-WS, etc. Here is a table of what is included and what's not included in the web profile. The idea is that some application servers will be certified even if they do not implement all the specifications included in JavaEE. Caucho Resin will be such an application server that supports only the web profile.
Upvotes: 16