Newbie - problem with Session & CMP entity combination in IBM Websphere studio application developer.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mohamed_Imdadullah
Posted On:   Thursday, June 6, 2002 08:57 AM

Hi all, Trying to implement a scenario with session and CMP entity bean on IBM Websphere using Studio Application Developer. I have been able to create the required entity bean from the database table. I am trying to access this entity bean from my session bean using the findByPrimaryKey method of the entity Home interface. I seem to get the following error while compiling " The method findByPrimaryKey(CustomerWebservice.CustKey) from the type CustomerWebservice.CustHome is not static" where CustKey is the Keyclass for the entitybean cust and CustHome is the Home Interface for the entitybean. I must be doin some silly mista   More>>

Hi all,


Trying to implement a scenario with session and CMP entity bean on IBM Websphere using Studio Application Developer.


I have been able to create the required entity bean from the database table.


I am trying to access this entity bean from my session bean using the findByPrimaryKey method of the entity Home interface.


I seem to get the following error while compiling
" The method findByPrimaryKey(CustomerWebservice.CustKey) from the type CustomerWebservice.CustHome is not static"


where CustKey is the Keyclass for the entitybean cust and CustHome is the Home Interface for the entitybean.


I must be doin some silly mistake, would be delighted to have some enlightment on that. I have also included below the Session bean code.


thanx in advance.


arif


			


package CustomerWebservice;

import javax.naming.*;
import javax.ejb.*;
import java.util.*;
import java.math.*;
import CustomerJavaBean.CheckCust;

/**
* Bean implementation class for Enterprise Bean: CustomerSession
*/
public class CustomerSessionBean implements javax.ejb.SessionBean {

// Cache home
private CustHome custentityHome;


private javax.ejb.SessionContext mySessionCtx;
/**
* getSessionContext
*/
public javax.ejb.SessionContext getSessionContext() {
return mySessionCtx;
}
/**
* setSessionContext
*/
public void setSessionContext(javax.ejb.SessionContext ctx) {
mySessionCtx = ctx;
}
/**
* ejbActivate
*/
public void ejbActivate() {
}
/**
* ejbCreate
*/
public void ejbCreate() throws javax.ejb.CreateException {
}
/**
* ejbPassivate
*/
public void ejbPassivate() {
}
/**
* ejbRemove
*/
public void ejbRemove() {
}

/**
* getCustomerHome - to find the customer home
*/
private CustHome getCustHome() {

if (custentityHome == null) {
try {
InitialContext ic = new InitialContext();
//Object objref = ic.lookup("Cust");
Object objref = ic.lookup("java:comp/env/ejb/Cust");
custentityHome = (CustHome)javax.rmi.PortableRemoteObject.narrow
(objref, CustHome.class);
} catch (NamingException ex){
ex.printStackTrace();
throw new EJBException("Error looking up CustHome: "+
ex.getMessage());
}
}
return custentityHome;
}
/**
* getCustomername - to find the customer name
*/

public void inquireCustomer(BigDecimal id){
Cust customer = null;

try{

customer = CustHome.findByPrimaryKey(new CustKey(id));

}catch (FinderException ex) {
System.out.println("Cannot find Customer: "+id);
ex.printStackTrace();
} catch (java.rmi.RemoteException ex) {
ex.printStackTrace();
}
}
}
   <<Less

Re: Newbie - problem with Session & CMP entity combination in IBM Websphere studio application developer.

Posted By:   Mohamed_Imdadullah  
Posted On:   Thursday, June 6, 2002 09:31 AM

Hi,

Found the answer, it was a stupid mistake, in the inquireCustomer method, instead of using the getCustHome method i was using the return type custHome.

regards
About | Sitemap | Contact