7 Replies Latest reply on Mar 17, 2014 7:19 PM by Cristian Miranda

    Errai Testing - Calling RPC

    Cristian Miranda Newbie

      Hi guys,


           I've created a test for an RPC and I'm having the following error: http://pastebin.com/FjpbbRpH


      package app.client.local;
      import app.client.shared.service.AsyncRPCService;
      import org.jboss.errai.bus.client.api.base.MessageBuilder;
      import org.jboss.errai.bus.client.tests.AbstractErraiTest;
      import org.jboss.errai.common.client.api.RemoteCallback;
      * Created by cristianmiranda on 3/13/14.
      public class GreetingRPCTest extends AbstractErraiTest {
      public String getModuleName() {
           return "app.App";
      protected void gwtSetUp() throws Exception {
      public void testcreateStrategy() throws Exception {
        System.out.println("-- Testing create strategy --");
        runAfterInit(new Runnable() {
             public void run() {
                  MessageBuilder.createCall(new RemoteCallback<String>() {
                       public void callback(String response) {
                            System.out.println("-- Got a response! --");        
                            assertEquals("foobar", response);                  
                  }, AsyncRPCService.class).doSomeTask();


      I already have this in my web.xml:




           My @Remote interface is in the client package and my @Service implementation is in the server package.

           Server side service is not being found in ServiceProcessor.java:70


        public void process(final BootstrapContext context, MetaDataScanner reflections) {
          final ErraiServiceConfiguratorImpl config = (ErraiServiceConfiguratorImpl) context.getConfig();
          final Set<Class<?>> services = reflections.getTypesAnnotatedWithExcluding(Service.class, CLIENT_PKG_REGEX);
          final Set<Method> methodServices = reflections.getMethodsAnnotatedWithExcluding(Service.class, CLIENT_PKG_REGEX);
          for (Class<?> loadClass : services) {
            processServiceClass(loadClass, context, config);
          for (Method loadMethod : methodServices) {
            processServiceMethod(loadMethod, context, config);


      I have debugged the sources and noticed the following in ClientMessageBusImpl.java:793


      if (!localOnly && remotes.containsKey(subject)) {
              //  LogUtil.log("[bus] sent to remote: " + message);
                routedToRemote = true;


                ... remotes does not contain my Remote service AsyncRPCService (it is annotated with @org.jboss.errai.bus.server.annotations.Remote)


      I see this in my generated RpcProxyLoaderImpl.java


      class app_client_shared_service_AsyncRPCServiceImpl extends AbstractRpcProxy implements AsyncRPCService { public CallableFuture doSomeTask() {
              RemoteCallSendable sendable = null;
              if (errorCallback == null) {
                sendable = MessageBuilder.createCall().call("app.client.shared.service.AsyncRPCService").endpoint("doSomeTask:", qualifiers, new Object[] { }).respondTo(CallableFuture.class, remoteCallback).defaultErrorHandling();
              } else {
                sendable = MessageBuilder.createCall().call("app.client.shared.service.AsyncRPCService").endpoint("doSomeTask:", qualifiers, new Object[] { }).respondTo(CallableFuture.class, remoteCallback).errorsHandledBy(errorCallback);
              app_client_shared_service_AsyncRPCServiceImpl.this.sendRequest(bus, sendable);
              return null;
          RemoteServiceProxyFactory.addRemoteProxy(AsyncRPCService.class, new ProxyProvider() {
            public Object getProxy() {
              return new app_client_shared_service_AsyncRPCServiceImpl();


           Here is my App.gwt.xml: http://pastebin.com/Dj70VRzL


      Any ideas?


      Thanks in advance!

        • 1. Re: Errai Testing - Calling RPC
          Anton Hughes Master

          Hi Max and Christian - I know you guys are very busy working on the next stable release.

          If you can help us with this issue, it would be greatly appreciated!



          • 2. Re: Errai Testing - Calling RPC
            Victor Wjugow Newbie

            Hi, I'm having the exact same issue, I took this example errai/errai-bus/src/test/java/org/jboss/errai/bus/client/tests/AsyncRPCServicesTest.java at master · errai/errai · GitHu… but seems like there's something wrong on the server side configuration, it seems like the "server side" hasn't subscribed to the message bus so no rpc calls get executed

            • 3. Re: Errai Testing - Calling RPC
              Victor Wjugow Newbie

              Code for @Service class

              package app.server.service;
              import app.client.shared.service.AsyncRPCService;
              import org.jboss.errai.bus.client.api.CallableFuture;
              import org.jboss.errai.bus.server.annotations.Service;
              import org.jboss.errai.bus.server.api.CallableFutureFactory;
              import java.util.concurrent.Executors;
               * @author Mike Brock
              public class AsyncRpcServiceImpl implements AsyncRPCService {
                public CallableFuture<String> doSomeTask() {
                final CallableFuture<String> future = CallableFutureFactory.get().createFuture();
                final java.util.concurrent.ExecutorService executorService = Executors.newSingleThreadExecutor();
                executorService.submit(new Runnable() {
                public void run() {
                try {
                catch (Throwable t) {
                return future;
              • 4. Re: Re: Errai Testing - Calling RPC
                Max Barkley Expert



                Can you please try the following:

                • Create a log4j.properites in src/test/resources with the following contents:
                log4j.rootLogger=DEBUG, CONSOLE
                log4j.appender.CONSOLE.layout.ConversionPattern=%d [%t] %-5p %c{1} - %m%n
                • Run your test.
                • Look for output that looks like this (there'll be a lot of output, but this should be near the beginning):
                2014-03-14 10:31:29,217 [Thread-10] DEBUG ClasspathScanning - scanning inside: /home/yyz/mbarkley/Documents/errai-projects/errai/errai-bus/target/test-classes/
                2014-03-14 10:31:29,218 [Thread-10] DEBUG ClasspathScanning - scanning inside: /home/yyz/mbarkley/Documents/errai-projects/errai/errai-bus/target/classes/
                2014-03-14 10:31:29,218 [Thread-10] DEBUG ClasspathScanning - scanning inside: /home/yyz/mbarkley/.m2/repository/org/jboss/errai/errai-common/3.0-SNAPSHOT/errai-common-3.0-SNAPSHOT.jar
                2014-03-14 10:31:29,218 [Thread-10] DEBUG ClasspathScanning - scanning inside: /home/yyz/mbarkley/.m2/repository/org/jboss/errai/errai-marshalling/3.0-SNAPSHOT/errai-marshalling-3.0-SNAPSHOT.jar
                2014-03-14 10:31:29,256 [Thread-10] DEBUG Reflections - going to scan these urls:


                Instead of the paths shown here, you should see:

                • The errai-bus jar.
                • The jar path to your @Service class.
                1 of 1 people found this helpful
                • 6. Re: Errai Testing - Calling RPC
                  Victor Wjugow Newbie

                  Ok, so this turned out to be a class path error. We've fixed that by having this in the pom:




                  Now we know that both main and test are being included in the classpath (checked by debugging errai sources)


                  Now we are getting this:




                  If I comment the reference to that interface, another one throws same error. It happens with all fields that have @javax.inject.Inject annotation.

                  I tried using @google.inject.Inject but same error occurs.

                  If anyone can help it would be very appreciated!


                  Thanks in advanced.

                  • 7. Re: Errai Testing - Calling RPC
                    Cristian Miranda Newbie

                    Hi guys, after debugging the sources we've found that the error occurs when trying to find an implementation for the bean interface.

                    I don't know if it helps but here is the piece of code where the exception is thrown, in OrderedBootstrap:56


                    public void execute(final BootstrapContext context) {

                        log.info("starting errai bus ...");

                        try {

                          for (BootstrapExecution execution : bootstrap) {

                           execution.execute(context); // THIS IS THE LINE FAILING



                          ((ErraiServiceConfiguratorImpl) context.getConfig()).lockdown();

                          log.info("errai bus started.");


                        catch (Exception e) {


                          throw new RuntimeException("server bootstrap failed", e);




                    ... and a bit deeper in InjectorImpl:961


                    public <T> Provider<T> getProvider(Class<T> type) {

                        return getProvider(Key.get(type));