EJB 3.2 : Remote View – Client and EJBs in Different WARs but Same Container (Tutorial 7)

How to invoke a Session Bean packaged in another WAR and deployed in the Same Container?

Will the client need a Remote or Local View?


Tutorial 1 : Eclipse + Maven 3 + Wildfly 9  

Tutorial 2 : Session Beans

Tutorial 3 : Solution Design

Tutorial 4 : Session Beans and Business Interfaces Projects

Tutorial 5 : Local View – Client and EJBs in the Same WAR

Tutorial 6 : Remote View – Client and EJBs in the Same EAR

Tutorial 7 : Remote View – Client and EJBs in Different WARs but Same Container  EJB 3 Remote View

Tutorial 8 : Remote View – Client and EJBs in different Containers

Tutorial 9 : Standalone Client


We will deploy the Client and the Session Beans in the same Container, but package each one in a different WAR. We will use a JSF Session Scoped Managed Bean to inject/lookup the Session Beans.

Requirement : This tutorial supposes that you have followed the following tutorial successfully Tutorial 4 : Session Beans and Business Interfaces Projects

Client and Session Beans in the different WARs but Same Container

1. Maven Artifacts

  • To create :
ejb3-remote-client-1-war
  • Group Id : com.letsprog.learning
  • Artifact Id : ejb3-remote-client-1-war
  • Version : 0.0.1-SNAPSHOT
  • Packaging : war
  • to improve :
jndi-lookup-util
  • Group Id : com.letsprog.learning
  • Artifact Id : jndi-lookup-util
  • Version : 0.0.1-SNAPSHOT
  • Packaging : jar
  • To use :
ejb3-server-war
  • Group Id : com.letsprog.learning
  • Artifact Id : ejb3-server-war
  • Version : 0.0.1-SNAPSHOT
  • Packaging : war

The artifact ejb3-server-impl was implemented in this tutorial.

2. EJB 3 Remote View : Improving jndi-lookup-util to invoke

We have created this project in Tutorial 5. And we have added the necessary methods for remote Session Beans in Tutorial 6.

In case you didn’t follow the tutorial 6, this is what the LookerUp class must have to support Remoting JNDI Lookup :

3. Creating ejb3-remote-client-1-war

3.1. pom.xml

3.2. The Quiz Managed Bean (Session Beans invocation place)

3.3. The view (GUI)

4. Deployment and Testing

The WAR ejb3-remote-client-1-war contains a Dependency Injection of IRemotePlayedQuizzesCounter. This means that the EJB container will try to look for this dependency on deployment of ejb3-remote-client-1-war. And since IRemotePlayedQuizzesCounter exists in another WAR ejb3-server-war, the latter must be deployed previously. And so you have got to respect the Deployment Order ( Server –then–> Client). Either you do this manually by Eclipse, either you automate it by a CLI script (Command Line Interface of WildFly/JBoss).

// TODO Verify if jboss-all.xml is still supported for WildFly 9 to resolve the problem of Deployment Order.

After a successful deployment, the client Quiz must be accessible through the link : http://localhost:8080/ejb3-remote-client-1-war/index.xhtml

Retro-Flower-Fire-2-iconOk! Now let’s move to the third example of Remote Client!