@Depends injection after redeploy
ci May 18, 2007 8:18 AMHi.
jdk5, jboss-4.2.0.CR2
Something strange in @Depends injection happens. I have two JMX deployed in _two_ different ears.
a.ear:
@Service(objectName = "A")
@Management(A.class)
public class ABean implements A {
@Depends("B")
private B b = null;
...
}
b.ear:
@Service(objectName = "B")
@Management(B.class)
public class BBean implements B {
...
}When deployed firstly, everything is fine. Then I undeploy b.ear and depoly it again. I can see A.stop() executed on undeploy, but after b.ear is deployed again, no injection into A is done. (Looking into jndi for a value strangely fails too, but I think this is not correct to replace injection manually.) So, I need to redeploy all dependant ears to get proper injection done.
Is it a correct behavior?
I looked into source code, there is a org.jboss.ejb3.service.ServiceContainer class, where in rows 141-166 there is a method, which is called when B deployment happens:
public void start() throws Exception {
super.start();
try {
initBeanContext();
...
(*) injectDependencies(beanContext);
(**) registerManagementInterface();
...
invokeOptionalMethod("start");
} catch (Exception e) {
e.printStackTrace();
stop();
}
}In (*) does its work, but it uses ServiceContainer.beanContext.bean as a target for injection, while (**) calls start() for another instance of my JMX A, which is in ServiceContainer.singleton field.
I noticed that when we deploy an mx bean everything ok, ServiceContainer.singleton is used when ServiceContainer.beanContext is being inited, so ServiceContainer.singleton == ServiceContainer.beanContext.bean afterwards. But when we redeploy something our mx bean depends on, there is a call of ServiceController.create() for all dependant mx beans (they should apparently be stopped until then), and at that time ServiceContainer.singleton != ServiceContainer.beanContext.bean, which causes the problem.
I am not an expert in JBoss, of cause my investigations and ideas can easily be incorrect. Please, help me understand why I need to restart the whole server if I only redeploy an ear...
--
Serg