Hi all
JBoss 2 final
I have a session bean that does a DB select,
then loads up a number of entity beans.
Sometimes while loading the entity beans, after
loading some of the beans, i get a null pointer exception
getting the PK from the beans context...
Anyone got any tips/suggestions?
Peter.
--- entity bean ----
public void ejbLoad() throws
javax.ejb.EJBException, java.rmi.RemoteException
{
if ( VERBOSE )
System.out.println("in ejbLoad"
);
long starttime =
System.currentTimeMillis();
ContactPK pk =
(ContactPK)ctx.getPrimaryKey();
this.db_data.id = pk.id;
// LINE
61
this.isModified =
false;
...
public void
setEntityContext(EntityContext ctx) throws javax.ejb.EJBException,
java.rmi.RemoteException {
this.ctx = ctx;
}
public void
unsetEntityContext() throws javax.ejb.EJBException, java.rmi.RemoteException
{
ctx =
null;
}
--- contact entity pk ---
public class ContactPK implements
java.io.Serializable {
int
id; // the unique database
id.
public ContactPK(int id)
{
this.id =
id;
}
public ContactPK()
{
this.id =
-1;
}
public String toString()
{
return "[ContactPK(id=" +
Integer.toString(id) + "]";
}
public int hashCode()
{
return
id;
}
public boolean
equals(Object parm1) {
return
this.id == ((ContactPK)parm1).id;
}
}
JBoss Output
[ContactBean] ContactBean.ejbFindByPrimaryKey took 90
ms
[ContactBean] ContactBean.ejbLoad took130 ms
[ContactBean]
ContactBean.ejbFindByPrimaryKey took 181 ms
[ContactBean]
ContactBean.ejbLoad took120 ms
[ContactBean]
ContactBean.ejbFindByPrimaryKey took 110 ms
[ContactBean]
ContactBean.ejbLoad took201 ms
[ContactBean]
ContactBean.ejbFindByPrimaryKey took 280 ms
[ContactBean]
ContactBean.ejbLoad took221 ms
[ContactBean]
ContactBean.ejbFindByPrimaryKey took 160 ms
[ContactBean] TRANSACTION
ROLLBACK EXCEPTION:null; nested exception
is:
javax.ejb.EJBException
[ContactBean]
java.lang.NullPointerException
[ContactBean] at
com.cpt.contactcenter.server.ContactBean.ejbLoad(ContactBean.java:61)
[ContactBean]
at java.lang.reflect.Method.invoke(Native
Method)
[ContactBean] at
org.jboss.ejb.plugins.BMPPersistenceManager.loadEntity(BMPPersistenceManager.java:275)
[ContactBean]
at
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:192)
[ContactBean]
at
org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:204)
[ContactBean]
at
org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:133)
[ContactBean]
at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:263)
[ContactBean]
at
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:99)
[ContactBean]
at
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:144)
[ContactBean]
at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
[ContactBean]
at
org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:323)
[ContactBean]
at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:237)
[ContactBean]
at
org.jboss.ejb.plugins.jrmp.interfaces.EntityProxy.invoke(EntityProxy.java:146)
[ContactBean]
at $Proxy16.getAll(Unknown Source)
[ContactBean] at
com.cpt.contactcenter.server.AgentSessionBean.enumContacts(AgentSessionBean.java:242)
[ContactBean]
at java.lang.reflect.Method.invoke(Native
Method)
[ContactBean] at
org.jboss.ejb.StatefulSessionContainer$ContainerInterceptor.invoke(StatefulSessionContainer.java:570)
[ContactBean]
at
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:144)
[ContactBean]
at
org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invoke(StatefulSessionInstanceInterceptor.java:198)
[ContactBean]
at
org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:133)
[ContactBean]
at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:263)
[ContactBean]
at
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:99)
[ContactBean]
at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
[ContactBean]
at
org.jboss.ejb.StatefulSessionContainer.invoke(StatefulSessionContainer.java:326)
[ContactBean]
at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:163)
[ContactBean]
at java.lang.reflect.Method.invoke(Native
Method)
[ContactBean] at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
[ContactBean]
at
sun.rmi.transport.Transport$1.run(Transport.java:142)
[ContactBean]
at java.security.AccessController.doPrivileged(Native
Method)
[ContactBean] at
sun.rmi.transport.Transport.serviceCall(Transport.java:139)
[ContactBean]
at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:443)
[ContactBean]
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:643)
[ContactBean]
at java.lang.Thread.run(Thread.java:484)
[AgentSession] Exception while
enuming contacts javax.transaction.TransactionRolledbackException: null;
nested exception is:
javax.ejb.EJBException