0 Replies Latest reply on Mar 24, 2004 5:30 AM by jaksa

    Passive Creation of Entity Beans

      Hi.
      I'm trying to extend JBoss with Entity Bean clustering. Currently I'm writing the support for passive creation of Entity Beans. By passive creation I mean creating an Entity Bean without invoking its ejbCreate method. I just have the ID of the bean that has to be created and I don't care about the state. The idea is to use it like this:


      ctx = createEntityBean(id);
      setEntityBeanState(ctx, state);

      This would be useful if, for example, a bean is created on another node and I want to create a local copy as well. My first implementation was to use the InstanceCache:


      EnterpriseContext createEntityBean(Object id) {
      EnterpriseContext ctx = cache.get();
      ctx.setId(id);
      cache.insert(ctx);
      return ctx;
      }

      but the PersistenceStore complained about inserting a bean instance with an invalid primary key. So I added the code to set the primary key as well, but then I got the EntityBridgeInvocationHanler complaining that EJB home methods are not allowed to access CMP or CMR fields:

      ...
      Caused by: javax.ejb.EJBException: EJB home methods are not allowed to access CMP or CMR fields: methodName=setName
      at org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invoke(EntityBridgeInvocationHandler.java:114)
      at org.jboss.proxy.compiler.Runtime.invoke(Runtime.java:59)
      at cmtest.ejb.CounterBean$Proxy.setName()
      ... 35 more

      Is there another way to do this or should I pursue this approach?
      Thanks,

      Jaksa

      PS: The code above is just for explaining the problem, I didn't attach the real code because it's too big and spans over a lot of classes.