title: javax.ejb.EJBAccessException: Caller unauthorized
body: <p>I encountered above exception after migrating an application from QuartzMDB with  quartz-ra.rar to EJB Timers in Jboss AS 6.1 . (As a part of upgrading application to wildfly 8.1)</p>
  
  <p>Exception is occurred at a job that uses following ejb.</p>
  
  <pre><code>@Stateless
  @TransactionAttribute(TransactionAttributeType.REQUIRED)
  @RolesAllowed({"admin"})
  public class PlatformPluginBean implements PlatformPluginRemote {
  
      // some code here
  
      public Collection&lt;PlatformPlugin&gt; getPlugins() {
          return new ArrayList&lt;PlatformPlugin&gt;(schemaToPlugin.values());
      }
  
  }
  </code></pre>
  
  <p>Following is the job before migration which worked fine.</p>
  
  <pre><code>@MessageDriven(activationConfig = {
      @ActivationConfigProperty(propertyName = "cronTrigger", propertyValue = "0 0 * * * ?"),
      @ActivationConfigProperty(propertyName = "jobName", propertyValue = "PruneJob")})
  @ResourceAdapter("quartz-ra.rar")
  @RunAs("admin")
  public class PruneJob implements Job {
  
      @EJB
      private PlatformPluginRemote platformPluginRemote;
  
      @Override
      public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
  
          for (PlatformPlugin platformPlugin: platformPluginRemote.getPlugins()) {
              // some stuff here
          }
      }
  }
  </code></pre>
  
  <p>Following is the job after changing to ejb auto timer.</p>
  
  <pre><code>@Stateless
  @RunAs("admin")
  public class PruneJob {
  
      @EJB
      private PlatformPluginRemote platformPluginRemote;
  
      @Schedule(hour="*", minute="0", persistent=false)
      public void execute() {
  
          for (PlatformPlugin platformPlugin: platformPluginRemote.getPlugins()) {
              // some stuff here
          }
      }
  }
  </code></pre>
  
  <p>The exception is occurred at <code>platformPluginRemote.getPlugins()</code> call.</p>