spi.NotBoundException
remi-at-work Feb 6, 2009 9:43 AMHi all,
first - sorry for mu English.
I have following problem. I create the EJB3 bean DbCleanerBean which I want to be executed when JBoss (v5.0) starts. So I create the MBean AutostartService that is looking for the DbCleanerBean in JNDI and executing the method after start.
In 98% it works fine but sometime I got such exception:
ERROR [AbstractKernelController] Error installing to Start: name=jboss:service=AutostartService state=Create mode=Manual requiredState=Installed
org.jboss.ejb3.common.registrar.spi.NotBoundException: Object is bound at key jboss.j2ee:ear=myear.ear,jar=myjar.jar,name=DbCleanerBean,service=EJB3, but is not fully installed, instead of state: ControllerState@180b4f9{Start}
at org.jboss.ejb3.common.registrar.plugin.mc.Ejb3McRegistrar.lookup(Ejb3McRegistrar.java:169)
at org.jboss.ejb3.common.registrar.plugin.mc.Ejb3McRegistrar.lookup(Ejb3McRegistrar.java:133)
at org.jboss.ejb3.proxy.handler.ProxyInvocationHandlerBase.getContainerLocally
XML:
<mbean code="com.myservice.mbeans.AutostartService" name="jboss:service=AutostartService"> <depends>jboss.j2ee:ear=myear.ear,jar=myjar-ejb.jar,name=DbCleanerBean,service=EJB3</depends> </mbean>
AutostartService.java
public class AutostartService implements AutostartServiceMBean { protected Logger log = Logger.getLogger(getClass()); @Override public void start() throws Exception { log.info("AutostartService started"); DbCleanerBusinessLocal bean = (DbCleanerBusinessLocal)new InitialContext().lookup("DbCleanerBean"); if (bean == null) { log.error("Cannot find bean DbCleanerBean in JNDI. Autostartfailed!"); } bean.startup(); log.info("AutostartService finished"); } ... }
As I said - it works in 98% but sometimes I got the NotBoundException.
Why such problem occur? From second hand - how to handle this exception. I try to run this in the loop 3 times (each try after 10 seconds). So the loop execute following code:
DbCleanerBusinessLocal bean = (DbCleanerBusinessLocal)new InitialContext().lookup("DbCleanerBean"); if (bean == null) { log.error("Cannot find bean DbCleanerBean in JNDI. Autostartfailed!"); } bean.startup();
this doesn't help. How should I handle this exception correctly?
Thanks in advance.