3 Replies Latest reply on Oct 3, 2005 12:58 PM by zitrogol

    javax.naming.NameNotFoundException: InteresesBean not bound

    zitrogol

      Hi, i am learning to use EJB and i have some problems. I tried some examples but i can execute. Always i get the same error.
      I am using Jboss 4.0.2 with Window XP.

      My ejb-jar.xml is:

      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE ejb-jar PUBLIC
      "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
      "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

      <ejb-jar>
      Calculo de Intereses
      <display-name>Calculo</display-name>
      <enterprise-beans>

      <ejb-name>InteresesBean</ejb-name>
      com.osmosislatina.ejb.intereses.InteresesHome
      com.osmosislatina.ejb.intereses.Intereses
      <ejb-class>com.osmosislatina.ejb.intereses.InteresesBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Bean</transaction-type>

      </enterprise-beans>
      </ejb-jar>

      And my clases are:

      **********************
      package com.osmosislatina.ejb.intereses;

      import javax.ejb.SessionBean;
      import javax.ejb.SessionContext;

      public class InteresesBean implements SessionBean {

      public double calcularInteres(double capital, double tasa, double plazo) {

      return capital * Math.pow(1+tasa, plazo) - capital;
      }

      public InteresesBean() {}
      public void ejbCreate() {}
      public void ejbRemove() {}
      public void ejbPassivate() {}
      public void ejbActivate() {}
      public void setSessionContext(SessionContext sc) {}
      }

      **********************
      package com.osmosislatina.ejb.intereses;

      import javax.ejb.EJBObject;
      import java.rmi.RemoteException;

      public interface Intereses extends EJBObject {

      public double calcularInteres(double capital, double tasa, double plazo)
      throws RemoteException;

      }
      **********************
      package com.osmosislatina.ejb.intereses;

      import javax.ejb.EJBHome;
      import javax.ejb.CreateException;
      import java.rmi.RemoteException;

      public interface InteresesHome extends EJBHome {

      Intereses create() throws RemoteException, CreateException;

      }
      **********************
      and the client is:


      package com.osmosislatina.ejb.intereses;

      import java.util.Properties;
      import javax.rmi.PortableRemoteObject;
      import javax.naming.*;

      class ClienteIntereses
      {
      public static void main(String[] args)
      {
      Properties env = new Properties();
      System.out.println("Inicio\n");
      // Definir las propiededas y ubicación de búsqueda de Nombres JNDI.
      env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      env.setProperty("java.naming.provider.url", "jnp://localhost:1099");
      env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming.client");
      env.setProperty("j2ee.clientName","ClienteIntereses");

      //env.put(Context.INITIAL_CONTEXT_FACTORY, "org.openejb.client.LocalInitialContextFactory");

      try
      {
      // Traer el Contexto de Nombre
      InitialContext jndiContext = new InitialContext(env);
      System.out.println("Contexto Disponible");

      Object ref = jndiContext.lookup("InteresesBean");//THE PROBLEM IS HERE

      InteresesHome home = (InteresesHome) PortableRemoteObject.narrow (ref, InteresesHome.class);

      Intereses interes = home.create();

      System.out.println("Interés de 10,000 Capital, a tasa 10%, bajo 2 plazos anuales:");
      System.out.println("Fin");
      }
      catch(Exception e)
      {
      System.out.println("Error\n");
      System.out.println(e.getMessage());
      e.printStackTrace();
      }
      }
      }

      The error is in the line:
      Object ref = jndiContext.lookup("InteresesBean");//THE PROBLEM IS HERE

      I don't know what is the problem because i didn't write the program and another persons can execute without problems.
      Can anybody help me, please?