O'Reilly logo

Mastering Java EE Development with WildFly by Luca Stancapiano

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Local and remote interfaces

By default, an EJB is always local. A local EJB can be invoked only inside the same deployment package. A good coupling for the local EJB is the CDI injection. In previous paragraphs, we used the @Inject annotation to inject the EJB. It is only possible if the EJBs are local.

The annotation that represents a local EJB is @Local. Our EJB, by default, can be seen as annotated with it:

@Singleton@Localpublic class MyPosts {...}

The remote EJB can be invoked by a different deployment package through JNDI. Here is an implementation of remote EJB:

@Singleton@Remotepublic class MyHarderPosts {...}

When we deploy a remote EJB, WildFly automatically creates three RMI stubs named through a JNDI name. Here is a sample ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required