File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Error with BMP Entity Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Error with BMP Entity Bean" Watch "Error with BMP Entity Bean" New topic

Error with BMP Entity Bean

Jorge Chata

Joined: Jul 06, 2001
Posts: 24
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

Joined: Jan 06, 2001
Posts: 977
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).]
I agree. Here's the link:
subject: Error with BMP Entity Bean
It's not a secret anymore!