EJB 3.2 : Standalone Client (Tutorial 9)

How to lookup an EJB from a standalone client that is not deployed into an EJB container?

How to invoke an EJB from the static main method?


Tutorial 1 : Eclipse + Maven 3 + Wildfly 9  

Tutorial 2 : Session Bean

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

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

Tutorial 9 : Standalone Client  Standalone Client


1. Server Side

1.1. Wildfly Application User

We must make sure that we have the user “ejb-client” with as password “Pwd1234+”, if not create it using the batch file :

{Widlfly_HOME}\bin\add-user.bat

ejb-client-highlight

1.2. EJB Deployment

Let’s just deploy the WAR “ejb3-server-war” we have created in this tutorial. We will reuse the Stateful Session Bean “QuizBean” we have implemented in it.


2. Client Side

2.1. pom.xml :

2.2. EJB3 JNDI Lookup

Now, let’s lookup for the Stateful Session Bean “QuizBean”.

 

2.3. jboss-ejb-client.properties

This file should be placed under “src/main/resources” :

 


3. Let’s run the Standalone Client!

In the Standalone Client console, the question will be displayed and the player must introduce the right answer :