简单的bmp请指教错误。
java.lang.NullPointerException: narrowFrom'null' narrowTo:'interface yang2.DeptRemoteHome'It is invalid to call narrow with null parameters
at weblogic.iiop.PortableRemoteObjectDelegateImpl.narrow(PortableRemoteObjectDelegateImpl.java:94)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
at yang2.DeptTestClient1.main(DeptTestClient1.java:331)-- Succeeded initializing bean access through Home interface.
这是报的错误。
bean类如下:
import javax.ejb.*;
import java.sql.*;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import java.sql.*;
public class DeptBean implements EntityBean {
PreparedStatement ps;
Connection con;
EntityContext entityContext;
java.math.BigDecimal deptno;
java.lang.String dname;
java.lang.String loc;
public java.math.BigDecimal ejbCreate(java.math.BigDecimal deptno) throws CreateException {
setDeptno(deptno);
return null;
}
public void ejbPostCreate(java.math.BigDecimal deptno) throws CreateException {
/**@todo Complete this method*/
}
public void ejbRemove() throws RemoveException {
/**@todo Complete this method*/
}
public void setDeptno(java.math.BigDecimal deptno) {
this.deptno = deptno;
}
public void setDname(java.lang.String dname) {
this.dname = dname;
}
public void setLoc(java.lang.String loc) {
this.loc = loc;
}
public java.math.BigDecimal getDeptno() {
return deptno;
}
public java.lang.String getDname() {
return dname;
}
public java.lang.String getLoc() {
return loc;
}
public java.math.BigDecimal ejbFindByPrimaryKey(java.math.BigDecimal deptno) throws FinderException {
System.out .println("FindByPrimaryKey begins");
try {
ps=con.prepareStatement("SELECT DEPTNO,DNAME,LOC FROM dept WHERE DEPTNO=?");
ps.setBigDecimal(1,deptno);
ResultSet rs=ps.executeQuery() ;
if(rs.next())
{
this.deptno =rs.getBigDecimal(1);
this.dname =rs.getString(2);
this.loc=rs.getString(3);
}
else{
System.out .println("find error");
}
}
catch (SQLException ex) {
throw new EJBException("Exception"+ex);
}
try {
ps.close();
}
catch (SQLException ex1) {
System.out .println("cannt"+ex1);
}
System.out .println("enc");
return deptno;
}
public void ejbLoad() {
/**@todo Complete this method*/
}
public void ejbStore() {
/**@todo Complete this method*/
}
public void ejbActivate() {
/**@todo Complete this method*/
}
public void ejbPassivate() {
/**@todo Complete this method*/
}
public void unsetEntityContext() {
this.entityContext = null;
}
public void setEntityContext(EntityContext entityContext) {
this.entityContext = entityContext;
try{
System.out .print("make connection");
makeConnection();
}
catch(Exception ex){
throw new EJBException("unable connection"+ex);}
}
public Connection makeConnection() {
try {
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup("jkbc/scottDataSource");
con = ds.getConnection();
return con;
}
catch (Exception ex) {
System.out .print("Exception in connection"+ex);
return null;
}
}
}