6 Replies Latest reply on Jun 23, 2004 10:41 AM by gtigti

    JBOSS and JNDI: Object Not Bound Exception

    vivkap01 Newbie

      Hi
      I am trying to deploy a simple Session Bean and then access it from a Java program.
      This is how the ejb-jar.xml looks

      <ejb-jar>
      <enterprise-beans>

      <ejb-name>SoftwareServicesBean</ejb-name>
      package.core.services.SoftwareServicesHome
      package.core.services.ISoftwareServicesBean
      <ejb-class>package.core.services.SoftwareServicesBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>

      </enterprise-beans>
      <assembly-descriptor>
      <container-transaction>

      <ejb-name>SoftwareServicesBean</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>

      So I have an .ear file called product-core.ear. It has software-ejb.jar containing the classes and the ejb-jar.xml under meta-inf.
      The .ear also contains third party jars and application.xml under meta-inf.
      And I just drop the .ear under JBOSS. When JBOSS starts it says :

      17:12:41,761 INFO [EARDeployer] Started J2EE application: file:/C:/product/jboss-3.2.3/server/default/deploy/product-core.ear
      17:12:41,761 INFO [MainDeployer] Deployed package: file:/C:/product/jboss-3.2.3/server/default/deploy/product-core.ear

      This is how the simple Java client is

      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      env.put(Context.PROVIDER_URL, "localhost:1099");
      env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");

      try
      {
      // Get a naming context
      InitialContext jndiContext = new InitialContext(env);
      Object ref = jndiContext.lookup("SoftwareServicesBean");
      }
      catch(Exception e)
      {
      System.out.println(e.toString());
      e.printStackTrace();
      }



      I get this error:
      javax.naming.NameNotFoundException: SoftwareServicesBean not bound


      I even tried putting the jboss.xml under meta-inf with the jndi name , it still give the same error.
      I am struggling with this for quiet a while now, any help will be appreciated

        • 1. Re: JBOSS and JNDI: Object Not Bound Exception
          geoff74 Newbie

          I had this same problem, and failed to resolve it. I changed my packaging to not use an EAR.

          Are EJB's deployed in an EAR supposed to be available from outside of the EAR, or are they only available to web apps deployed in the same EAR? Are they deployed in a different namespace or something? Or does JBoss not correctly deploy EJB's packaged in an EAR? Or are we doing something wrong? If so, what might it be?

          I, too, would like an answer on this, but there does not appear to be any documentation on it (that I can find).

          • 2. Re: JBOSS and JNDI: Object Not Bound Exception
            Darran Lofthouse Master

            Yes EJBs deployed in an EAR are supposed to be accessible from the outside.

            I am not sure what the cause of the problem is, are you checking JNDI to make sure that the components were deployed correctly?

            Is your application.xml valid and in the correct location.

            Are you sure that there are no errors displayed in the console.

            The recent versions of JBoss work fine so it is not a JBoss problem.

            • 3. Re: JBOSS and JNDI: Object Not Bound Exception
              Raja Master

              What is the JNDI Name on the EJB? You mentioned only the ejb-jar.xml , can you post the jndi-name from jboss.xml or from teh console. Make sure that that is the one you are referencing from ur client

              • 4. Re: JBOSS and JNDI: Object Not Bound Exception
                geoff74 Newbie

                I got this to work, but I have no idea what is different from what I did before (well, actually I know several things are different, but I'm not sure which one if any was the problem).

                • 5. Re: JBOSS and JNDI: Object Not Bound Exception
                  vivkap01 Newbie

                  I finally got it to work. It was nothing to do wit JNDI name or jboss.xml. In fact jboss.xml is not required. The ejb-name in ejb-jar.xml is enough to be referenced by a client.
                  The problem was that the ear wasnt deployed at all. There was some problem with the soure code in remote interface. The method signature did not throw RemoteException.
                  But the surprising thing was jBoss did not complain when I deployed it. It did not throw any errors or messages or exception. This is what misled me into going to debug somewhere else.
                  I would have expected JBOSS to throw some message to the least saying the ear was not deployed.

                  • 6. Re: JBOSS and JNDI: Object Not Bound Exception
                    gtigti Newbie

                    Hi,

                    I'm new to jboss and I have to deploy a J2EE application.
                    The WebModule, the JavaModule and the DataSource (Oracle) are working fine, but not the EJBModule

                    I have this error :

                    javax.naming.NameNotFoundException: ejb not bound

                    I red about jboss.xml but I dunno what do I have to put in it or if it's necessary to write it or not.

                    note that from the jmx-xonsole, I have the following :

                    JMX MBean Operation Result
                    Operation list()

                    java:comp namespace of the OPCAISSE bean:
                    +- env (class: org.jnp.interfaces.NamingContext)


                    These two line are displayed for each of my Java beans, so the EJB Module was correctly deployed I guess

                    Can someone help me with this please ? ...

                    Thx in advance