Hello cowboys :
I have troubles with my first BMP Entity Bean. Actually i am working with IBM WebSphere 3.5.3 on Windows NT 4.0 , Oracle V.7.2.3. After of execute with success my first Session Bean.
I have troubles with EjbCreate() method of my Entity Bean when
I call from my
servlet. I got this message error :
java.rmi.ServerException: RemoteException occurred in server
thread; nested exception is: com.ibm.ejs.container.CreateFailureException: java.lang.NullPointerException; nested exception is: java.lang.NullPointerException com.ibm.ejs.container.CreateFailureException: java.lang.NullPointerException; nested exception is: java.lang.NullPointerException java.lang.NullPointerException
EjbCreate() method :
public
String ejbCreate(double bonus, String socsec)
throws RemoteException,
CreateException,
SQLException {
this.socsec=socsec;
this.bonus=bonus;
System.out.println("Create Method");
try {
ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup(dbName);
// next line have the trouble
con = ds.getConnection("user","clave");
// prev line have the trouble
ps = con.prepareStatement(
"INSERT INTO BONUS VALUES (? , ?)");
ps.setString(1, socsec);
ps.setDouble(2, bonus);
ps.executeUpdate();
} catch (javax.naming.NamingException ex) {
ex.printStackTrace();
} finally {
ps.close();
con.close();
}
return socsec;
}
Part of servlet code :
...
public class BonusServlet extends HttpServlet {
CalcHome homecalc;
BonnHome homebonus;
Bonn theBonus, record;
private static DataSource ds = null;
public void init() {
try{
InitialContext ctx = new InitialContext();
Object objref = ctx.lookup("beans/Bonn");
homebonus=(BonnHome)PortableRemoteObject.narrow(objref, BonnHome.class);
Object objref2 = ctx.lookup("beans/Calc");
homecalc=(CalcHome)PortableRemoteObject.narrow(objref2, CalcHome.class);
ds = (DataSource) ctx.lookup("jdbc/dsjorgecht");
} catch (Exception NamingException) {
NamingException.printStackTrace();
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
...
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try{
Calc theCalculation;
String strMult = request.getParameter("MULTIPLIER");
Integer integerMult = new Integer(strMult);
multiplier = integerMult.intValue();
socsec = request.getParameter("SOCSEC");
double bonus = 100;
theCalculation = homecalc.create();
calc = theCalculation.calcBonus(multiplier, bonus);
con = ds.getConnection("user","clave");
stmt = con.createStatement();
rs = stmt.executeQuery("select descri from tablagen1 where tipo = '17'");
if (rs.next()) {
out.println("
DESCRIPCION |
"); do { out.println(""+rs.getString(1)+" |
"); } while (rs.next()); out.println("
");
}
out.println("
");
// next line have the trouble
theBonus = homebonus.create(calc, socsec);
out.println("prev line have the trouble");
record = homebonus.findByPrimaryKey(socsec);
....
Anyboby have some idea about of how to solve this problem
Thanks for your help
Jorge