0 Replies Latest reply on Nov 17, 2016 11:14 AM by Alex Landini

    Wildfly 8: are ejb remote proxy thread safe?

    Alex Landini Newbie

      I have the following situation, in a client ear application there is CDI  `@ApplicationScoped` bean which performs a remote SLSB lookup on `@PostConstruct` callback and caches the obtained proxy:


        @Typed({ ServiceInterface.class })
        public class RemoteServiceProxy implements ServiceInterface
          * Remote service.
          private RemoteService remoteService;
        protected void onPostConstruct()
          remoteService = serviceLocator.lookup(ActivityRemoteEntityService.class);
          Properties jndiProps = new Properties();
          jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
          jndiProps.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
          jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
          jndiProps.put("jboss.naming.client.ejb.context", "true");
          Context context = new InitialContext(jndiProps);
          remoteService = (RemoteService) context.lookup(
          } catch (NamingException e)
            throw new RuntimeException(e);


      I would like to know if the cached proxy in the field `remoteService` is thread-safe, so the `RemoteServiceProxy` can be annotated with `@ApplicationScoped`, or I have to perform a new proxy lookup for each invocation? Or is a best to use `@Stateless`?


      Thanks in advance