Unable to lookup EJB from MBean (Quite desperate)


EJB programming & troubleshooting: Unable to lookup EJB from MBean (Quite desperate)

  1. Unable to lookup EJB from MBean (Quite desperate) (7 messages)

    I have an EJB which implements a MBean interface so that a start()-method is called on deployment of the EAR. What I want to do in this start()-method is to lookup the EJB itself and call a method on it.

    Seems easy enough, but I am unable to lookup the EJB.

    The EJB is properly defined in the ejb-jar.xml with the <ejb-name> set to "ManagerEJB".

    Now, in the start()-method (which according to the LOG-output is called after the deployment of all of the EJBs) I do a

    Context initial = new InitialContext();
    Object objref = initial.lookup("ManagerEJB");

    Which results in a "javax.naming.NameNotFoundException: ManagerEJB not bound"

    I have also tried looking up "java:comp/env/ejb/ManagerEJB" and "java:comp/env/ManagerEJB" with no luck.

    I have tried having a jboss.xml in the META-INF-dir mapping ejb-name "ManagerEJB" to jndi-name "Foo" and then trying to look up "Foo".

    I have tried with and without a jndi.properties-file, specifying the attributes in a Hashtable and feeding it to InitialContext.

    And I am still unable to lookup anything. What am I missing?
  2. Johan, if you check the JBoss console (mapped to /jmx-console or just /), you should be able to see where your EJB is deployed in the JNDI space. I recommend that you always use a jboss.xml to map the EJB name to a JNDI name, and then you should only lookup exactly what you specified in the jboss.xml JNDI field (no "java:..." etc.).

    Try binding an object in the JNDI dynamically from your MBean and then do a lookup to it. Does that work? Try binding the object to the same JNDI name as the EJB - does that work?

    If it doesn't work, give me some more info and we'll see if we can solve it.
  3. Thanks for the tip! After looking at the list of objects in the Jndi namespace
    I think I have found what is wrong. In the Global Jndi-namespace my EJB is listed
    with the following error.

    ManagerEJB (proxy: $Proxy92 implements No ClassLoaders found for: com.emarsys.core.management.ManagerHome (no security manager: RMI class loader disabled)

    But I not really sure of what this means in this context. Any hints would be appriciated
  4. Hmmm, not sure either. After searching a bit on Google I came up with this old question on a JBoss maillist.

    http://www.mail-archive.com/jboss-development at lists dot sourceforge dot net/msg37790.html

    From what I gather this might be because you've specified a security restriction on the EJB but not mapped it against a security manager/realm? Is this correct (I'm just shooting in the dark here)?
  5. Well, I had some security rescrictions defined, but the same error remains even
    if I remove all restrictions in the EJB-definition.

     <description>Manager of Services</description>



    The exact same error is also reported for org.jboss.console.manager.PluginManagerMBean in my Jndi-list. So atleast it´s not just me :)
  6. Hi, I am facing exactly same error which is listed by you. I am not able to access my session bean via start() method of MBean.I know that EJB Container should get loaded prior to MBean gets loaded.But not geting how this can be achieved?Tried with n no of ways but no success..Can you please help? Thanks..
  7. I have solved the problem with the lookup. It seems like at the time of
    invocation of the start()-method in the MBean the EJB was properly loaded (Even if the log says that it is). Because, if I later on, through the JMX-interface, invokes the start()-method again the lookup works and everything is just as it should be.

    I guess I have to listen for some notification to make sure that everything is fully loaded before I do the lookup.

    The Errors concerning the security and no class loaders found, still remains. It would be nice to know why, but everything seems to be working now atleast :)
  8. Gött mos!

    Try naming the service that deployes the MBean something like "zz.." because I think JBoss looks through the deploy directory in file name order for each service (though perhaps the MBeans are deploy earlier than the EJBs altogether). I haven't done any MBeans for JBoss, but perhaps like you say you could hook in to some system notification when the container is started?