• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

About BMP Entity Bean problem

 
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
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jorge,
Try this stuff :
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/DataSource");
Connection conn = ds.getConnection();
where jdbc/DataSouce is name of your datasource which u have created using admin console of websphere.
I guess something is wrong with your connection? also please check the user name and password too. It should be in proper case I think.
Vipul.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not using CMP Entity Beans.
I have been getting the same error, but not always. This problem occurs if I try to create multiple instances of the beans simulatneously. FOr eg, if I try to run about 7 instances, then the first 3-4 get processed correctly while the remaining ones bomb with the following error :
RemoteException occurred in server thread; nested exception is:
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

THis error occurs for the subsequent failing transaction :
RemoteException occurred in server thread; nested exception is:
com.ibm.ejs.persistence.EJSPersistenceException: java.sql.SQLException: ORA-08177: can't serialize access for this transaction
; nested exception is:
java.sql.SQLException: ORA-08177: can't serialize access for this transaction
RemoteException occurred in server thread; nested exception is:
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
RemoteException occurred in server thread; nested exception is:
com.ibm.ejs.persistence.EJSPersistenceException: java.sql.SQLException: ORA-08177: can't serialize access for this transaction
; nested exception is:
java.sql.SQLException: ORA-08177: can't serialize access for this transaction

It has no problem with the connection, else it wouldn;t have executed for the first 3-4 cases at all. If I run each of the 7 cases one at a time, then they all go through correctly, but give problems when run simultaneously.
The beans have been deployed with
Any idea what the problem could be?
THanks,
Deepa
 
author
Posts: 3892
5
Redhat Quarkus Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by vipul makwana:
Hi Jorge,
Try this stuff :
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/DataSource");
Connection conn = ds.getConnection();
where jdbc/DataSouce is name of your datasource which u have created using admin console of websphere.
I guess something is wrong with your connection? also please check the user name and password too. It should be in proper case I think.
Vipul.



Actually, that won't work -- you didn't read the orginal post carefully enough -- he is working in WebSphere 3.5.X and so the line you have posted (which is for Websphere 4.0 and EJB 1.1) will not work.
However you're close. His problem probably is that the datasource name isn't correct. Just don't try to use the EJB 1.1 style of naming -- what he's done later (jdbc/SomeName) is the style he needs to use.

------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
[This message has been edited by Kyle Brown (edited October 01, 2001).]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic