ejb injection problem
sbutt Mar 26, 2014 1:05 PMHi All,
I am trying to inject a locat stateless bean into another bean. Both beans are in different packages/jars.
Both the beans get deployed fine, but when i enable the injection of bean 1 in my bean 2, i get the following error:
DEPLOYMENTS IN ERROR: Deployment "startup-singleton-initiator:topLevelUnit=com.abc.integra.ams2.kernel.war,unit=com.traveltainment.integra.ams2.kernel.war,bean=AutoScheduler" is in error due to the following reason(s): javax.naming.NameNotFoundException: CacheLoaderBean not bound
Bean 1:
@Stateless(name="CacheLoaderBean/local")
@Local(CacheLoader.class)
public class CacheLoaderBean implements CacheLoader
{
  private Log log = LogFactory.getLog(this.getClass());
..
..
public void loadPersistenceUnitsToCache()
  {
    String persistenceUnits = configService.getProperty("AvailablePersistenceUnits");
    log.info("reloading persistence units: " + persistenceUnits);
Interface
@Local
public interface CacheLoader
{
  public void loadPersistenceUnitsToCache();
}
Bean 2:
@Startup
@Singleton
public class AutoScheduler {   
  @EJB(mappedName = "CacheLoaderBean/Local")
  CacheLoader  cacheLoader;
  private Log log = LogFactory.getLog(this.getClass());
  private InitialContext initialContext;
  /** 
  * This method will be invoked every day at 5:00:00 in the morning 
  * @param timer The timer instance 
  */  
  //@Schedule (second = "*/10" , minute  = "*", hour = "*", persistent=false)
  @Schedule(persistent = false, second = "12", minute = "*", hour = "*", info = "evictProfiles")
  private void executeEveryDayAtFive(Timer timer) throws Exception 
  {  
  cacheLoader.loadPersistenceUnitsToCache();
  // do some task here. 
  log.info("Auto-timer method invoked at " + new Date() + " for Cache scheduler bean " + this.getClass().getSimpleName());
  System.out.println("/ " + new Date() + " for bean " + this.getClass().getSimpleName());  
  }  
  }  
In my above bean 2, when i enable the injection of CacheLoaderBean, i get the error mentioned above.
Could someone please tell me how to handle this bean injection so then I can finally manage to call the method "cacheLoader.loadPersistenceUnitsToCache();" of the injected bean?
Thanks. log.info("Auto-timer method invoked at " +