-
1. Re: Could not instantiate the bean, Urgent help please
raja05 Apr 29, 2003 5:43 PM (in response to krishkumar)Post some code, I would check the setEntityContext and teh constructor(if you have one) for the EntityBean.
-
2. Re: Could not instantiate the bean, Urgent help please
krishkumar Apr 29, 2003 5:55 PM (in response to krishkumar)Thank you for thr immediate reply, here is the src for ProductPK.java and ProductBean.java,
ProductPk.java :
____________
public class ProductPK implements Serializable{
public String productID;
public ProductPK( String id) {
this.productID = id;
}
public ProductPK() {
}
public String toString() {
return productID.toString();
}
public int hashCode() {
return productID.hashCode();
}
public boolean equals( Object prod) {
return ((ProductPK)prod).productID.equals(productID);
}
}
ProductBean.java
_______________
public abstract class ProductBean implements EntityBean {
protected EntityContext ctx;
public ProductBean() {
}
public abstract void setName(String name);
public abstract void setDescription(String desc);
public abstract void setBasePrice(double price);
public abstract void setProductID(String id);
public abstract String getName();
public abstract String getDescription();
public abstract double getBasePrice();
public abstract String getProductID();
public void ejbActivate() {
System.out.println("ejbActivate Method called ");
}
public void ejbPassivate() {
System.out.println("ejbPassivate Method called ");
}
public void ejbLoad() {
System.out.println("ejbLoad Method called ");
}
public void ejbStore() {
System.out.println("ejbStore Method called ");
}
public void ejbRemove() {
System.out.println("ejbRemove Method Called ");
}
public void setEntityContext(EntityContext ctx) {
this.ctx = ctx;
}
public void unsetEntityContext() {
this.ctx = null;
}
public void ejbPostCreate(String id,String name,String desc,double price) {
System.out.println( " ejbPostCreate called ");
}
public String ejbCreate(String productid,String name, String description,double price){
System.out.println( "ejbCreate Called ");
setProductID(productid) ;
setName(name);
setDescription(description);
setBasePrice(price);
return new ProductPK(productid).toString();
}
} -
3. Re: Could not instantiate the bean, Urgent help please
raja05 Apr 29, 2003 6:14 PM (in response to krishkumar)Your ejbCreate should return the Primary key class, so it should return ProductPK and not String. It should have definitely not deployed properly if the deployment descriptor reflects this.
-
4. Re: Could not instantiate the bean, Urgent help please
krishkumar Apr 30, 2003 10:40 AM (in response to krishkumar)Deployment procedure went without any problem. I made changes to Bean class to return ProductPK from ejbCreate function. I am still getting the same error, I have attached the client code for your reference. Thanks for your help.
public class ProductClient {
public static void main (String args[]) {
// preparing properties for constructing an InitialContext object
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.PROVIDER_URL, "localhost:1099");
try {
// Get an initial context
InitialContext jndiContext = new InitialContext(properties);
System.out.println("Got context");
Object ref = jndiContext.lookup("Product");
ProductHome productHome = (ProductHome)PortableRemoteObject.narrow (ref, ProductHome.class);
System.out.println("LOADED Product BEAN");
productHome.create("PC2300","P5-350","350 Mhz Pentium",200);
productHome.create("PC2301","P5-400","400 Mhz Pentium",250);
System.out.println("Products created ");
}
catch(Exception e) {
System.out.println(e.toString());
}
}
} -
5. Re: Could not instantiate the bean, Urgent help please
jonmartin May 4, 2003 6:12 PM (in response to krishkumar)Also post some more of the exception trace, in the original posting it seems it was cut off just when it was beginning to get interesting ....
-
6. Re: Could not instantiate the bean, Urgent help please
websel Sep 9, 2005 11:57 AM (in response to krishkumar)Check if there are any errors during deploying.
I've been searching my head of for over 4 hours to find out why this error is occuring. Finaly i found out that one of my EJB-QL queries had an error on a total different bean, and it had it's effect on the bean that coun't instantiated.
My tip, check if there are already errors during deploying your beans. this might be the key to your dropout later.
Wessel de Roode