Hi,

  I have problems with the following scenario:

I have five CMP EntityBeans called A, B, C, D. A and B are in meta.jar, C and D are in 
ext.jar.

D references C, B and A ( A and B are external references).
C references B (B is a external reference).
B references A.

If bean D is created, the referenced beans were also created. If the
beans were NOT passivated and the bean D is removed all referenced
beans were removed. But when the beans were passivated following
happens:

- Getting a reference to bean D
- Calling remove on bean D
- now bean D is activated
- in ejbActivate() from bean D getting a reference to bean C, B and A.
- in ejbRemove() from bean D now remove on bean C is called
- now bean C is activated
- in ejbActivate() from bean C gettin a reference to bean B
- in ejbRemove() from bean C now remove on bean B is called
- now bean B is activated
- in ejbActivate() from bean B all things crashes. I have only created
an instance from APK that results in a NPE. I have tried to get the
PrimaryKey from bean B with getPrimaryKey that results in a
ClassCastException cause auf a NPE.

Am I out of spec or is there something wrong ?

For clarify:

bean D = VerstorbenerBean
bean C = EhegatteBean
bean B = PersonBean
bean A = AdresseBean

Here the ejbActivate() from bean B:

---- snip ----
  public void ejbActivate() throws RemoteException {
    super.ejbActivate();
    AdresseHome adresseHome;
    PrintWriter out=null;

    try {
      out = new PrintWriter(new FileWriter("//d:/temp/ejb.log", true));
      
      out.println("ectx: " + ectx);
      out.println("PersonPK: " + PersonPK.class);
      out.println("AdressePK: " + AdressePK.class);

      out.println("Get Primary Key");
      PersonPK pkey = (PersonPK)ectx.getPrimaryKey();
      out.println("Mandant: " + pkey.Mandant);
      out.println("Nummer: " + pkey.Nummer);
      out.println("Typ: " + pkey.Type);
  
      out.println("create AdressePK");
      AdressePK akey = new AdressePK();
      out.println("AdressePK created: " + akey);
      

      try {
        out.println("Versuche Adresse <" + ((PersonPK)ectx.getPrimaryKey()).Mandant +
            "> <" + ((PersonPK)ectx.getPrimaryKey()).Nummer + "> <" +
            ((PersonPK)ectx.getPrimaryKey()).Type +"> zu finden.");
        akey.Mandant = ((PersonPK)ectx.getPrimaryKey()).Mandant;
        akey.Nummer = ((PersonPK)ectx.getPrimaryKey()).Nummer;
        akey.Type = ((PersonPK)ectx.getPrimaryKey()).Type;
        adresseHome = getAdresseHome();
        adresse = adresseHome.findByPrimaryKey(akey);
      } catch(Exception ex) {
        System.out.println("Adresse nicht gefunden.<"+akey.Mandant+"> 
<"+akey.Nummer+"> <"+akey.Type+">");
        throw ex;
      }
    } catch(NamingException nex) {
      System.out.println("Naming: " + nex);
      throw new RemoteException("Naming: " + nex.getMessage());
    } catch(FinderException fex) {
      System.out.println("Finder: " + fex);
      throw new RemoteException("Finder: " + fex.getMessage());
    } catch(Exception ex) {
      System.out.println("Other: " + ex);
      ex.printStackTrace(out);
      throw new RemoteException("Other: " + ex.getMessage());
    } finally {
      out.flush();
      out.close();
    }
  }
---- snap ----

And here the log that I gave out in ejbActivate in a separate file to
avoid sync problems withe the logger:

---- snip ----
ectx: org.jboss.ejb.EntityEnterpriseContext$EntityContextImpl@210fc
PersonPK: class de.oblgmbh.wb.meta.interfaces.PersonPK
AdressePK: class de.oblgmbh.wb.meta.interfaces.AdressePK
Get Primary Key
java.lang.ClassCastException: de.oblgmbh.wb.meta.interfaces.PersonPK
        at de.oblgmbh.wb.meta.ejb.PersonBean.ejbActivate(PersonBean.java:108)
        at java.lang.reflect.Method.invoke(Native Method)
        at 
org.jboss.ejb.plugins.CMPPersistenceManager.activateEntity(CMPPersistenceManager.java:247)
        at 
org.jboss.ejb.plugins.EntityInstanceCache.activate(EntityInstanceCache.java:103)
        at 
org.jboss.ejb.plugins.AbstractInstanceCache.get(AbstractInstanceCache.java:164)
        at org.jboss.ejb.plugins.EntityInstanceCache.get(EntityInstanceCache.java:58)
        at 
org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:127)
        at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:133)
        at 
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:263)
        at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:99)
        at 
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:144)
        at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
        at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:323)
        at 
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:441)
        at 
org.jboss.ejb.plugins.jrmp.interfaces.EntityProxy.invoke(EntityProxy.java:146)
        at $Proxy80.remove(Unknown Source)
        at de.oblgmbh.jbvs.meta.ejb.EhegatteBean.ejbRemove(EhegatteBean.java:94)
        at de.oblgmbh.jbvs.meta.ejb.EhegatteCMP.ejbRemove(EhegatteCMP.java:448)
        at java.lang.reflect.Method.invoke(Native Method)
        at 
org.jboss.ejb.plugins.CMPPersistenceManager.removeEntity(CMPPersistenceManager.java:379)
        at org.jboss.ejb.EntityContainer.remove(EntityContainer.java:331)
        at java.lang.reflect.Method.invoke(Native Method)
        at 
org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:692)
        at 
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:208)
        at 
org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:187)
        at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:133)
        at 
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:263)
        at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:99)
        at 
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:144)
        at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
        at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:323)
        at 
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:441)
        at 
org.jboss.ejb.plugins.jrmp.interfaces.EntityProxy.invoke(EntityProxy.java:146)
        at $Proxy75.remove(Unknown Source)
        at 
de.oblgmbh.jbvs.meta.ejb.VerstorbenerBean.ejbRemove(VerstorbenerBean.java:103)
        at de.oblgmbh.jbvs.meta.ejb.VerstorbenerCMP.ejbRemove(VerstorbenerCMP.java:470)
        at java.lang.reflect.Method.invoke(Native Method)
        at 
org.jboss.ejb.plugins.CMPPersistenceManager.removeEntity(CMPPersistenceManager.java:379)
        at org.jboss.ejb.EntityContainer.remove(EntityContainer.java:331)
        at java.lang.reflect.Method.invoke(Native Method)
        at 
org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:692)
        at 
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:208)
        at 
org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:187)
        at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:133)
        at 
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:263)
        at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:99)
        at 
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:144)
        at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
        at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:323)
        at 
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:367)
        at java.lang.reflect.Method.invoke(Native Method)
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
        at sun.rmi.transport.Transport$1.run(Transport.java:142)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:139)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:443)
        at 
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:643)
        at java.lang.Thread.run(Thread.java:484)
---- snap ----

so long


Ingo Bruell                                 

---
<[EMAIL PROTECTED]>
<ICQ# 40377720>
Oldenburg    PGP-Fingerprint: 9DD0 1776 DF4D 5B16  A532 C2A1 4701 EEA2
Germany      PGP-Public-Key available at pgpkeys.mit.edu



Reply via email to