Over a million developers have joined DZone.

Where Can I Run EJBs ?

· Java Zone

What every Java engineer should know about microservices: Reactive Microservices Architecture.  Brought to you in partnership with Lightbend.

EJBs are built for more than just a Java EE application server. They can also execute in aJava EE Web Profile container or plain Java SE environment (Java SE ! yeah – Easy JavaBeans !).

EJB Lite

  • Required to support only a subset of the features which are provided by the full EJB specification – a lightweight version of the same
  • A Java EE Web Profile certified container has to support the EJB Lite spec

Embedded Container

  • Embedded = in-memory
  • Executes in a JVM (plain Java SE environment) e.g. just as a part of bigger Java SE, JavaFX or a Swing application
  • Required to support all the features within the EJB Lite spec.
  • e.g – Open EJB
public class EmbeddedEJBExample{
	//inject an EJB available on the classpath
	MyLocalEJB local;
	//use JNDI to talk to remotely deployed EJBs (via RMI)
	EJBContainer container = EJBContainer.createEJBContainer();
	Context context = container.getContext();
	ARemoteEJB remote = (ARemoteEJB) context.lookup(<provide JNDI name here >)

Application Client Container

  • Technically not an EJB container
  • Executes in a Java SE environment but it has some Java EE capabilities as well
  • Because of it’s Java EE related features, it can be used to talk to remotely deployed EJBs using DI (@EJB) or JNDI calls

EC and ACC are not the same

  • An Embedded Container provides a run time to host EJBs themselves
  • Application Client Containers are meant to host clients of remote EJBs apart from providing the ability to consume other services deployed on remote Java EE servers e.g. interaction with JMS destinations etc.

Microservices for Java, explained. Revitalize your legacy systems (and your career) with Reactive Microservices Architecture, a free O'Reilly book. Brought to you in partnership with Lightbend.


Published at DZone with permission of Abhishek Gupta, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}