Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullpointerException when I removed an ejb session

 
Steph Wutke
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi, I m using WAS 5.1.3 and ejb 2.0, I don't have any trouble since 2 week ... and yesterday I 've got NullPointerException for each calling of remove method of each ejb session (I m using session facade patern) !!!

I don t know why !!

InitialContext iCtx;
Object obj;
try {
iCtx = new InitialContext();
obj = iCtx.lookup(PrometheeEjb.CONTEXT_LOCAL + BtrSequenceFacadeBean.NOM_JNDI);
BtrSequenceFacadeLocalHome btrSequenceFacadeHome = (BtrSequenceFacadeLocalHome) obj;
BtrSequenceFacadeLocal btrSequenceFacadeLocal = btrSequenceFacadeHome.create();
btrSequence = btrSequenceFacadeLocal.getNextBtrSequence(this.numRub, this.getSite());
// Here !!! btrSequenceFacadeLocal is not null, but his reference in memory dont exist ?
btrSequenceFacadeLocal.remove();
} catch (RemoveException exc) {
exc.printStackTrace();
} catch (CreateException exc) {
exc.printStackTrace();
} catch (NamingException exc) {
exc.printStackTrace();
throw new EJBException("EJBException");
}catch (Exception exc){}

Thanks for any reply ...
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Steph,

Couple of things:
  • Is this a SFSB or a SLSB? If your bean is a SLSB then you don�t need to call remove; the client reserves the bean during the current transaction and the server will return the bean in the pool, after the transaction ends. The instance won�t necessarily get removed from the pool. The container will remove it if necessary, in order to preserve resources and not as a direct response to client's remove() call (which is useless anyway).
  • You might need to check if your business method (getNextBtrSequence) fails. If that�s the case and it throws a RuntimeException then your container will: 1) log the error message and will 2) discard the bean. It might be why your remove fails...


  • Regards.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic