title: Roles Based Security for EJB deployed on Weblogic
body: <p>I am working on an EJB application. I have to apply role based security on session bean(EJB3) methods, for which I tried annotating the session bean method with "@RolesAllowed" as below,</p>
  
  <p>For creating User, groups and roles i am using jazn-data.xml as below,</p>
  
  <p>After the deploying the EJB and running the application, security does get applied and throws an exception [EJB:010160]Security Violation: User: 'XXX' has insufficient permission to access EJB</p>
  
  <p>After Adding the weblogic ejb deployment descriptor as below,</p>
  
  <pre><code>&lt;?xml version = '1.0' encoding = 'windows-1252'?&gt;
  &lt;weblogic-ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar http://xmlns.oracle.com/weblogic/weblogic-ejb-jar/1.1/weblogic-ejb-jar.xsd"
                    xmlns="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar"&gt;
      &lt;weblogic-enterprise-bean&gt;
          &lt;ejb-name&gt;ApplicationFacade&lt;/ejb-name&gt;
          &lt;stateless-session-descriptor/&gt;
          &lt;enable-call-by-reference&gt;true&lt;/enable-call-by-reference&gt;
      &lt;/weblogic-enterprise-bean&gt;
      &lt;security-role-assignment&gt;
          &lt;role-name&gt;PVUser&lt;/role-name&gt;
          &lt;principal-name&gt;pv&lt;/principal-name&gt;
      &lt;/security-role-assignment&gt;
      &lt;security-role-assignment&gt;
          &lt;role-name&gt;PRUser&lt;/role-name&gt;
          &lt;principal-name&gt;pr&lt;/principal-name&gt;
  
      &lt;/security-role-assignment&gt;
  &lt;/weblogic-ejb-jar&gt;
  </code></pre>
  
  <p>It starts working as expected.</p>
  
  <p>My question is related to weblogic ejb deployment descriptor(weblogic-ejb-jar.xml), do I have to make an entry for each user (pricipal-name), each time I am adding a new user or is there a way by which i can map a user-groups?</p>
  
  <p>Also let me know if I have missed any other configuration required to add permissions.</p>