0 Replies Latest reply on Apr 6, 2011 2:54 AM by Christian Reiter

    @SecurityDomain doesn't work with @Singleton

    Christian Reiter Newbie

      Hello!

       

      In Jboss AS 6 (6.0.0.Final) the Annotation @SecurityDomain from the package org.jboss.ejb3.annotation.SecurityDomain doesn't seem to work with @Singleton - SessionBeans.

       

      If I try to call a method from a @Singleton which is marked with @RolesAllowed i get a "java.lang.IllegalStateException: Security Context has not been set" Exception. If I do completely the same with a @Stateless SessionBean everything works fine.

       

      Is this a bug in JBoss AS6?

       

      I've attached a simple example with this posting.

       

      Here are my beans:

       

      {code}

      import javax.annotation.security.RolesAllowed;

      import javax.ejb.Singleton;

      import org.jboss.ejb3.annotation.SecurityDomain;

       

      @SecurityDomain("SingletonTest")

      @Singleton

      public class MySingletonBean implements MySingletonBeanRemote {

       

          @RolesAllowed("Role1")

          @Override

          public String sayHello() {

              return "Hello MySingletonBeanRemote " + System.currentTimeMillis();

          }

      }

      {code}

       

       

      {code}

      import javax.annotation.security.RolesAllowed;

      import javax.ejb.Stateless;

      import org.jboss.ejb3.annotation.SecurityDomain;

       

      @SecurityDomain("SingletonTest")

      @Stateless

      public class MyStatelessBean implements MyStatelessBeanRemote {

       

          @RolesAllowed("Role1")

          @Override

          public String sayHello() {

              return "Hello MyStatelessBeanRemote " + System.currentTimeMillis();

          }       

       

      }

      {code}

       

       

      Thanks in advance for your Help!

       

      Best Regards,

       

      Christian