• Post Reply Bookmark Topic Watch Topic
  • New Topic

@DeclareRoles vs @RolesAllowed  RSS feed

Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am preparing for SCBCD5 exam and have some doubts about these annotations.

I have good knowledge about security in older version of EJBs. But finding it hard to understand in EJB3.

RolesAllowed annotation is used to declare logical roles instead of declaring them in the deployment descriptor?

What is the use of DeclareRoles annotation? is it also used to declare new logical role name ?e.g.

or used to refer the name used programmatically in ejb?


in the above code i have declared two roles "employee","manager" but the code itself uses only one role.So the container will create a new role called employee which is equivalent to <security-role><role-name>employee</role-name></security-role>?

i got the above question as i was going through the specification and it says :

The set of security roles used by the application is taken to be the aggregation of the security roles defined by the security role names used in the DeclareRoles and RolesAllowed annotations. The Bean Provider may augment the set of security roles defined for the application by annotations in this way by means of the security-role deployment descriptor element.


It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!