4 Replies Latest reply on Apr 25, 2003 12:50 AM by Seet Seet

    javax.naming.NameNotFoundException

    benjamca Newbie

      I hope I posted enough information for someone to help me with this...

      I get the following error:
      2003-04-14 10:04:36,355 ERROR [STDERR] javax.naming.NameNotFoundException: bonus not bound

      My ejb-jar file directory structure is as follows:
      /meta-inf/ejb-jar.xml
      /meta-inf/jboss.xml
      /Manifest.mf
      /com/gees/bonus/BonusCalculator.class
      /com/gees/bonus/BonusCalculatorBean.class
      /com/gees/bonus/BonusCalculatorHome.class
      /com/gees/bonus/BonusCalculatorLocal.class
      /com/gees/bonus/BonusCalculatorLocalHome.class

      I am using XDoclet 1.1.2 andthe bean is declared as follows:
      /**
      * Session - BonusCalculatorBean
      *
      * @ejb:bean name = "bonus/BonusCalculator"
      * display-name = "Bonus Calculator Bean"
      * type = "Stateless"
      * transaction-type = "Container"
      * jndi-name = "ejb/bonus/BonusCalculatorHome"
      * view-type = "both"
      */
      public class BonusCalculatorBean implements SessionBean {

      private SessionContext ctx;

      /**
      * @ejb:interface-method view-type="both"
      **/
      public double calculateBonus(int multiplier, double bonus) throws RemoteException {
      double calculatedBonus = (multiplier * bonus);
      return calculatedBonus;
      }

      /**
      * @ejb:interface-method view-type="both"
      **/
      public void ejbCreate() throws CreateException {
      System.out.println( "BonusCalculatorBean.ejbCreate()" );
      }

      public void setSessionContext(SessionContext ctx) {
      this.ctx = ctx;
      }

      public void ejbRemove() throws EJBException {}
      public void ejbActivate() throws EJBException {}
      public void ejbPassivate() throws EJBException {}
      public void ejbLoad() throws EJBException {}
      public void ejbStore() throws EJBException {}
      }

      and I call the bean as follows inside my servlet:

      Object homeObject = context.lookup("ejb/bonus/BonusCalculatorHome");

      the servlet web-xml file is as follows:
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE web-app PUBLIC
      "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
      "http://java.sun.com/dtd/web-app_2_3.dtd">

      <web-app>

      <display-name>Bonus-App</display-name>


      <servlet-name>CalculateBonus</servlet-name>
      <servlet-class>com.gees.bonus.BonusCalculationServlet</servlet-class>


      <servlet-mapping>
      <servlet-name>CalculateBonus</servlet-name>
      <url-pattern>/CalculateBonus</url-pattern>
      </servlet-mapping>

      <welcome-file-list>
      <welcome-file>bonus.html</welcome-file>
      </welcome-file-list>

      <ejb-ref>
      <ejb-ref-name>ejb/bonus/BonusCalculatorHome</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      com.gees.bonus.BonusCalculatorHome
      com.gees.bonus.BonusCalculator
      </ejb-ref>

      </web-app>

      The servlet jboss.xml is as follows:
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss-web
      PUBLIC "-//JBoss//DTD Web Application 2.3//EN"
      "http://www.jboss.org/j2ee/dtds/jboss-web_3_0.dtd">

      <jboss-web>

      <context-root>/bonusapp</context-root>

      <ejb-ref>
      <ejb-ref-name>ejb/bonus/BonusCalculatorHome</ejb-ref-name>
      <jndi-name>ejb/bonus/BonusCalculatorHome</jndi-name>
      </ejb-ref>

      </jboss-web>