|
 |
enterprise_java_beans thread: entity bean Null pointer exception
Message #1 by "sami" <sami.s.n@l...> on Sat, 16 Dec 2000 12:34:39 -0000
|
|
hi there,
it seems you are using bean managed persistence- can your bean
manage the null fields for persisting? if you are attempting to write
a null field in the database you might get such errors.
greetings
On 16 Dec 00, at 12:34, sami wrote:
this is a program example in pro java server programming j2ee edition
this is the client program
the records are inserted into the datbase but immediately afterwards
iam getting an exception
package sportBean.bmp;
import javax.naming.*;
import java.util.*;
import javax.ejb.*;
import java.rmi.RemoteException;
public class SportClient{
public static void main(String ar[]){
//team=null;
SportTeam team=null;
try{
Object ref=null;
Properties p=new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL,"http://localhost:7001");
System.out.println("properties put the initial context");
Context cc=new InitialContext(p);
System.out.println("got the initial context");
ref=cc.lookup("containerManaged.SportsHome");
SportTeamHome
home=(SportTeamHome)javax.rmi.PortableRemoteObject.narrow(ref,SportTeamHome.class);
System.out.println("home create succesfully");
//SportTeam team=home.create("basketball","queens");
if(home != null){
team=home.create("basketball","kings","joe maloof","jason williams");
}
System.out.println("created remote reference");
if(team != null){
System.out.println("current franchis player"+team.getFranchisePlayer());
team.setFranchisePlayer("dan connor");
System.out.println("new franchise player:"+ team.getFranchisePlayer());
}
Collection collection= home.findByOwnerName("joe maloof");
Iterator iter=collection.iterator();
if(! iter.hasNext()){
System.out.println("found no such owner");
}
else{
Object ref2=iter.next();
SportTeam
teamRef2=(SportTeam)javax.rmi.PortableRemoteObject.narrow(ref2,SportTeam.class);
System.out.println("owner name" +teamRef2.getOwner());
}
team.remove();
}
catch(RemoteException re){
re.printStackTrace();
}
catch(NamingException re){
re.printStackTrace();
}
catch(CreateException ce){
ce.printStackTrace();
}
catch(RemoveException re){
re.printStackTrace();
}
catch(FinderException re){
re.printStackTrace();
}
}
}
and this is the out put of the client
properties put the initial context
Connected successfully using http to localhost/127.0.0.1:7001
got the initial context
home create succesfully
java.rmi.UnexpectedException: Unexpected exception in
sportBean.bmp.SportTeamEJB
.create():
java.lang.NullPointerException:
at
weblogic.ejb.internal.LockManagerImpl.unlock(LockManagerImpl.java:160
)
at
weblogic.ejb.internal.StatefulEJBCache.unbind(StatefulEJBCache.java:5
28)
at
weblogic.ejb.internal.BaseEJBContext.afterCompletion(BaseEJBContext.j
ava:333)
at
weblogic.ejb.internal.EntityEJBContext.afterCompletion(EntityEJBConte
xt.java:240)
at
weblogic.ejb.internal.StatefulEJBObject.postInvokeNoTx(StatefulEJBObj
ect.java:315)
at
weblogic.ejb.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:663
)
at
sportBean.bmp.SportTeamEJBEOImpl.create(SportTeamEJBEOImpl.java:120)
at
sportBean.bmp.SportTeamEJBHomeImpl.create(SportTeamEJBHomeImpl.java:4
1)
at
sportBean.bmp.SportTeamEJBHomeImpl_WLSkel.invoke(SportTeamEJBHomeImpl
_WLSkel.java:144)
at
weblogic.rmi.extensions.BasicServerObjectAdapter.invoke(Compiled Code
)
at
weblogic.rmi.extensions.BasicRequestHandler.handleRequest(BasicReques
tHandler.java:69)
at
weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
.java:15)
at weblogic.kernel.ExecuteThread.run(Compiled Code)
; nested exception is:
java.lang.NullPointerException:
java.lang.NullPointerException:
---
NEED TECHNICAL TIPS, TOOLS, AND INSIGHTS? Is FREE okay?
Visit EarthWeb for the latest in IT Management, Software Development,
Web Development, Networking & Communications, and Hardware & Systems.
Click on http://www.earthweb.com for FREE articles, tutorials,
and discussions from the experts.
---
You are currently subscribed to enterprise_java_beans as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-enterprise_java_beans-$subst('Recip.MemberIDChar')@p2p.wrox.com
|
|
 |