2 Replies Latest reply on Mar 5, 2002 5:19 PM by Todd Marshall

    Urgent Help Needed!! with NameNotFoundException

    rohid Newbie

      I have been having trouble testing client application.
      javax.naming.NameNotFoundException
      javax.naming.NameNotFoundException: interest not bound

      C:\usr\lib\jboss>java -classpath c:\usr\lib\jboss\client\jnp-client.jar;
      \client\jboss-j2ee.jar;
      \client\jboss-client.jar;
      \client\jnp-client.jar;org\interest;
      \client\jndi.jar;c:\examples\resources;. -Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory -Djava.naming.provider.url=localhost:1099 -Djava.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces org.interest.InterestClient
      Got context

      javax.naming.NameNotFoundException: interest not bound

      All the required files are under c:\usr\lib\jboss\org\Interest
      InterestHome, InterestBean, Interest, InterestClient

      Interest.java
      package org.interest;
      import javax.ejb.EJBObject;
      import java.rmi.RemoteException;

      public interface Interest extends EJBObject
      {

      public double calculateCompoundInterest(double principle,
      double rate, double periods) throws RemoteException;
      }


      InterestBean.java
      package org.interest;
      import java.rmi.RemoteException;
      import javax.ejb.SessionBean;
      import javax.ejb.SessionContext;

      public class InterestBean implements SessionBean
      {

      public double calculateCompoundInterest(double principle,
      double rate, double periods)
      {
      System.out.println("Someone called `calculateCompoundInterest!'");
      return principle * Math.pow(1+rate, periods) - principle;
      }

      /** Empty method body
      */
      public void ejbCreate()
      {}

      public void ejbPostCreate()
      {}
      /** Empty method body
      */
      public void ejbRemove()
      {}
      /** Empty method body
      */
      public void ejbActivate()
      {}
      /** Empty method body
      */
      public void ejbPassivate()
      {}
      /** Empty method body
      */
      public void setSessionContext(SessionContext sc)
      {}
      }

      InterestHome.java
      package org.interest;
      import java.io.Serializable;
      import java.rmi.RemoteException;
      import javax.ejb.CreateException;
      import javax.ejb.EJBHome;

      public interface InterestHome extends EJBHome
      {

      Interest create() throws RemoteException, CreateException;
      }


      InterestClient.java
      import javax.naming.InitialContext;
      import javax.rmi.PortableRemoteObject;
      import org.interest.Interest;
      import org.interest.InterestHome;


      class InterestClient
      {

      public static void main(String[] args)
      {

      try
      {
      // Get a naming context
      InitialContext jndiContext = new InitialContext();
      System.out.println("Got context");

      // Get a reference to the Interest Bean
      Object ref = jndiContext.lookup("interest/Interest");
      System.out.println("Got reference");

      // Get a reference from this to the Bean's Home interface
      InterestHome home = (InterestHome)
      PortableRemoteObject.narrow(ref, InterestHome.class);

      // Create an Interest object from the Home interface
      Interest interest = home.create();

      // call the calculateCompoundInterest() method to do the calculation
      System.out.println("Interest on 1000 units, at 10% per period, compounded over 2 periods is:");
      System.out.println(interest.calculateCompoundInterest(1000, 0.10, 2));
      }
      catch(Exception e)
      {
      System.out.println(e.toString());
      }
      }
      }

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

      <ejb-jar>
      JBoss Interest Sample Application
      <display-name>Interest EJB</display-name>
      <enterprise-beans>

      <ejb-name>Interest</ejb-name>
      org.interest.InterestHome
      org.interest.Interest
      <ejb-class>org.interest.InterestBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Bean</transaction-type>

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

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

      <enterprise-beans>

      <ejb-name>Interest</ejb-name>
      <jndi-name>interest/Interest</jndi-name>

      </enterprise-beans>
      <resource-managers />

      <container-configurations>
      <container-configuration configuration-class="org.jboss.ejb.deployment.EntityContainerConfiguration">
      <container-name>BMP EntityBean</container-name>
      <container-invoker>org.jboss.ejb.plugins.jrmp13.server.JRMPContainerInvoker</container-invoker>
      <instance-pool>org.jboss.ejb.plugins.EntityInstancePool</instance-pool>
      <instance-cache>org.jboss.ejb.plugins.NoPassivationEntityInstanceCache</instance-cache>
      <persistence-manager>org.jboss.ejb.plugins.BMPPersistenceManager</persistence-manager>
      <transaction-manager>org.jboss.tm.TxManager</transaction-manager>
      <container-invoker-conf>
      False
      </container-invoker-conf>
      <container-cache-conf />
      <container-pool-conf>
      100
      10
      </container-pool-conf>