File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "Error with BMP Entity Bean" Watch "Error with BMP Entity Bean" New topic
Author

Error with BMP Entity Bean

Jorge Chata
Greenhorn

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: 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

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: http://aspose.com/file-tools
 
subject: Error with BMP Entity Bean
 
Similar Threads
About BMP Entity Bean problem
ResultSet can not print the first row
unable to recognize jndi name when using myeclipse3.8.3
how to deploye EJB
a session bean contacts an entity bean