• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

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: 26019
186
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 ]
 
You got style baby! More than this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic