1 Reply Latest reply on Aug 17, 2001 8:01 AM by tbfmicke

    Startup MBean and EJB

    cbutkus

      I tried this in the new to JBoss group and got no response, so I figured I would try here.

      I've created an MBean to run at JBoss startup. I've put this MBean as the last entry in the jboss.jcml file so all other services would be available.

      The code invoked by the MBean needs to call an EJB. When I attempt to get the home interface of the EJB I get the following error and stack trace:

      Startup.main: Remote Exception caught: Unable to get home interface: javax.naming.NameNotFoundException: env not bound
      java.rmi.RemoteException: Unable to get home interface: javax.naming.NameNotFoundException: env not bound
      at com.highground.queue.QProcessorImpl.getQueue(QProcessorImpl.java:250)
      at com.highground.queue.QProcessorImpl.(QProcessorImpl.java:171)
      at com.highground.startup.StartupJBoss.start(StartupJBoss.java:42)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.util.ServiceControl.start(ServiceControl.java:97)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.Main.(Main.java:217)
      at org.jboss.Main$1.run(Main.java:121)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.jboss.Main.main(Main.java:117)

      My question is: Is it possible to get a reference to an EJB from code invoked by an MBean at JBoss startup?

      I've tried different JNDI names but all give the same error. The error "env not found" leads me to believe that none of the JNDI entries under "java:comp/env" are available.

      Any help will be greatly appreciated!! I can supply more info if necessary.
      Chuck

        • 1. Re: Startup MBean and EJB
          tbfmicke

          (Disclaimer: Not having the specs up at the moment so I'm going off the top of my head)

          The java:comp/env namespace is only usable inside EJB's. In there you find "logical" names for other EJB's (or other resources), that you have configured in the deployment descriptor for the bean doing the lookup.

          It might be that the beans are not available yet anyway during MBeans startup, but if they are you should succeed in finding them by using the "real" JNDI name for the bean you are trying to access. (The Beanname in ejb-jar.xml or the jndi-name set in jboss.xml)

          Regards
          Mike