5 Replies Latest reply on May 15, 2008 5:40 AM by mallikarjun_nbsg

    javax.naming.NameNotFoundException: CMPHome not bound

      javax.naming.NameNotFoundException: CMPHome not bound


      Goal of the Program: Client is calling Session Bean which is a remote call and Session Bean is calling CMP Bean as a Local Call. So while making a local call there is an Exception (javax.naming.NameNotFoundException: CMPHome not bound). ie while lookup.

      Here are the XML files and code:
      In the bean class: making a local call

      try {
      log.info("entered in try");

      log.info("before lookup in Empbean");
      InitialContext ic = new InitialContext();
      Object ojb= ic.lookup("java:comp/env/CMPHome");
      home = (CMPHome)PortableRemoteObject.narrow(ojb, EmpBean.class);


      log.info("after lookup in Empbean");

      log.info("CMP home created");
      } catch (Exception e) {
      log.info("Exception in ejbCreate " + e);
      }


      <?xml version="1.0" ?>
      <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://www.jboss.org/j2ee/dtd/ejb-jar_2_0.dtd">
      <ejb-jar>
      <enterprise-beans>

      <ejb-name>Employee Session</ejb-name>
      com.test.EmpHome
      com.test.EmpRemote
      <ejb-class>com.test.EmpBean</ejb-class>
      <session-type>Stateful</session-type>
      <transaction-type>Bean</transaction-type>
      <ejb-ref>
      This is the reference to the CMP bean
      <ejb-ref-name>ejb/CMPHome</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <ejb-link>CMPHome</ejb-link>
      com.test.CMPHome
      com.test.CMPRemote
      </ejb-ref>
      <resource-ref>
      <res-ref-name>jdbc/MySql</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>




      <ejb-name>CMPHome</ejb-name>
      <local-home>com.test.CMPHome</local-home>
      com.test.CMPRemote
      <ejb-class>com.test.CMPBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Employee</abstract-schema-name>
      <prim-key-class>java.lang.String</prim-key-class>
      False
      <cmp-field>
      <field-name>id</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>empId</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>empName</field-name>
      </cmp-field>
      <primkey-field>id</primkey-field>

      Gets whole collection of Employees
      <query-method>
      <method-name>findAll</method-name>
      <method-params/>
      </query-method>
      <ejb-ql>Select OBJECT(r) From Employee r</ejb-ql>



      </enterprise-beans>

      <assembly-descriptor>
      <container-transaction>

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

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

      </ejb-jar>



      <?xml version="1.0" ?>
      <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">

      <enterprise-beans>

      <ejb-name>Employee Session</ejb-name>
      <jndi-name>Employee Session</jndi-name>
      <resource-ref>
      <res-ref-name>jdbc/MySql</res-ref-name>
      <resource-name>MySql</resource-name>
      </resource-ref>


      <ejb-name>CMPHome</ejb-name>
      <jndi-name>CMPRemote</jndi-name>
      <local-jndi-name>CMPHome</local-jndi-name>
      <resource-ref>
      <res-ref-name>jdbc/MySql</res-ref-name>
      <resource-name>MySql</resource-name>
      </resource-ref>


      </enterprise-beans>

      <resource-managers>
      <resource-manager>
      <res-name>MySql</res-name>
      <res-jndi-name>java:/MySqlDS</res-jndi-name>
      </resource-manager>
      </resource-managers>




      The Exception is while lookup of local call from the above bean code. Please help me out.

      Thank you,
      Mallikarjun.