hibernate - Jboss, use enterprise bean in security interceptor -


i'm new j2ee , have jboss implementation of rest-based web service. i'm not familiar frameworks , on in jboss. security have implemented securityinterceptor nullpointerexception. problem kryptomanager.getkryptoinformation(); call because kryptomanager null.

@ejb kryptomanager kryptomanager;  @override public boolean accept(class c, method method) {     if (c == null || method == null) return false;     //class implementing rest service     return method.getname().equals("restservice");  }  @override public serverresponse preprocess(httprequest request, resourcemethod method)         throws failure, webapplicationexception {     serverresponse response = null;      string key = kryptomanager.getkryptoinformation();      ...      if (error) {         response = new serverresponse(loginurl, 403, new headers<object>());     }       return response; } 

i have servlet , restservice running, can access kryptomanager getkryptoinformation method. (there don't have create instances or whatever) why can't interceptor access database on kryptobean ? there possibility access or information database in backend. kryptomanager looks like:

@stateless public class kryptomanager {      @ejb     private kryptodao kryptodao;      public kryptobean getkryptoinformation() {         return kryptodao.getkryptoinformation();     }  } 

the kryptodao looks like:

@stateless public class kryptodao {       @persistencecontext(unitname = "db", type = persistencecontexttype.transaction)      private entitymanager entitymanager;        public kryptobean getkryptoinformation() {          query query = entitymanager.createquery("select k kryptobean k");          return (kryptobean) query.getresultlist().get(0);       } } 

and bean class looks like:

@xmlrootelement @table(name = "krypto") @entity(name = "kryptobean") public class kryptobean {      @id     @column(name = "idkrypto")     private int idkrypto;      @column (name = "hmackey")     private string hmackey;      public int getidkrypto() {         return idkrypto;     }      public void setidkrypto(int idkrypto) {         this.idkrypto = idkrypto;     }      public string gethmackey() {         return hmackey;     }      public void sethmackey(string hmackey) {         this.hmackey = hmackey;     }  } 

and jaxrsactivator looks like:

@applicationpath( "/rest" ) public class jaxrsactivator extends application {      @override     public set<class<?>> getclasses() {         // todo auto-generated method stub         return super.getclasses();     }      @override     public set<object> getsingletons() {         // todo auto-generated method stub         return super.getsingletons();     }  } 


Comments