Exception in Weblogic about CMP EntityBean

Discussions

EJB programming & troubleshooting: Exception in Weblogic about CMP EntityBean

  1. Exception in Weblogic about CMP EntityBean (4 messages)

    Hi all
      I write a cmp EntitiyBean and deployed to weblogic5.1,when i call finder method i get an exception :

    java.rmi.RemoteException: ; nested exception is:
            weblogic.rmi.ServerError: A RemoteException occurred in the server metho
    d
     - with nested exception:
    [java.lang.NoSuchMethodError: weblogic.ejb.internal.EJBHomeImpl: method findMeth
    odInfo(Ljava/lang/String;)Lweblogic/ejb/internal/MethodInfo; not found]

    and I call home.create() and home.remove() is sucess
    only finder is error ,help me and any suggest
    is appreciated!

    my Bean is

    package com.prient.entity.cmp;

    import javax.ejb.EntityBean;

    import javax.ejb.EntityContext;

    /**
     * Container managed entity Bean
     * @stereotype EntityBean
     */
    public class CarTypeEJB implements EntityBean
    {
    /** @field Key CHAR(6) partslink.daniel.Cartype.car_code */
    public String car_code;
    /** @field VARCHAR(50) partslink.daniel.Cartype.car_name */
    public String car_name;
    /**
    * The container assigned reference to the entity
    */
    private EntityContext context;

    /**
    * @return
    * @SBGen Method get car_code
    */
    public String getCar_code() {
    // SBgen: Get variable
    System.out.println("getCar_code is invoked!");
    return(car_code);
    }

    /**
    * @param car_code
    * @SBGen Method set car_code
    */
    public void setCar_code(String car_code) {

    // SBgen: Assign variables
    System.out.println("setCar_code is invoked!");
    this.car_code = car_code;
    // SBgen: End Assign
    }

    /**
    * @return
    * @SBGen Method get car_name
    */
    public String getCar_name() {
    // SBgen: Get variable
    System.out.println("getCar_code is invoked!");
    return(car_name);
    }

    /**
    * @param car_name
    * @SBGen Method set car_name
    */
    public void setCar_name(String car_name) {
    // SBgen: Assign variables
    System.out.println("setCar_name is invoked!");
    this.car_name = car_name;
    // SBgen: End Assign
    }

    /**
    * @return
    */
    public CarTypeEJB() {
    System.out.println("CarTypeEJB Constructor is invoked!");
    }

    /**
    * Sets the context of the bean
    * @param ec
    */
    public void setEntityContext(EntityContext ec) {
    System.out.println("setEntityContext is invoked");
    context = ec;
    // to do: code goes here.
    }

    /**
    * Clears the context of the bean
    */
    public void unsetEntityContext() {
    System.out.println("unsetEntityContext is invoked!");
    this.context = null;
    // to do: code goes here.
    }

    public void ejbActivate() {
    System.out.println("ejbActivate is invoked!");
    }

    public void ejbPassivate() {
    System.out.println("ejbPassivate is invoked!");
    }
    public void ejbLoad() {
    System.out.println("ejbLoad is invoked!");
    }

    public void ejbStore() {
    System.out.println("ejbStore is invoked!");
    }

    public void ejbCreate(String car_code, String car_name) {
    System.out.println("ejbCreate is invoked!");
    this.car_code = car_code;
    this.car_name = car_name;
    // return null;
    }

    public void ejbPostCreate(String car_code, String car_name) {
    System.out.println("ejbPostCreate is invoked!");
    }
    public void ejbRemove() {
    System.out.println("ejbRemove is invoked!");
    }
    }

    //home interface is:


    package com.prient.entity.cmp;

    import javax.ejb.EJBHome;

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

    import java.util.Enumeration;

    import javax.ejb.CreateException;

    public interface CarTypeHome extends EJBHome
    {
    /**
    * @return
    */
    public CarType findByPrimaryKey(String key)
    throws FinderException, RemoteException;

    /**
    * @return
    */
    public CarType findByName(String s_car_name)
    throws FinderException, RemoteException;

    /**
    * @return
    */
    public Enumeration findAll()
    throws FinderException, RemoteException;

    /**
    * @return
    */
    public CarType create(String car_code, String car_name)
    throws CreateException, RemoteException;
    }

    //remote interface is:

    package com.prient.entity.cmp;

    import javax.ejb.EJBObject;

    import java.rmi.RemoteException;

    public interface CarType extends EJBObject
    {
    /**
    * @return
    */
    public String getCar_code()
    throws RemoteException;

    public void setCar_code(String car_code)
    throws RemoteException;

    /**
    * @return
    */
    public String getCar_name()
    throws RemoteException;

    public void setCar_name(String car_name)
    throws RemoteException;
    }
    ///////
    //ejb-jar.xml
    <?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>
        <enterprise-beans>
            <entity>
                <description></description>
                <ejb-name>CarType</ejb-name>
                <home>com.prient.entity.cmp.CarTypeHome</home>
                <remote>com.prient.entity.cmp.CarType</remote>
                <ejb-class>com.prient.entity.cmp.CarTypeEJB</ejb-class>
                <persistence-type>Container</persistence-type>
                <prim-key-class>java.lang.String</prim-key-class>
                <reentrant>false</reentrant>
                <cmp-field>
                    <field-name>car_name</field-name>
                </cmp-field>
                <cmp-field>
                    <field-name>car_code</field-name>
                </cmp-field>
                <primkey-field>car_code</primkey-field>
            </entity>
        </enterprise-beans>
        <assembly-descriptor>
            <container-transaction>
                <method>
                    <ejb-name>CarType</ejb-name>
                    <method-name>*</method-name>
                </method>
                <trans-attribute>Supports</trans-attribute>
            </container-transaction>
        </assembly-descriptor>
    </ejb-jar>

    ///////
    //weblogic-cmp-rdbms-jar-CarType.xml:
    <!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>SqlServerPool</pool-name>
        <schema-name>daniel</schema-name>
        <table-name>Cartype</table-name>
        <attribute-map>
            <object-link>
                <bean-field>car_name</bean-field>
                <dbms-column>CAR_NAME</dbms-column>
            </object-link>
            <object-link>
                <bean-field>car_code</bean-field>
                <dbms-column>CAR_CODE</dbms-column>
            </object-link>
        </attribute-map>
        <finder-list>
            <finder>
                <method-name>findByName</method-name>
                <method-params>
                    <method-param>java.lang.String</method-param>
                </method-params>
                <finder-query>
                    <![CDATA["(= car_name $s_car_name)"]]>
                </finder-query>
            </finder>
            <finder>
                <method-name>findAll</method-name>
                <finder-query>
                    <![CDATA[(= 1 1)]]>
                </finder-query>
            </finder>
        </finder-list>
        <options></options>
    </weblogic-rdbms-bean>


    help me!
  2. I will take a stab at the dark here, because it looks like a simple example of CMP. But in your weblogic-cmp-rdbms-jar.xml file try removing the quotation marks from this line:
    <![CDATA["(= car_name $s_car_name)"]]>
    make it
    <![CDATA[(= car_name $s_car_name)]]>
     
    Rich
  3. Hi
      thanks for your reply,i have try it but failed.

      in my weblogic-cmp-rdbms-jar.xml file i remove the quotation marks from this line:
    <![CDATA["(= car_name $s_car_name)"]]>
    make it
    <![CDATA[(= car_name $s_car_name)]]>
    when i use command :
    java weblogic.ejbc cartype.jar cartypeEJB.jar
    i got exception:

    Scanner exception: line(1), no viable alt for char: s
    ERROR: Error from ejbc: weblogic.cmp.rdbms.finders.IllegalExpressionException:
    While trying to process Finder
            Method Name: findByName
            Parameter Types: (java.lang.String)
            WebLogic Query: (= car_name $s_car_name)
            Finder Expressions: ()
    Invalid Identifier in WLQL expression: _car_name

    ERROR: ejbc found errors

    In my java Client i call findAll() method exception still is:

    java.rmi.RemoteException: ; nested exception is:
            weblogic.rmi.ServerError: A RemoteException occurred in the server metho
    d
     - with nested exception:
    [java.lang.NoSuchMethodError: weblogic.ejb.internal.EJBHomeImpl: method findMeth
    odInfo(Ljava/lang/String;)Lweblogic/ejb/internal/MethodInfo; not found]

    Any suggestion will be appreciated! thanks
  4. Looks like there were two problems in one line:
    make:
    <![CDATA["(= car_name $s_car_name)"]]>
    this:
    <![CDATA[(= car_name $0)]]>

    which means car_name = the first parameter.

    rich
  5. It's ok ,Thanks!