Currently I am using EJB3.0 session beans in my application. Normally i lookup the bean using jndi name and call the concerned method. But recently what I was suggested to store these references in a Map rather than looking up again and again.
Is this a good practice to store
Session Beanreferences intoMapto avoid their lookup every time ? Or is it Hazardous ? What kind of problems if at all application may have to encounter ?
If it is a good practice then I have another concern.
Class that contains
Mapto store references is part of Module A. Whilesession beansare part of Module B1 ...Bn. So Once after looking up when I store the reference inMap, I can retrieve it back. In the meantime Module Bn is redeployed but A remains as it is. So now after looking up the bean from the Map ( as it contains entry) using it,ClassCast Exceptionis thrown.
What is the reason of that and how can I avoid ? I am using JBOSS Application server - jboss 5.1.0.GA