cmp entity beans and jboss
afshad Jun 15, 2006 10:59 PMHi
First time Im using CMP with NetBeans 5.0.
Cannot successfully use any finder method. Nothing is returned.
I cant seem to get anything from the database using the finder methods. Ive noticed netbeans by default does not create a : jbosscmp-jdbc.xml file. Is this necessary? Are there any particular files I need to add my self to the enterprise or web application in order to make the cmp beans work??
They seem to deploy fine but at runtime i cant get the finder methods on any beans to work.
Any ideas??
Steps in creating my simple project:
So I added the mysql driver and database connection.
I created an Enterprise application.
In the EJB module, I chose NEW-> CMP Entity bean from DATABASE
In my other session bean created previously, I try to access this entity bean People to get a particular person as follows:
private db.PeopleLocalHome lookupPeopleBean() {
try {
javax.naming.Context c = new javax.naming.InitialContext();
db.PeopleLocalHome rv = (db.PeopleLocalHome) c.lookup("java:comp/env/ejb/PeopleBean");
return rv;
}
catch(javax.naming.NamingException ne) {
java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE,"exception caught" ,ne);
throw new RuntimeException(ne);
}
}
public String getLast() {
db.PeopleLocalHome custHome;
String s="";
custHome = lookupPeopleBean();
try {
String f="Afshad";
/////NOTE: findById does not return anything. in the admin window i can see the output is 0 the size is 0
System.out.println(custHome.findById(new Integer(1)).size());
}
catch(Exception e) {
System.out.println("ascsd");
e.printStackTrace();
}
return s;
}
PROBLEM: The findById does not return anything because when I use size on it I get 0 in the console window of the server. Im using JBoss 4.0.4 as the server.
Even any other finder methods which were autogenerated dont work.
Also if i do
custHome.toString() i get the following output:
[STDOUT] local/PeopleBean@4435599Home
So the bean is deployed fine??
Any one please help!!!!! Any ideas on how to debug?
Thanks