• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error with BMP Entity Bean

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 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(""); do { out.println(""); } while (rs.next()); out.println("
DESCRIPCION
"+rs.getString(1)+"
");
}
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

 
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
reply
    Bookmark Topic Watch Topic
  • New Topic