1 Reply Latest reply on Mar 5, 2002 11:54 AM by dsundstrom

    Error thrown by CMR fields

    mpetteys


      I have a recent copy of JBOSS 3.0 from CVS this weekend.

      I have a bean with two relationships.. The first one is one-to-one, bidirectional.. The second one is one-to-one uni-directional. In the ejbPostCreate function, I am setting both of the relationships but there is an error being generated that says I cannot set the relationship in ejbCreate. It appears that the second relationship's "data" isn't being notified that the create method is complete. Let me know if this is not enough information..

      XDOCLET DECLARATIONS FOR THE RELATIONSHIPS..

      /**
      * @ejb:interface-method view-type="local"
      * @ejb:relation name="SCANCONFIG-ENABLEDFAMILIES"
      * role-name="enabledfamily-belongsto-scanconfig"
      * cascade-delete="yes"
      * @jboss:relation fk-constraint="yes"
      * related-pk-field="id"
      * fk-column="scanconfig_id"
      */
      public abstract ScanConfigLocal getScanConfig();

      /**
      * @ejb:interface-method view-type="local"
      * @ejb:relation name="ENABLEDFAMILY-FAMILY"
      * role-name="enabledfamily-has-family"
      * cascade-delete="no"
      * target-ejb="NessusPluginFamily"
      * target-role-name="family-belong-enabledfamily"
      * target-cascade-delete="yes"
      * target-multiple="no"
      * @jboss:relation fk-constraint="yes"
      * related-pk-field="id"
      * fk-column="family_id"
      */
      public abstract NessusPluginFamilyLocal getPluginFamily();

      HERE IS THE CREATE METHOD..

      /**
      * @ejb:create-method
      */
      public String ejbCreate(ScanConfigLocal o, NessusPluginFamilyLocal o2) throws CreateException {
      this.setId(EJBUtils.generateUID());
      return null;
      }
      public void ejbPostCreate(ScanConfigLocal o, NessusPluginFamilyLocal o2) throws CreateException {
      this.setScanConfig(o);
      this.setPluginFamily(o2); // LINE 92!!!!
      }

      HERE IS THE ERROR MESSAGE..

      2002-03-04 22:50:42,550 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackException, causedBy:
      java.lang.IllegalStateException: A CMR field cannot be set or added to a relationship in ejbCreate; this should be done in the ejbPostCreate method instead [EJB 2.0 Spec. 10.5.2].
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.addRelation(JDBCCMRFieldBridge.java:758)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:146)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:300)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:189)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:108)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:96)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:167)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:61)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166)
      at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:474)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.invokeAddRelation(JDBCCMRFieldBridge.java:691)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.createRelationLinks(JDBCCMRFieldBridge.java:618)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.setInstanceValue(JDBCCMRFieldBridge.java:582)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.setValue(JDBCCMRFieldBridge.java:520)
      at org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invoke(EntityBridgeInvocationHandler.java:125)
      at org.jboss.proxy.compiler.ProxyCompiler$Runtime.invoke(ProxyCompiler.java:89)
      at securestate.nessus.ejb.scanconfig.EnabledFamilyCMP$Proxy.setPluginFamily(Unknown Source)
      at securestate.nessus.ejb.scanconfig.EnabledFamilyBean.ejbPostCreate(EnabledFamilyBean.java:92)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:256)
      at org.jboss.ejb.EntityContainer.createLocalHome(EntityContainer.java:560)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1050)
      at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:73)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:222)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:136)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:80)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:98)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:167)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:52)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:102)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:109)
      at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:468)
      at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invokeHome(BaseLocalContainerInvoker.java:244)
      at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker$HomeProxy.invoke(BaseLocalContainerInvoker.java:369)
      at $Proxy108.create(Unknown Source)
      at securestate.nessus.ejb.ConfigManagerBean.setEnabledCategories(ConfigManagerBean.java:321)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:642)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:96)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:167)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:61)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166)
      at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:308)
      at org.jboss.ejb.Container.invoke(Container.java:668)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1555)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:363)
      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:152)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:148)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:465)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:706)
      at java.lang.Thread.run(Thread.java:484)