Oops, things were quite not the way I first described them: it looks like the Schedulable class that is invoked has never a way to retrieve the ejb home, except that these Homes are cached (the lookup took place in a helper class), so that later retries didn't need to lookup the jndi context, but found the ejb Home in the cache.
Sorry for the mis-post.
The question can now be changed into: is there a way for the Schedulable class to access the jndi context where the ejbs are bound?
This what the "java:/" context in the Schedulable class contains:- jaas (instance of javax.naming.Context)
- TransactionPropagationContextImporter (instance of org.jboss.tm.TransactionPropagationContextImporter)
- JmsXA (instance of org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
- JBossCorbaNaming (instance of org.omg.CosNaming.NamingContextExt)
- DefaultDS (instance of org.jboss.resource.adapter.jdbc.WrapperDataSource)
- StdJMSPool (instance of org.jboss.jms.asf.StdServerSessionPoolFactory)
- TransactionManager (instance of org.jboss.tm.TxManager)
- JBossCorbaPOA (instance of org.omg.PortableServer.POA)
- TransactionPropagationContextExporter (instance of org.jboss.tm.TransactionPropagationContextFactory)
- ConnectionFactory (instance of org.jboss.mq.SpyConnectionFactory)
- jdbc (instance of org.jnp.interfaces.NamingContext)
- DefaultJMSProvider (instance of org.jboss.jms.jndi.JNDIProviderAdapter)
- XAConnectionFactory (instance of org.jboss.mq.SpyXAConnectionFactory)
- JBossCorbaInterfaceRepositoryPOA (instance of org.omg.PortableServer.POA)
- Mail (instance of javax.mail.Session)
- JBossCorbaORB (instance of org.omg.CORBA.ORB)
- timedCacheFactory (instance of javax.naming.Context)
- SecurityProxyFactory (instance of org.jboss.security.SubjectSecurityProxyFactory)
- comp (instance of javax.naming.Context)
The real problem here is that the code in the Scheduler class (which is a MBean) is executed even before the EJB is bound to the jndi name. This can be solved by having a dependency attribute on the MBean. Have a look at the following link, for the same:
Thanks for your reply. I tried what you suggest, messages in the log file seem to confirm that everything went right, but the lookup still fails.
In the log I saw a service which seems strictly related to the jndi binding:
I tried also to add a dependency on this, JBoss didn't complain, duly logged that the dependency was there, but the scheduled class still can't see anything...
Couldn't simply this be the key?
The NamingService also creates the java:comp context such that access to this context is isolated based on the context ClassLoader of the thread that accesses the java:comp context.
Problem solved: I tried to look it up in the java:/comp context rather than in the global context (env/comp).
Sorry for wasting the time of those who read, hope this may help others...