5 Replies Latest reply on Nov 1, 2012 10:37 AM by nva

    Problem using @AuthenticationRequired on RPC service endpoint

    nva Newbie

      I'm using Errai RPC as described in chapter 5. of the manual and implemented a custom login adapter for security. When annotating my service endpoints (annotated with @Service) with @AuthenticationRequired to secure them, I get the following exception during startup:

       

      Caused by: java.lang.RuntimeException: no such subject: UserServiceImpl

      at org.jboss.errai.bus.server.ServerMessageBusImpl.addRule(ServerMessageBusImpl.java:847)

      at org.jboss.errai.bus.server.service.ServiceProcessor.process(ServiceProcessor.java:181)

      at org.jboss.errai.bus.server.service.ServiceProcessor.process(ServiceProcessor.java:61)

      at org.jboss.errai.bus.server.service.bootstrap.DiscoverServices.execute(DiscoverServices.java:52)

      at org.jboss.errai.bus.server.service.bootstrap.OrderedBootstrap.execute(OrderedBootstrap.java:55)

      at org.jboss.errai.bus.server.service.ErraiServiceImpl.boostrap(ErraiServiceImpl.java:70)

      at org.jboss.errai.bus.server.service.ErraiServiceImpl.<init>(ErraiServiceImpl.java:65)

      at org.jboss.errai.bus.server.service.ErraiServiceImpl$$FastClassByGuice$$7879947c.newInstance(<generated>)

      at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)

      at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:60)

      at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)

      at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)

      at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)

      at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)

      at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)

      at com.google.inject.Scopes$1$1.get(Scopes.java:65)

      at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)

      at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:54)

      at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:978)

      at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1024)

      at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:974)

      at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1013)

      at org.jboss.errai.bus.server.service.ErraiServiceFactory.create(ErraiServiceFactory.java:14)

      at org.jboss.errai.bus.server.service.ErraiServiceSingleton.initSingleton(ErraiServiceSingleton.java:15)

      at org.jboss.errai.bus.server.servlet.ServletBootstrapUtil.initService(ServletBootstrapUtil.java:104)

      at org.jboss.errai.bus.server.servlet.ServletBootstrapUtil.getService(ServletBootstrapUtil.java:54)

      at org.jboss.errai.bus.server.servlet.AbstractErraiServlet.init(AbstractErraiServlet.java:71)

      at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:433)

      at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:256)

      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)

      at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:616)

      at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)

      at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220)

      at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513)

      at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)

      at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:468)

      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)

      at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)

      at org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115)

      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)

      at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)

      at org.mortbay.jetty.Server.doStart(Server.java:222)

      at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)

      at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:672)

      at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509)

      at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1068)

      at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:811)

      at com.google.gwt.dev.DevMode.main(DevMode.java:311)

       

      Sample code to reproduce the problem:

       

      @Remote

      public interface UserService {

       

           public Boolean save(String username, String password);

      }

       

      @Service

      @RequireAuthentication

      public class UserServiceImpl implements UserService {

       

          public Boolean save(String username, String password) {

       

          }

      }

       

      Adding an explicit service name in the @Service annotation makes no difference. However, on a bus endpoint it works perfectly. What am I doing wrong? Thanks!