Discussions

EJB programming & troubleshooting: can any one give full procedure to run cmp in weblogic5.1

  1. Hi,
    I am getting problem while doing the ejbc of my jar files. My jar file contains all three class files and the ejb-jar.xml.My bean is a cmp one. It is having a primarykey class. Here are my doubts:
    1. Is it necessary, in CMP bean, to return the PrimaryKey class from ejbCreate Method? ( As I got from Roman book that as the bean is CMP, it should return void. But during ejbc I am getting error )
    2. Is the implementation of haseCode and equals methods are must?
    3. Here is my ejb-jar file. Let me know whether there is any problem with this.

    -----------------------------
    <?xml version="1.0"?>

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

    <ejb-jar>
      <display-name>TellerEJB</display-name>
      <enterprise-beans>
        <entity>
          <description>BankingProject</description>
          <ejb-name>TellerBean</ejb-name>
          <home>Teller.TellerHome</home>
          <remote>Teller.Teller</remote>
          <ejb-class>Teller.TellerBean</ejb-class>
          <persistence-type>Container</persistence-type>
          <prim-key-class>Teller.TellerPK</prim-key-class>
          <reentrant>False</reentrant>

          <cmp-field><field-name>amount</field-name></cmp-field>
          <cmp-field><field-name>address</field-name></cmp-field>
          <cmp-field><field-name>accountNo</field-name></cmp-field>
          <cmp-field><field-name>name</field-name></cmp-field>
        </entity>
      </enterprise-beans>

      <assembly-descriptor>
        <container-transaction>
          <method>
            <ejb-name>TellerBean</ejb-name>
            <method-name>*</method-name>
          </method>
          <trans-attribute>Required</trans-attribute>
        </container-transaction>
      </assembly-descriptor>
    </ejb-jar>
    -----------------------------

    Thanks in advance.

    Pabak
  2. where is your weblogic-ejb-jar.xml file???
  3. Here is my weblogic-ejb-jar.xml
    -----------------------
    <?xml version="1.0"?>

    <!DOCTYPE weblogic-ejb-jar PUBLIC '-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB//EN' 'http://www.bea.com/servers/wls510/dtd/weblogic-ejb-jar.dtd'>

    <weblogic-ejb-jar>
        <weblogic-enterprise-bean>
          <ejb-name>TellerBean</ejb-name>
          <caching-descriptor>
    <max-beans-in-cache>1000</max-beans-in-cache>
          </caching-descriptor>
          <persistence-descriptor>
          <is-modified-method-name>isModified</is-modified-method-name>
    <persistence-type>
    <type-identifier>WebLogic_CMP_RDBMS</type-identifier>
    <type-version>5.1.0</type-version>
    <type-storage>META-INF/weblogic-cmp-rdbms-jar.xml</type-storage>
    </persistence-type>
    <persistence-use>
    <type-identifier>WebLogic_CMP_RDBMS</type-identifier>
    <type-version>5.1.0</type-version>
    </persistence-use>
          </persistence-descriptor>
          <jndi-name>myTellerBean</jndi-name>
        </weblogic-enterprise-bean>
      </weblogic-ejb-jar>
    ---------------------------
    And here is my weblogic-cmp-rdbms-jar.xml
    -----------------------------------
    <?xml version="1.0"?>
    <!DOCTYPE weblogic-rdbms-bean PUBLIC
     '-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB RDBMS Persistence//EN'
     'http://www.bea.com/servers/wls510/dtd/weblogic-rdbms-persistence.dtd'>
    <weblogic-rdbms-bean>
      <pool-name>CMPPool</pool-name>
      <table-name>usoc_config</table-name>
      <attribute-map>
        <object-link>
          <bean-field>acountNo</bean-field>
          <dbms-column>usoc_id</dbms-column>
        </object-link>
        <object-link>
          <bean-field>name</bean-field>
          <dbms-column>usoc_modifier</dbms-column>
        </object-link>
        <object-link>
          <bean-field>address</bean-field>
          <dbms-column>primary_usoc_nm</dbms-column>
        </object-link>
        <object-link>
          <bean-field>amount</bean-field>
          <dbms-column>remaks</dbms-column>
        </object-link>
      </attribute-map>
      <options>
        <use-quoted-names>false</use-quoted-names>
      </options>
    </weblogic-rdbms-bean>
    _-----------------------------------------------
    Thanks,
    Pabak
  4. Ur Questions:
    1. Is it necessary, in CMP bean, to return the PrimaryKey class from ejbCreate Method?
    Yes, according to specifications, the ejbCreate Method of the entity bean should return a primary key class

    2. Is the implementation of haseCode and equals methods are must?
    Yes, the primary key class should provide hashCode and equals method

  5. Send me the complete code so that i can check and can answer you.
    pvegesna@rediffmail.com