2 Replies Latest reply on Mar 5, 2015 6:37 AM by Wolf-Dieter Fink

    Calling remote EJB from another Wildfly

    Stefan Schubert Newbie

      Hi all,

      My current problem in general is, that i have two Wildfly 8.2.0Final instances running on my machine.
      One of them holds a restful application that triggers a stateless session bean SenderBean when it receives a GET.
      Afterwards, this stateless session bean should invoke a method from a remote stateless session bean
      PrintBean, which is located on the other wildfly instance.

      I'll start of by explaining what i have done so far (maybe i missed something, i'm quite new to Java EE and Wildfly).

      I'm going to call the Wildfly instance with the SenderBean the Sender and the one with the PrintBean the Receiver.

      I created an Application user named Stefan with Password stefan, belonging to group guest on the Receiver. On the Sender, in the standalone-full.xml, i added a Security-Realm by putting

      <security-realm name="ejb-security-realm">

      <server-identities>

      <secret value="c3R1ZmFu"/>

      </server-identities>

      </security-realm>

      into the <security-realms> section. I also added a outbound-socket-binding by putting

      <outbound-socket-binding name="remote-ejb">

      <remote-destination host="localhost" port="8080"/>

      </outbound-socket-binding>

      into the <socket-binding-group ...> section. Last, i created an outbound-connection, by putting

      <outbound-connections>

      <remote-outbound-connection name="remote-ejb-connection" outbound-socket-binding-ref="remote-ejb" username="Stefan" security-realm="ejb-security-realm">

        <properties>

      <property name="SASL_POLICY_NOANONYMOUS" value="false"/>

      <property name="SSL_ENABLED" value="false"/>

      </properties>

      </remote-outbound-connection>

      </outbound-connections>

      into the <subsystem xmlns="urn:jboss:domain:remoting:2.0"> section.

      I start the Sender with the CLI command standalone.bat -c standalone-full.xml -Djboss.socket.binding.port-offset=100 -Djboss.node.name=Sender and the Receiver with standalone.bat -c standalone-full.xml -Djboss.node.name=Receiver.

      The Local Stateless Session Bean on the Sender is called SenderBean:

      @Stateless

      public class SenderBean implements SenderService {

       

        @EJB(lookup="ejb:baseproject-ear-01.00.00-SNAPSHOT/testdomain-service-01.00.00-SNAPSHOT/Receiver/PrintBean!com.schubert.baseproject.testdomain.service.PrintService")

      private PrintService printer;

        private static final Logger logger = Logger.getLogger(SenderBean.class.getSimpleName());

      public void send(){

      logger.info("Trying to invoke"); this.invoke();

      }

       

      private void invoke() {

      logger.info("Printing using remote ejb: "+s.print("Markus"));

      }

      }

      And the Receiver contains the PrintBean:

      @Stateless

      @Remote(PrintService.class)

      public class PrintBean implements PrintService {

      @Override

      public String print(String name) {

      return "Hello " + name;

      }

      }

      the problem now is, I always get a IllegalStateException that says EJBCLIENT000025: No EJB receiver available for handling ...

      Am I maybe doing something very wrong? I am fairly new to EJBs and Wildfly. You can find the project setup on Urr4/wildfly-communication · GitHub