In this tutorial we will show how you can configure two JBoss AS 7 server instances to call each other via EJB.

Calling EJB which are located on a remote EJB server is done differentely depending if the remote client is a standalone client or if the client is located on another instance of JBoss AS 7.

J2SE Standalone clients will use a file name which defines the host name where EJBs are deployed along with other settings such as application username and password. You can read more on this tutorial which describes step by step how to configure your standalone clients.

Java EE clients located on another application server will need another procedure and another file named jboss-ejb-client.xml which is used by the Remote clients. In order to complete this procedure you will need to configure an application user on the JBoss AS 7 "server" (which exposes the EJBs) and configure an outbound remote connection on the JBoss AS 7 "client" which points to the "server" machine.

jboss as 7 remote ejb client

JBoss AS 7 "server" configuration:

So at first thing we will do is creating an application user on the JBoss AS 7 server:

What type of user do you wish to add?
a) Management User (
b) Application User (
(a): b
Enter the details of the new user to add.
Realm (ApplicationRealm) :
Username : user1234
Password : password1234
Re-enter Password : password1234
What roles do you want this user to belong to? (Please enter a comma separated list, or leave blank
for none) :
About to add user 'user1234' for realm 'ApplicationRealm'
Is this correct yes/no? yes
Added user 'ejb' to file '/jboss-as-7.1.1.Final/standalone/configuration/'
Added user 'ejb' to file '/jboss-as-7.1.1.Final/domain/configuration/'
Added user 'ejb' with roles to file '/jboss-as-7.1.1.Final/standalone/configuration/'
Added user 'ejb' with roles to file '/jboss-as-7.1.1.Final/domain/configuration/'

Next step, you need to generate a base64 encoded string ("secret") for your password. If you are using a JBoss AS 7.1.2 release (e.g. 7.1.2 Alpha) you get it printed on the console automatically. For the 7.1.1 release you can use an online utility such as
In our example the base64 encoded password is cGFzc3dvcmQxMjM0ed

JBoss AS 7 "client" configuration:

Create a security realm which contains the password generated into the secret element:

            . . . . . .
            <security-realm name="ejb-security-realm">
                            <secret value="cGFzc3dvcmQxMjM0"/>

Now configure the outbound socket connection toward the "remote" JBoss AS 7 server. This will be done in two points of your configuration:

1) Into the remoting subsystem:

<subsystem xmlns="urn:jboss:domain:remoting:1.1">
    <connector name="remoting-connector" socket-binding="remoting" security-realm="ApplicationRealm"/>
              <remote-outbound-connection name="remote-ejb-connection" outbound-socket-binding-ref="remote-ejb"
                  username="user1234" security-realm="ejb-security-realm">
                     <property name="SASL_POLICY_NOANONYMOUS" value="false"/>
                     <property name="SSL_ENABLED" value="false"/>

2) Into the socketbinding group, where you need to specify the host name and port where you are going to connect (Replace with the IP Address of the JBoss AS 7 "server")
<socket-binding-group name="standard-sockets" default-interface="public">
. . . .
     <outbound-socket-binding name="remote-ejb">
          <remote-destination host="" port="4447"/>

Application changes:
In terms of application code, you need to include the file jboss-ejb-client.xml into your client application which describes the outbound-connection to use for the EJB calls. Please note that this file needs to be placed into the META-INF folder of your EAR file or the WEB-INF of your Web application.


<jboss-ejb-client xmlns="urn:jboss:ejb-client:1.2"> 
  <client-context >
     <ejb-receivers exclude-local-receiver="true">
         <remoting-ejb-receiver outbound-connection-ref="remote-ejb-connection" >

That's all.

Please notice that if you are starting both JBoss AS 7 servers on the same machine you need to specify a port offset for one of the two servers and a unique name



standalone.bat -Djboss.socket.binding.port-offset=150

If you need an example of EJB to EJB communication in a clustered environment, we suggest having a look at this tutorial: EJB to EJB communication in a cluster (JBoss AS 7 - WildFly)


Related articles available on

JBoss AS 7 introduction

This is an introduction tutorial to the newest JBoss AS 7 which a

Develop Java EE applications on WildFly

In this tutorial we will learn how to develop a basic Java EE 8 a

Adding users with JBoss AS 7

If you are planning to add new users to your management interface

Using JBoss AS 7 management API programmatically

In this tutorial we will show how to use detyped management API t

JNDI view in JBoss AS 7

JNDI can be checked on the naming subsystem of the application se

How to install a module on WildFly / JBoss AS 7

Installing a module on WildFly / JBoss AS 7 requires creating a p