Win a copy of Penetration Testing Basics this week in the Security forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error with BMP Entity Bean

Jorge Chata
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: java.lang.NullPointerException; nested exception is: java.lang.NullPointerException java.lang.NullPointerException; nested exception is: java.lang.NullPointerException java.lang.NullPointerException
EjbCreate() method :
public String ejbCreate(double bonus, String socsec)
throws RemoteException,
SQLException {
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(
ps.setString(1, socsec);
ps.setDouble(2, bonus);
} catch (javax.naming.NamingException ex) {
} finally {
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() {
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) {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
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 ( {
out.println(""); do { out.println(""); } while (; 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

Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that you�re not getting the reference to the EJB when you do:
Object objref = ctx.lookup("beans/Bonn");
try like this
Object objref = ctx.lookup("java:comp/env/beans/Bonn");
ah! and check if you declared a reference to beans/Bonn at the web.xml
I hope this helps.
[This message has been edited by Marcos Maia (edited August 03, 2001).]
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic