EJB 3 Local Remote Interface example

EJB 3 Local Remote Interface example

In this example you will see how to create EJB 3 application with local and remote interface.
Local Interface: This interface has been introduced for client if he is running in the same container.
Remote Interface: As per its definition it’s designed for client which resided out side of the EJB container.

Important: It’s confusing if you are thinking about if web application which is not inside EAR file and packaged in separate WAR file but running on same instance of application server.
Answer: Once beans which is annotated with @Local then it will accessed only in same application means client should be packaged in same EAR file. If application has been packaged in different WAR and EAR file means it’s two different application here remote interface will be called.

Below are needed:

  • JBoss Application Server 5.1 community version
  • Eclipse 3.3 or up (For this demo we have used Kepler)


  • Create project name EJB3
  • Final project structure

EJB 3 Local Remote Interface example

  • Calculator.java

  • CalculatorLocal.java

  • CalculatorRemote.java

  • CalculatorClient.java

  •  We are all done with EJB 3 classes. Before run this project you will have to configure JBoss server to eclipse and if are not sure how to do it please use this tutorial. Now to run project on JBoss server –> Right click Project –> Run As –> Run on Server
  • Once server is started please verify below on console:

EJB 3 Local Remote Interface example

  • Run the CalculatorClient –> Right click –> Run As –> Java Applicaton:

EJB 3 Local Remote Interface example

  • That’s it for more information on EJB 3 please use this link

download Download Project: EJB3

Leave a Reply

Your email address will not be published. Required fields are marked *

I am not Robot *