• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

BMP question,Help me!

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I make a BMP with jb6 from a CMP,The CMP is work well in Weblogic61,But the BMP is error:
Start server side stack trace:
java.rmi.RemoteException: EJB Exception:; nested exception is:
java.lang.NullPointerException
java.lang.NullPointerException
at testbmp2.CabinBean.ejbCreate(CabinBean.java:31)
at testbmp2.CabinBean_12m8qx_Impl.ejbCreate(CabinBean_12m8qx_Impl.java:172)
at java.lang.reflect.Method.invoke(Native Method)
at weblogic.ejb20.manager.DBManager.create(DBManager.java:492)
at weblogic.ejb20.manager.DBManager.remoteCreate(DBManager.java:462)
at weblogic.ejb20.internal.EntityEJBHome.create(EntityEJBHome.java:190)
at testbmp2.CabinBean_12m8qx_HomeImpl.create(CabinBean_12m8qx_HomeImpl.java:75)
at testbmp2.CabinBean_12m8qx_HomeImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:298)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:93)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:267)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:22)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
End server side stack trace
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"flaying"
Please note that JavaRanch has a naming standard that requires the use of your real first name - space - your real last name. Please change your display name to reflect this. Thanks.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, so what is happening at line 31 of your BMP cabin bean? Insert some System.out.println() statements or use a debugger and find out what object is null...
Kyle
 
flaying ma
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But at line31,is a testClient load a remote Bean's mothed!
Some one tell me there is't have a remote mothed,So the error is "NullPointerException"
Why! help me! Thanks a lots!
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by flaying ma:
But at line31,is a testClient load a remote Bean's mothed!
Some one tell me there is't have a remote mothed,So the error is "NullPointerException"
Why! help me! Thanks a lots!


Show us the code around that error. Perhaps we can see if you are accessing the bean correctly.
 
flaying ma
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
package testbmp2;
import javax.ejb.*;
import java.util.*;
import java.rmi.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
public class CabinBean implements EntityBean {
public EntityContext entityContext;
public Integer ID;
public String Name;
//next is ejbCreate **********************************************************
public Integer ejbCreate(java.lang.Integer id) throws CreateException {
this.ID = id;
Connection conn = null;
PreparedStatement ps = null;
try
{
try
{
conn = getConnection();
}
catch(Exception e)
{
e.printStackTrace();
}
ps = conn.prepareStatement("insert into Cabin (id, name) values (?, ?)");
ps.setInt(1, id.intValue());
ps.setString(2, "");
if(ps.executeUpdate() != 1)
{
throw new CreateException("Filed to add Cabin to database!");
}
return id;
}
catch(SQLException e)
{
throw new EJBException(e);
}
finally
{
try
{
if(ps != null)
{
ps.close();
}
if(conn != null)
{
conn.close();
}
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
........................
package testbmp2;
import javax.ejb.*;
import java.util.*;
import java.rmi.*;
public interface CabinRemote extends javax.ejb.EJBObject {
public void setId(java.lang.Integer id) throws RemoteException;
public java.lang.Integer getId() throws RemoteException;
public void setName(java.lang.String name) throws RemoteException;
public java.lang.String getName() throws RemoteException;
}
..................................
package testbmp2;
import javax.ejb.*;
import java.util.*;
import java.rmi.*;

public interface CabinRemoteHome extends javax.ejb.EJBHome {
public CabinRemote create(java.lang.Integer id) throws CreateException, RemoteException;
public CabinRemote findByPrimaryKey(java.lang.Integer id) throws FinderException,RemoteException;
}
....................................
package testbmp2;
import javax.naming.*;
import java.util.Properties;
import javax.rmi.PortableRemoteObject;
public class CabinTestClient1 {
private static final String ERROR_NULL_REMOTE = "Remote interface reference is null. It must be created by calling one of the Home interface methods first.";
private static final int MAX_OUTPUT_LINE_LENGTH = 100;
private boolean logging = true;
private CabinRemoteHome cabinRemoteHome = null;
private CabinRemote cabinRemote = null;
//CabinTestClient1 cabinTestClient1 = new CabinTestClient1();
//Construct the EJB test client
public CabinTestClient1() {
long startTime = 0;
if (logging) {
log("Initializing bean access.");
startTime = System.currentTimeMillis();
}
try {
//get naming context
Context ctx = getInitialContext();
//look up jndi name
Object ref = ctx.lookup("CabinRemote");
//cast to Home interface
cabinRemoteHome = (CabinRemoteHome) PortableRemoteObject.narrow(ref, CabinRemoteHome.class);
if (logging) {
long endTime = System.currentTimeMillis();
log("Succeeded initializing bean access.");
log("Execution time: " + (endTime - startTime) + " ms.");
}
try
{
java.lang.Integer id = new Integer("112");
log("The id ="+id);
//cabinRemote = cabinRemoteHome.findByPrimaryKey(id);
CabinRemote cabinRemote = cabinRemoteHome.create(id);
cabinRemote.setName("runFrank");
}
catch(Exception e)
{
log("@The error is:"+e);
e.printStackTrace();
}
.........
 
Saloon Keeper
Posts: 27485
195
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By my reckoning "conn" is still null when you invoke prepareStatement(). Possibly related is the fact that although you catch exceptions attempting to initialize conn, you then go ahead and attempt to use it anyway. If conn didn't initialize, you really ought to just throw an EJBCreateException, since you can't do anything further anyway.
[ March 11, 2002: Message edited by: Tim Holloway ]
 
A sonic boom would certainly ruin a giant souffle. But this tiny ad would protect it:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic