title: Inject EJB in Jersey filter
body: <p>I am currently developing an application with Jersey JAX-RS as backend and AngularJS as frontend ; I need a sort of authentication, and so with every request I send a token that should be verify by the backend. For this, I decided to create a Jersey filter that will look for that token, and then call my AuthenticateService to check if the user can be authenticated. 
  Authorization is then managed by <code>@RolesAllowed</code> annotation.</p>
  
  <p>Here is my problem : I can't inject an EJB inside a Jersey filter, strangly because it works great with resources.. But with a filter, the service always stays <strong>null</strong></p>
  
  <p>Any idea how to trick it ?
  Thanks</p>
  
  <p>Filter code : </p>
  
  <pre><code>@Provider
  @Priority( Priorities.AUTHORIZATION )
  public class AuthenticationFilter implements ContainerRequestFilter {
  
      @EJB( name=AuthenticationService.LOOKUP_NAME)
      private AuthenticationService authService;
  
      @Override
      public void filter( ContainerRequestContext requestContext ) throws IOException {
          /**
           * Get headers parameters
           */
          String userIdStr = requestContext.getHeaderString( SecurityConsts.HEADER_ID_PARAMETER );
          int userId = 0;
  
          if( userIdStr != null &amp;&amp; !userIdStr.isEmpty() ) {
              userId = Integer.parseInt( userIdStr );
          }
  
          String securityToken = requestContext.getHeaderString( SecurityConsts.HEADER_TOKEN );
  
          User user = null;
  
          /**
           * If a token is present, try to authenticate the user
           */
          if( securityToken != null &amp;&amp; !securityToken.isEmpty() ) {
                      // NullPointerException happens here
              user = authService.authenticateWithToken( userId, securityToken );
          }
  
          /**
           * Set correct security context
           */
          requestContext.setSecurityContext( new ConfiguratorSecurityContext( user ) );
      }
  
  }
  </code></pre>