Deploying BMP Entity Bean with primary key calss

Hi,
I am using EJB 2.0 with and websphere studio 5.0 and database is sql server 2000.
My BMP Entity bean has a primary key class.From my client I am invoking the Entity Bean by calling it's findbyprimarykey method.
The home interface of my findbyprimarykey method returns a class of type Remote.But in the Entity Bean class,the return type is the primarykey class type.
My problem is invoking this findbyprimarykey from the client to get the remote interface so that the other business methods of the entity bean can be called.
The control goes into the ejbFindbyPrimaryKey but when it is returing from the Entity Bean class,it gives a remote exception (as the return type in Entity Bean class and Home interface are different for the findbyprimarykey method).
I think that somewhere in the deployment decriptor in my websphere,i have to specify the primarykey class type,which i am missing out and hence getting the error.
Please help me out with your advice and solution.
Thanks
Rahul Priyadarshi

Hi,
Sorry to disturb you again.
Even my code is also almost the same....i am pasting the code below...Please go through it and let me know if I have made any mistake..
EditVendorEntityBean.....(Bean Class)
package code.beans.EditVendor;
import code.beans.dataAccess.*;
import javax.ejb.CreateException;
import javax.ejb.RemoveException;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.EJBException;
import javax.ejb.FinderException;
import javax.ejb.ObjectNotFoundException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.sql.*;
import javax.sql.*;
import java.util.*;
* Bean implementation class for Enterprise Bean: EditVendorEntity
public class EditVendorEntityBean implements javax.ejb.EntityBean {
     private static Hashtable dataSources = new Hashtable();
     private String username;
private int Vendor_ID;
private int Category_Id;
private String Category_Name;
private String Vendor_Name;
private String Vendor_Address1;
private String Vendor_Address2;
private String Contact_Name;
private String Home_Phone;
private String Work_Phone;
private String email;
private String faxno;
private String userloginname;
private boolean dirtyFlag = false;
private EntityContext context;
private static final String DS_NAME = "jdbc/spiPOPS";
Connection con = null;
Statement stmt = null;
PreparedStatement st = null;
ResultSet res = null;
     //***********************Business Methods*********************
// Begin of Busines Methods
public void setData (String[] catname, String vendorname,String vendadd1,String vendadd2,String vendcontact,String venoff,String venres,String mailid,String venfax) {
          System.out.println("in setData where Vendor Id= "+ Vendor_ID);
               boolean status=false;
               boolean existing=false;
               ArrayList cat=new ArrayList();
               try
                    cat=getcategorylist(this.Vendor_ID);
               catch(SQLException e)
                    System.out.println("Could not get category list");
               System.out.println("Size of cat array -->" + cat.size() + " and string array size -->" + catname.length);
               if(catname.length>0)
                    //Removing unwanted vendor categories for a particular vendor id
                    for(int i=0;i<cat.size();i++)
                              existing=false;
                              String tempdata=(String)cat.get(i);
                              for(int j=0;j<catname.length;j++)
                                   if(tempdata.equals(catname[j]))
                                        existing=true;
                              if(!existing)
                                   try
                                        delvencat(this.Vendor_ID,tempdata.trim());
                                   catch(SQLException e)
                                        System.out.println("Could not delete record in POPS_VENDOR_CATEGORY for -->" + tempdata);
               //Adding new vendor categories for a particular vendor
                    try
                              for(int i=0;i<catname.length;i++)
                                   status=false;
                                   String strcat=catname;
                                   status=checkcat(this.Vendor_ID,strcat.trim());
                                   if(!status)
                                        insertvencat(this.Vendor_ID,strcat.trim());
                    catch(SQLException e)
                              System.out.println("Could not insert or select from POPS_VENDOR_CATEGORY table");
               this.Vendor_Name          =vendorname;
          this.Vendor_Address1     =vendadd1;
          this.Vendor_Address2     =vendadd2;
          this.Contact_Name          =vendcontact;
          this.Work_Phone               =venoff;
          this.Home_Phone               =venres;
          this.email                    =mailid;
          this.faxno                    =venfax;
               dirtyFlag = true;
               System.out.println("Leaving set data method");
public Vector getData() {
     Vector vctRec=new Vector();
     ArrayList arrdatas = new ArrayList();
     arrdatas.add(""+this.Vendor_ID);
     arrdatas.add(this.Vendor_Name);
     arrdatas.add(this.Vendor_Address1);
     arrdatas.add(this.Vendor_Address2);
     arrdatas.add(this.Contact_Name);
     arrdatas.add(this.Work_Phone);
     arrdatas.add(this.Home_Phone);
     arrdatas.add(this.email);
     arrdatas.add(this.faxno);
     vctRec.addElement(arrdatas);
     ArrayList cat=new ArrayList();
          try
          System.out.println("Calling getcategorylist from getdata with vendorid-->" + this.Vendor_ID);
          cat          = getcategorylist(this.Vendor_ID);
     catch(SQLException e)
               System.out.println("Could not get datas for category list");
     vctRec.addElement(cat);
     ArrayList allcats=new ArrayList();
     try
                    allcats          = getallcategorylist();
          catch(SQLException e)
                    System.out.println("Could not get datas for category list");
     vctRec.addElement(allcats);
          dirtyFlag = false;
     System.out.println("Before return statement in getdata with vector size -->" + vctRec.size());
          return vctRec;
// End of Business Methods
//**************************Entity Bean Methods*******************************
     * ejbActivate
     public void ejbActivate() {
          Vendor_ID = Integer.parseInt((String)context.getPrimaryKey());
     System.out.println("Inside ejbActivate Vendor_ID-->"+ Vendor_ID);
     * ejbLoad
     public void ejbLoad() {
          System.out.println("Inside ejbLoad ********" );
try {
loadRow();
}catch (Exception ex) {
          System.out.println("Failed in loadRow()");
throw new EJBException("ejbLoad: " +
ex.getMessage());
     * ejbPassivate
     public void ejbPassivate() {
     System.out.println("Inside ejbPassivate " );
Vendor_ID = 0;
     * ejbRemove
     public void ejbRemove() throws javax.ejb.RemoveException {
          //Empty Method
     * ejbStore
     public void ejbStore() {
System.out.println("Inside ejbStore " );
try {
storeRow();
}catch (Exception ex) {
          System.out.println("Exception thrown in storeRow" + ex.getMessage());
throw new EJBException("ejbLoad: " +
ex.getMessage());
     * getEntityContext
     public javax.ejb.EntityContext getEntityContext() {
          return context;
     * setEntityContext
     public void setEntityContext(javax.ejb.EntityContext ctx) {
          System.out.println("Inside setEntityContext " );
try{
     con = getConnection(DS_NAME);
     System.out.println("DB Connection Created!!");
catch(Exception e){
this.context = ctx;
     * unsetEntityContext
     public void unsetEntityContext() {
System.out.println("Inside unsetEntityContext " );
closeDbConnection(con, res, st);
this.context = null;
     * ejbCreate
     //code.beans.EditVendor.EditVendorEntityKey
     public code.beans.EditVendor.EditVendorEntityKey ejbCreate(String vendorid)
          throws javax.ejb.CreateException {          
          return new EditVendorEntityKey(vendorid);
          //return null;
     * ejbPostCreate
     public void ejbPostCreate(String vendorid) throws javax.ejb.CreateException {
          //Empty
     * ejbFindByPrimaryKey
     //code.beans.EditVendor.EditVendorEntityKey
     public code.beans.EditVendor.EditVendorEntityKey ejbFindByPrimaryKey(
          code.beans.EditVendor.EditVendorEntityKey primaryKey)
          throws javax.ejb.FinderException {
try {
if(selectByPrimaryKey(Integer.parseInt(primaryKey.getVendorId()))) {
          System.out.println("Leaving the findbyprimarykey method from the entity bean");
     return primaryKey;
     //return null;
}else {
     throw new ObjectNotFoundException
     ("Row for id " + primaryKey + " not found.");
}catch (Exception ex) {
throw new EJBException("EXCEPTION IN ejbFindByPrimaryKey :- " + ex.getMessage());
     /*********************** Database Utility Routines *************************/
private boolean selectByPrimaryKey(int priKey)
throws SQLException {
     System.out.println("inside selectByPrimaryKey for primary key " + priKey);
String queryStr ="SELECT VENDOR_ID FROM POPS_VENDOR WHERE VENDOR_ID = " + priKey;
System.out.println("in selectByPrimaryKey where queryString is: "+ queryStr);
          stmt = con.createStatement();
ResultSet result = stmt.executeQuery(queryStr);
if(!result.next()) {
stmt.close();
     System.out.println("Did not find "+priKey);
return false;
else { //Found the primaryKey
Vendor_ID = result.getInt("VENDOR_ID");
stmt.close();
return true;
private void loadRow() throws SQLException {
          System.out.println("inside loadRow ...");
          stmt = con.createStatement();
          String queryStr = "SELECT VENDOR_NAME,VENDOR_ADDRESS1,VENDOR_ADDRESS2,CONTACT_NAME,HOME_PHONE,WORK_PHONE,EMAIL_ID,FAX_NO " +
                              "FROM POPS_VENDOR WHERE VENDOR_ID=" + Vendor_ID;
          System.out.println("Inside loadRow()***********"+queryStr);
          ResultSet result = stmt.executeQuery(queryStr);
          ArrayList catadatas=new ArrayList();
     if(!result.next())
     throw new SQLException("No record for primary key" + Vendor_ID);
          this.Vendor_ID               =Vendor_ID;
                    this.Vendor_Name          =result.getString("VENDOR_NAME");
                    this.Vendor_Address1     =result.getString("VENDOR_ADDRESS1");
                    this.Vendor_Address2     =result.getString("VENDOR_ADDRESS2");
                    this.Contact_Name          =result.getString("CONTACT_NAME");
                    this.Home_Phone               =result.getString("HOME_PHONE");
                    this.Work_Phone               =result.getString("WORK_PHONE");
                    this.email                    =result.getString("EMAIL_ID");
                    this.faxno                    =result.getString("FAX_NO");
                         System.out.println("Leaving loadrow method with loaded datas for vendor -->" + Vendor_ID);
                         stmt.close();
private ArrayList getcategorylist(int vendor) throws SQLException{
          String queryStr ="SELECT DISTINCT(VENDOR_CAT) FROM POPS_VENDOR_CATEGORY WHERE VENDOR_ID=" + vendor;
          System.out.println("Query for the cat list --> " + queryStr);
          stmt = con.createStatement();
          ResultSet result = stmt.executeQuery(queryStr);
          ArrayList catdatas=new ArrayList();
try{
               while(result.next())
                    catdatas.add(result.getString("VENDOR_CAT"));
          catch (SQLException e){
               stmt.close();
               System.out.println("Could not retrieve datas for Category list");
          stmt.close();
          System.out.println("size off array for cat -->" + catdatas.size() + " and datas ->" + catdatas);
          return catdatas;
     private ArrayList getallcategorylist() throws SQLException{
               //String queryStr ="SELECT DISTINCT(VENDOR_CAT) FROM POPS_VENDOR_CATEGORY";
               StringBuffer strquery=new StringBuffer(20);
               strquery.append("SELECT DISTINCT(CATEGORY_NAME) FROM POPS_CATEGORY");
               stmt = con.createStatement();
               //ResultSet result = stmt.executeQuery(queryStr);
               ResultSet result = stmt.executeQuery(strquery.toString());
               ArrayList catdatas=new ArrayList();
               try{
                    while(result.next())
                              //catdatas.add(result.getString("VENDOR_CAT"));
                              catdatas.add(result.getString("CATEGORY_NAME"));
               catch (SQLException e){
                         stmt.close();
                         System.out.println("Could not retrieve datas for All Category list");
               stmt.close();
               return catdatas;
     private void delvencat(int vendor,String vencat) throws SQLException {
          int update=-1;
          stmt = con.createStatement();
          String queryStr ="DELETE FROM POPS_VENDOR_CATEGORY WHERE VENDOR_ID = " + vendor + " AND VENDOR_CAT = '" + vencat.toUpperCase() + "'";
          System.out.println("Delete query --> " + queryStr);
          update= stmt.executeUpdate(queryStr);
          if(update!=1)
               System.out.println("Did not find data to delete");
          stmt.close();
     private void insertvencat(int vendor,String vencat) throws SQLException {
          int update=-1;
          String queryStr ="INSERT INTO POPS_VENDOR_CATEGORY(VENDOR_ID,VENDOR_CAT)" +
                              " VALUES(" + vendor +",'" + vencat + "')";
          System.out.println("Insert query --> " + queryStr);
          stmt = con.createStatement();
          update=stmt.executeUpdate(queryStr);
          if(update!=1)
               System.out.println("Could not insert records in the database");
          stmt.close();
     private boolean checkcat(int vendor,String catven) throws SQLException {
          boolean datastatus=false;
          String queryStr ="SELECT VENDOR_ID FROM POPS_VENDOR_CATEGORY WHERE VENDOR_ID = " + vendor + " AND VENDOR_CAT = '" + catven.toUpperCase() + "'";
          stmt = con.createStatement();
          ResultSet result = stmt.executeQuery(queryStr);
          datastatus=result.next();
          stmt.close();
          return datastatus;
private void storeRow() throws SQLException {
               System.out.println("Inside ejb store");
     if (!dirtyFlag) {
     System.out.println("Skipping the UPDATE because object is not dirty");
     return;
     CallableStatement cs=null;
try{
                    cs = con.prepareCall("EXEC POPS_VENDOR_UPDATE " + this.Vendor_ID + ",'" + this.Vendor_Name + "','" + this.Vendor_Address1 + "','" + this.Vendor_Address2 + "','" + this.Contact_Name + "','" + this.Work_Phone + "','" + this.Home_Phone + "','" + this.email + "','" + this.faxno +"'");
                    System.out.println("\n\n SQL Statement : \n " + "EXEC POPS_VENDOR_UPDATE " + this.Vendor_ID + ",'" + this.Vendor_Name + "','" + this.Vendor_Address1 + "','" + this.Vendor_Address2 + "','" + this.Contact_Name + "','" + this.Work_Phone + "','" + this.Home_Phone + "','" + this.email + "','" + this.faxno +"'");
                    cs.executeUpdate();
          catch (SQLException e){
                    cs.close();
                    System.out.     println("\n\n Error in calling stored procedure POPS_INSERT_NEW_REQUEST \n\n"+ e.getMessage() + "\n\n");
          cs.close();
          dirtyFlag = false;
     private Connection getConnection(String dbName) throws SQLException
          String configuredDataSourceName = null;
          if (dbName == null) {
               System.out.println("Attemp to get connection failed. The requested database name is null");
          DataSource dbSource = getDataSource(dbName);
          return dbSource.getConnection();
     private DataSource getDataSource(String dbName)
          // looking from cache;
          DataSource dbSource = (DataSource) dataSources.get(dbName);
          if (dbSource == null) { //we need to find it from JNDI
               try {
                    Context ic = new InitialContext();
                    dbSource = (DataSource) ic.lookup(dbName);
                    dataSources.put(dbName, dbSource);
               }catch (NamingException e){
          return dbSource;
     * User calls this function to safely close an connection
     * @param connt The connection a datasource
     * @param rs The resulSet inside this connection
     * @param statement The statement associate with this connection
     private void closeDbConnection(Connection cont,ResultSet rs,Statement statement)
          if (rs != null)
          try {
                    rs.close();
               } catch (SQLException ignored) {
                    ignored.printStackTrace();
          if (statement != null)
               try {
                    statement.close();
               } catch (SQLException ignored) {
                    ignored.printStackTrace();
          if (cont != null)
               try {
                    cont.close();
               } catch (SQLException ignored) {
                    ignored.printStackTrace();
     } //closeDbConnection
EditVendorEntity (Remote Interface)
package code.beans.EditVendor;
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
import java.util.*;
* Remote interface for Enterprise Bean: EditVendorEntity
public interface EditVendorEntity extends javax.ejb.EJBObject {
     public void setData (String[] catname, String vendorname,String vendadd1,String vendadd2,String vendcontact,String venoff,String venres,String mailid,String venfax)
               throws RemoteException;
public Vector getData() throws RemoteException;
EditVendorEntityHome (Home Interface)
package code.beans.EditVendor;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.ejb.DuplicateKeyException;
import javax.ejb.EJBHome;
import java.util.*;
* Home interface for Enterprise Bean: EditVendorEntity
public interface EditVendorEntityHome extends javax.ejb.EJBHome {
     * Creates an instance from a key for Entity Bean: EditVendorEntity
     public code.beans.EditVendor.EditVendorEntity create(String vendorid)
          throws javax.ejb.CreateException, java.rmi.RemoteException;
     * Finds an instance using a key for Entity Bean: EditVendorEntity
     public code.beans.EditVendor.EditVendorEntity findByPrimaryKey(
          code.beans.EditVendor.EditVendorEntityKey Vendor_ID)
          throws javax.ejb.FinderException, java.rmi.RemoteException;
EditVendorEntityKey (Primary Key Class)
package code.beans.EditVendor;
* Key class for Entity Bean: EditVendorEntity
public class EditVendorEntityKey implements java.io.Serializable {
     static final long serialVersionUID = 3206093459760846163L;
     public String primkey;
     * Creates an empty key for Entity Bean: EditVendorEntity
     public EditVendorEntityKey() {  }
     public EditVendorEntityKey(String primarykey) {     
          this.primkey=primarykey;
     public String getVendorId() {
return primkey;
     * Returns true if both keys are equal.
     public boolean equals(java.lang.Object otherKey) {
          if (otherKey instanceof code.beans.EditVendor.EditVendorEntityKey) {
               code.beans.EditVendor.EditVendorEntityKey o =
                    (code.beans.EditVendor.EditVendorEntityKey) otherKey;
               return (primkey.equals(otherKey));
          return false;
     * Returns the hash code for the key.
     public int hashCode() {
          return (primkey.hashCode());
Please go through and give me your comments and solution...
Thanks in advance
Rahul

Similar Messages

  • Entity bean with primary key generated by trigger

    Hi,
    We have a table(oracle) with one column as primary key,
    but the primary key is generated by trigger every time
    a new row is inserted into this table, inside the trigger,
    it uses oracle sequence to get the next val.
    If we want to use entity bean with it, what should we specify, it's not application-managed primay key, it's
    not auto-generated primary key either. How can we resolve
    it without change the database part.
    Any thought is appreciated.
    Thanks
    afang

    The code is already there with JDBC call inserting
    into the table, the inserting trigger then will generate
    sequence key and being inserted into primary key column.
    Now wondering if it's possible to change the code to use entity bean but without modifying the trigger (since it contains other business logics).

  • Entity Bean with Primary Key Class

    Hi
    I am trying to develop an entity bean attached to a key which have a
    composite key using Primary Key Class. When I use the findByPrimaryKey
    method of the bean it throws an exception as follows,
    java.sql.SQLException: Parameter typecheck failed: invalid parameter type:
    ORA-00000: normal, successful completion
    at com.netscape.server.jdbc.PreparedStatement.verifyError(Unknown Source)
    at com.netscape.server.jdbc.PreparedStatement.afterVerify(Unknown Source)
    at com.netscape.server.jdbc.PreparedStatement.executeQuery(Unknown Source)
    at com.netscape.server.ejb.SQLPersistenceManager.find(Unknown Source)
    at
    com.netscape.server.ejb.EntityDelegateManagerImpl.doPersistentFind(Unknown
    Source)
    at com.netscape.server.ejb.EntityDelegateManagerImpl.find(Unknown Source)
    at com.kivasoft.eb.EBHomeBase.findSingleByParms(Unknown Source)
    at
    TestBean2.ejb_home_TestBean2_EntityBean2Bean.findByPrimaryKey(ejb_home_TestB
    ean2_EntityBean2Bean.java:120)
    at
    TestBean2.ejb_kcp_skel_EntityBean2Home.findByPrimaryKey__TestBean2_EntityBea
    n2__TestBean2_TestBKey(ejb_kcp_skel_EntityBean2Home.java:258)
    at com.kivasoft.ebfp.FPRequest.invokenative(Native Method)
    at com.kivasoft.ebfp.FPRequest.invoke(Unknown Source)
    at
    TestBean2.ejb_kcp_stub_EntityBean2Home.findByPrimaryKey(ejb_kcp_stub_EntityB
    ean2Home.java:341)
    at
    TestBean2.ejb_stub_EntityBean2Home.findByPrimaryKey(ejb_stub_EntityBean2Home
    ..java:88)
    at TestBean2.Simple1.defaultAction(Simple1.java:115)
    at TestBean2.Simple1.doGet(Simple1.java:26)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source)
    at com.netscape.server.servlet.servletrunner.ServletRunner.execute(Unknown
    Source)
    at com.kivasoft.applogic.AppLogic.execute(Unknown Source)
    at com.kivasoft.applogic.AppLogic.execute(Unknown Source)
    at com.kivasoft.thread.ThreadBasic.run(Native Method)
    at java.lang.Thread.run(Thread.java:479)
    javax.ejb.FinderException
    at com.netscape.server.ejb.SQLPersistenceManager.find(Unknown Source)
    at
    com.netscape.server.ejb.EntityDelegateManagerImpl.doPersistentFind(Unknown
    Source)
    at com.netscape.server.ejb.EntityDelegateManagerImpl.find(Unknown Source)
    at com.kivasoft.eb.EBHomeBase.findSingleByParms(Unknown Source)
    at
    TestBean2.ejb_home_TestBean2_EntityBean2Bean.findByPrimaryKey(ejb_home_TestB
    ean2_EntityBean2Bean.java:120)
    at
    TestBean2.ejb_kcp_skel_EntityBean2Home.findByPrimaryKey__TestBean2_EntityBea
    n2__TestBean2_TestBKey(ejb_kcp_skel_EntityBean2Home.java:258)
    at com.kivasoft.ebfp.FPRequest.invokenative(Native Method)
    at com.kivasoft.ebfp.FPRequest.invoke(Unknown Source)
    at
    TestBean2.ejb_kcp_stub_EntityBean2Home.findByPrimaryKey(ejb_kcp_stub_EntityB
    ean2Home.java:341)
    at
    TestBean2.ejb_stub_EntityBean2Home.findByPrimaryKey(ejb_stub_EntityBean2Home
    ..java:88)
    at TestBean2.Simple1.defaultAction(Simple1.java:115)
    at TestBean2.Simple1.doGet(Simple1.java:26)
    [03/Aug/2001 15:26:41:7] error: Exception: SERVLET-execution_failed: Error
    in executing servlet Simat
    javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServletple1: java.lang.ClassCastException:
    com.netscape.server.deployment.EntityBeanDescriptor
    Exception .service(HttpServlet.java:865)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source)
    at com.netscape.server.servlet.servletrunner.ServletRunner.execute(Unknown
    Source)Stack Trace:
    java.lang.ClassCastException:
    com.netscape.server.deployment.EntityBeanDescriptor
    a
    at com.kivasoft.applogic.AppLogic.execute(Unknown Source)
    at com.kivasoft.applogic.AppLogic.ext
    com.netscape.server.servlet.servletrunner.AppInfo.popWebAppDescriptor(Unknow
    n Source)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source)
    at com.netscape.server.seecute(Unknown Source)
    at com.kivasoft.thread.ThreadBasic.run(Native Method)
    at java.lang.Threadrvlet.servletrunner.ServletRunner.execute(Unknown
    Source)
    at com.kivasoft.applogic.AppLogic.execu.run(Thread.java:479)
    te(Unknown Source)
    at com.kivasoft.applogic.AppLogic.execute(Unknown Source)
    at com.kivasoft.thread.ThreadBasic.run(Native Method)
    at java.lang.Thread.run(Thread.java:479)
    Any kind of help is appreciated. I am using iPlanet App Builder 6.0 with iAS
    6.0 SP1.
    Thanks
    Bhaskara Murthy
    Eclipse Networks Inc

    "Bhamu" <[email protected]> wrote in message
    news:9keuo4$[email protected]..
    I am trying to develop an entity bean attached to a key which have a
    composite key using Primary Key Class. When I use the findByPrimaryKey
    method of the bean it throws an exception as follows,I notice that you are using the reference CMP plugin.
    at com.netscape.server.ejb.SQLPersistenceManager.find(Unknown Source)I'm also willing to bet that you may have created your own primary key class
    with a single field, rather than using the fields type as a primitive
    primary key class. If you do this, then SQLPersistenceManager will break.
    It is badly written, and has some stupid assumptions. The one I remember
    the most is that if you only have one primary key field, then
    SQLPersistenceManager assumes you have used a primitive type such as
    java.lang.String or java.lang.Integer, to represent it, rather than creating
    your own <Enity>Pk.java file.
    SQLPersistenceManager works for toy examples, but in general I would say it
    is broken and unusable. Either use BMP, or splash out the money for Coco
    Base from Thought Inc. Currently the only CMP plugin for iPlanet App server,
    other than the reference implementation, that I know of.

  • CMP Entity Bean With Primary Key of int

    Is it valid to have a CMP Entity Bean (v1.1) where the primary key is defined as the primitive 'int' instead of a true Java class?
    Thanks in advance,
    Marc

    Hi,
    Ur primary key in the EJB cant be a primitive data type. If the primary key in the table is a int,
    then u will hv [bold] java.lang.Integer [bold] as the datatype in Entity Bean. If u hv further queries write me at [email protected]
    Kesavan.

  • Javax.ejb.ObjectNotFoundException: Bean with primary key '555' was not foun

    When I delete a particular entity bean instance, i get the following exception:
    javax.ejb.ObjectNotFoundException: Bean with primary key '555' was not found by 'findByPrimaryKey'.
    But, the instance is being deleted from the database.
    Anyone please help,
    Thank u,
    Seshu

    Greetings,
    When I delete a particular entity bean instance, i get
    the following exception:
    javax.ejb.ObjectNotFoundException: Bean with primary
    key '555' was not found by 'findByPrimaryKey'.Interesting. How is your client calling the bean's remove method? Directly or through its home? Is it calling findByPrimaryKey before or after the call to remove? What is the PrimaryKey class type of your bean? Is the client passing a correct instance? All are things to be considered when troubleshooting your application. If more assistance is required, then seeing the relevant source code would be more helpful.
    But, the instance is being deleted from the database.As is generally to be expected. No?
    Anyone please help,
    Thank u,
    SeshuRegards,
    Tony "Vee Schade" Cook

  • WLS8.1sp4 running into Bean with primary key

    We're facing an interesting issue with WLS8.1sp4.
    We have upgraded from WLS6.1sp5 to WLS8.1sp4, while testing running into the following error.
    javax.ejb.NoSuchObjectLocalException: [EJB:010140]Bean with primary key: '5375758' not found.: javax.ejb.NoSuchEntityException: [EJB:010140]Bean with primary key: '5375758' not found.
    at weblogic.ejb20.manager.BaseEntityManager.checkForReentrant(BaseEntityManager.java:1460)
    at weblogic.ejb20.manager.DBManager.preInvoke(DBManager.java:251)
    at weblogic.ejb20.internal.BaseEJBLocalObject.preInvoke(BaseEJBLocalObject.java:228)
    at weblogic.ejb20.internal.EntityEJBLocalObject.preInvoke(EntityEJBLocalObject.java:72)
    at edu.harvard.gmas.budget.SegmentLineItemBean_uyzy57_ELOImpl.getSubagreement(SegmentLineItemBean_uyzy57_ELOImpl.java:138)
    at edu.harvard.gmas.budget.SegmentCategoryManager.entityToSegmentLineItemData(SegmentCategoryManager.java:1610)
    at edu.harvard.gmas.budget.SegmentCategoryManager.entityToSegmentCategoryData(SegmentCategoryManager.java:1494)
    at edu.harvard.gmas.budget.SegmentCategoryManager.fetchSegmentCategoryData(SegmentCategoryManager.java:2833)
    at edu.harvard.gmas.budget.CategoryBudgetManager.fetchCategoryBudgetDataForProposedBudget(CategoryBudgetManager.java:2882)
    at edu.harvard.gmas.budget.BudgetMediatorBean.recalculateAndUpdateCategoryAmountsForProposedBudget(BudgetMediatorBean.java:6855)?:|?:|

    The code is already there with JDBC call inserting
    into the table, the inserting trigger then will generate
    sequence key and being inserted into primary key column.
    Now wondering if it's possible to change the code to use entity bean but without modifying the trigger (since it contains other business logics).

  • Entity bean - Unknow primary key problem

    Hi,
    We are using entity bean with unknown primary key option to generate the primary key automatically. It works for all the tables except one table. What we observe is, auto generated primary key is less than the max value in the table and is clashing with one existing record. Any thoughts on what could be wrong?
    Your help is highly appreciated.
    Regards,
    Chandra
    Edited by: Chandrashekhar Singh on Mar 3, 2008 6:39 PM

    Hi,
    I think Vladimir's answer can help you.
    [Entity bean - getting Duplicate Key Exception on ejbCreate;
    Regards
    Pavel

  • Can't deploy BMP Entity bean (iAS903)

    When I create findAll() method in Local interface and try to deploy apllication with BMP, server return "Deployment failed: Nested exception Root Cause: Syntax error in source. Syntax error in source".
    If remove findAll(), all OK.
    If use Remote interface - also all OK.
    How does BMP with fildAll() in Local interface deploy in iAS903?
    thanks
    Alexey.

    Alexey -- A fix will be coming out in the next release but before then you can ask your support representative for a patch for bug#2587584. This should solve the problem.
    Thanks -- Jeff

  • Error While Deploying A CMP Entity Bean With A Composite Primary Key

    Hello all,
    I have a problem deploying CMP Entity beans with composite primary keys. I have a CMP Entity Bean, which contains a composite primary key composed of two local stubs. If you know more about this please respond to my post on the EJB forum (subject: CMP Bean Local Stub as a Field of a Primary Key Class).
    In the mean time, can you please tell me what following error message means and how to resolve it? From what I understand it might be a problem with Sun ONE AS 7, but I would like to make sure it's not me doing something wrong.
    [05/Jan/2005:12:49:03] WARNING ( 1896):      Validation error in bean CustomerSubscription: The type of non-static field customer of the key class
    test.subscription.CustomerSubscriptionCMP_1530383317_JDOState$Oid must be primitive or must implement java.io.Serializable.
         Update the type of the key class field.
         Warning: All primary key columns in primary table CustomerSubscription of the bean corresponding to the generated class test.subscription.CustomerSubscriptionCMP_1530383317_JDOState must be mapped to key fields.
         Map the following primary key columns to key fields: CustomerSubscription.CustomerEmail,CustomerSubscription.SubscriptionType. If you already have fields mapped to these columns, verify that they are key fields.Is it enough that a primary key class be serializable or all fields have to implement Serializable or be a primitive?
    Please let me know if you need more information to answer my question.
    Thanks.
    Nikola

    Hi Nikola,
    There are several problems with your CMP bean.
    1. Fields of a Primary Key Class must be a subset of CMP fields, so yes, they must be either a primitive or a Serializable type.
    2. Sun Application Server does not support Primary Key fields of an arbitrary Serializable type (i.e. those that will be stored
    as BLOB in the database), but only primitives, Java wrappers, String, and Date/Time types.
    Do you try to use stubs instead of relationships or for some other reason?
    If it's the former - look at the CMR fields.
    If it's the latter, I suggest to store these fields as regular CMP fields and use some other value as the PK. If you prefer that
    the CMP container generates the PK values, use the Unknown
    PrimaryKey feature.
    Regards,
    -marina

  • Bad Performance/OutOfMemory Error in CMP Entity Bean with Large DB

    Hello:
    I have an CMP Entity deployed on WLS 7.0
    The entity bean maps to a table that has 97,480 records.
    It has a finder: findAll() -- SELECT OBJECT(e) FROM Equipment e
    I have a JSP client that invokes the findALL()
    The performance is very poor ~ 150 seconds just to perform the findAll() - (Benchmark
    from within the JSP code)
    If more than one simultaneous call is made then I get outOfMemory Error.
    WLS is started with max memory of 512MB
    EJB is deployed with <max-beans-in-cache>100000</max-beans-in-cache>
    (without max-beans-in-cache directive the performance is worse)
    Is there any documentation available to help us in deploying CMP Entity Beans
    with very large number of records (instances) ?
    Any help is greatly appreciated.
    Regards
    Rajan

    Hi
    You should use a Select Method, it does support cursors.
    Or a Home Select Method combination.
    Regards
    Thomas
    WLS is started with max memory of 512MB
    EJB is deployed with <max-beans-in-cache>100000</max-beans-in-cache>>
    (without max-beans-in-cache directive the performance is worse)>
    Is there any documentation available to help us in deploying CMP
    Entity Beans with very large number of records (instances) ? Any help
    is greatly appreciated.>
    Regards>
    Rajan>
    >
    "Rajan Jena" <[email protected]> schrieb im Newsbeitrag
    news:3dadd7d1$[email protected]..
    >
    Hello:
    I have an CMP Entity deployed on WLS 7.0
    The entity bean maps to a table that has 97,480 records.
    It has a finder: findAll() -- SELECT OBJECT(e) FROM Equipment e
    I have a JSP client that invokes the findALL()
    The performance is very poor ~ 150 seconds just to perform the findAll() -(Benchmark
    from within the JSP code)
    If more than one simultaneous call is made then I get outOfMemory Error.
    WLS is started with max memory of 512MB
    EJB is deployed with <max-beans-in-cache>100000</max-beans-in-cache>
    (without max-beans-in-cache directive the performance is worse)
    Is there any documentation available to help us in deploying CMP EntityBeans
    with very large number of records (instances) ?
    Any help is greatly appreciated.
    Regards
    Rajan

  • Creating entity beans with auto numbered primary key

    I have two entity bean with a CMR between them. I am successfully creating the first one but when I try and create the child entity bean I get a NullPointerException.
    Now I think this is because the gernerated code tries to get the primary key of the created entity bean and this is not set as it is set using a auto number in the database (An oracle sequence and trigger).
    Is there anyway i can get round this problem?
    Thanks in advance,
    Adrian

    This is the auto generated code:
         public dmd.sync.ejbs.entity.AppliancePackInfoLocal create_Local(dmd.sync.dataobjects.dto.AppliancePackInfoDTO appliancePackInfoDTO, dmd.sync.ejbs.entity.AmppLocal amppLocal) throws javax.ejb.CreateException, java.rmi.RemoteException {
              BeanO beanO = null;
              dmd.sync.ejbs.entity.AppliancePackInfoLocal result = null;
              boolean createFailed = false;
              boolean preCreateFlag = false;
              try {
                   beanO = super.createBeanO();
                   dmd.sync.ejbs.entity.AppliancePackInfoBean bean = (dmd.sync.ejbs.entity.AppliancePackInfoBean) beanO.getEnterpriseBean();
                   preCreateFlag = super.preEjbCreate(beanO);
                   bean.ejbCreate(appliancePackInfoDTO, amppLocal);
                   Object ejsKey = keyFromBean(bean);
                   result = (dmd.sync.ejbs.entity.AppliancePackInfoLocal) super.postCreate_Local(beanO, ejsKey, true);
                   bean.ejbPostCreate(appliancePackInfoDTO, amppLocal);
                   super.afterPostCreate(beanO, ejsKey);
    It must be falling over on the last line as it calls the ejbPostCreate fine.

  • CMP entity bean with compound primary key

    I'm trying to use a compound primary key in a CMP entity bean. I've created the custom primary key class okay, and I have the prim-key-class set in ejb-jar.xml. My client app gets the home reference okay, but when it tries to find an entity, I get the exception "SQLException: Incorrect syntax near '/'."
    I think I'm having trouble deploying this in OC4J. Is there a sample orion-ejb-jar.xml deployment for a custom, compound primary key somewhere?
    Many thanks for any help.
    Ernie

    Never mind. I solved my problem. Thanks.

  • Do I need to Create Primary Key Class for Entity beans with Local interface

    Do I need to Create Primary Key Class for Entity beans with Local interface?
    I have created my entity bean with the wizard in Sun One Studio and it does not create a primary key class for you.
    I thought that the primary key class was required. My key is made up of only one field.
    Anyone know the answer.
    Jim

    u dont need to create a primary key class for a entity bean.if ur table's primary key feild(int ,float) is a built in or primitive data type,then u dont need one.But if ur table has a primary key field which is non primitive (for example StudentID,ItemID etc)then u have to create a primary key class.
    hope this helps :-)

  • BMP-/CMP-Entity Beans with JBoss 3.0 & MySQL 3.23

    Hi @all!
    Sorry, I`m a beginner in development of EJBs, but I`ve got already two of them (a session bean, a cmp-bean with Hypersonic DB) running.
    Now my question:
    Is it possible to develop bmp- or cmp-beans with JBuilder 6.0 and AppServer JBoss 3.0 and MySQL as relational database.
    If anybody here, has ever done this.
    Please contact for one or two short questions like:
    What will I have to do to get MySQL as persistence medium in JBoss?
    What will I have to do to get MySQL by a bmp-entity-bean over JNDI?
    What will I have to do to run my program? ;-)
    I�m always getting error messages like:
    ...no such entity...
    Or:
    ...MyDB not bound...
    Thanks
    Michael

    Now, I`ve done a little step in the right direction:
    It is possible to create CMP-Beans with JBoss 3.0 and MySQL database.
    You just have to put both on the same machine ;-) (Incredible...)
    But now I`ve got problems to implement a bean-managed-persistence Bean with JBoss 3.0 and mySQL.
    If I start my client application, I get the following error messages, although my EJB is correctly deployed:
    -- I`m calling: create(17, max, [email protected])
    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
         java.rmi.ServerException: null
    Embedded Exception
    null; nested exception is:
         javax.ejb.EJBException: null
    Embedded Exception
    null
         at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:292)
         at sun.rmi.transport.Transport$1.run(Transport.java:148)
         at java.security.AccessController.doPrivileged(Native Method)-- Erfolglos: create(17, max, [email protected])
         at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
         at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
         at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
         at java.lang.Thread.run(Thread.java:536)
         at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:250)
         at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:226)
         at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:136)
         at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
         at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:128)
         at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:108)
         at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:73)
         at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:76)
         at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:185)
         at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
         at $Proxy0.create(Unknown Source)
         at gaestebuch.BMPTestClient.create(BMPTestClient.java:71)
         at gaestebuch.BMPTestClient.main(BMPTestClient.java:309)
    Caused by: java.rmi.ServerException: null
    Embedded Exception
    null; nested exception is:
         javax.ejb.EJBException: null
    Embedded Exception
    null
         at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:119)
         at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:167)
         at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:52)
         at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:104)
         at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:109)
         at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
         at org.jboss.ejb.Container.invoke(Container.java:726)
         at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1055)
         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
         at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:362)
         at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
         at sun.rmi.transport.Transport$1.run(Transport.java:148)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
         at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
         at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
         at java.lang.Thread.run(Thread.java:536)
    Caused by: javax.ejb.EJBException: null
    Embedded Exception
    null
         at org.jboss.ejb.plugins.BMPPersistenceManager.createEntity(BMPPersistenceManager.java:246)
         at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:270)
         at org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:728)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1116)
         at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:257)
         at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:215)
         at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:134)
         at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:79)
         at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:44)
         at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:98)
         ... 19 more
    -- return of create(17, max, [email protected]): null.
    What is my mistake?
    Thanks, Michael

  • Did elationship fields in entity bean with CMP same as foreign key in table

    did elationship fields in entity bean with CMP same as foreign key in table database.so we don't have to make some foreign key column in table database.
    did Container handle that both.
    I need some answer
    thank's

    Suppose you have Group and user entity. Relation is 1-m. One group many users. When you create user, you dont need to send group id, All you need is create user and add it in collection (cmr-field) in group(user belongs to). Container will add its group id in user entity as well as in db.

Maybe you are looking for