I am trying to implement my own ContainerRequestFilter and configure SecurityContext. It works well on jax-rs resources but EJB jax-rs throws
I finally resolved it. I could not use javax.security.RolesAllowed since it is handled differently from EJB container. So I implemented my own RolesAllowed annotation. It has a disadvantage that it is not so advanced as implementation of original javax.security.RolesAllowed. For example it does not support entity filtering like it is described in here. There is a demand from Java EE comunity for integration of security in next Java EE 8 release and I hope we'll see better solution.
I put the working example on github.