4 Replies Latest reply on Aug 21, 2003 4:35 AM by krogers

    Exception when accessing CMR field

    parul Newbie

      Hello,
      I am using jboss with embedded tomcat. I get an error when i am accessing a cmr field using accessor method. I have 2 beans CategoryBean
      and SubCategoryBean with one to many relationship. each category has more than one subcategories so i have a cmr field subCategories in CategoryBean and a cmr field category in SubCategoryBean. I also have
      addSubCategory(LocalSubCategory subCategory) method in CategoryBean
      following is the body of Method
      public void addSubCategory(LocalSubCategory subCategory) { try { Collection subCategories = getSubCategories(); subCategories.add(subCategory); }catch(Exception ex) { ex.printStackTrace(); throw new EJBException(ex); } }


      I am getting error at the first line in try block
      followin is the XML discriptor and stack trace i am getting


      <display-name>CategoryEJB</display-name>
      <ejb-name>CategoryEJB</ejb-name>
      <local-home>com.gmi.mportal.LocalCategoryHome</local-home>
      com.gmi.mportal.LocalCategory
      <ejb-class>com.gmi.mportal.CategoryBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Category</abstract-schema-name>
      <cmp-field>
      <field-name>categoryId</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>category</field-name>
      </cmp-field>
      <primkey-field>categoryId</primkey-field>
      <security-identity>

      <use-caller-identity></use-caller-identity>
      </security-identity>


      <query-method>
      <method-name>findAllCategories</method-name>
      <method-params/>
      </query-method>
      <ejb-ql>select object(c) from Category c </ejb-ql>



      <query-method>
      <method-name>findByCategoryName</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>select object(c) from Category c where c.category = ?1</ejb-ql>


      <!-- CategoryEJB End -->
      <!-- SubCategoryEJB Begin -->

      <display-name>SubCategoryEJB</display-name>
      <ejb-name>SubCategoryEJB</ejb-name>
      <local-home>com.gmi.mportal.LocalSubCategoryHome</local-home>
      com.gmi.mportal.LocalSubCategory
      <ejb-class>com.gmi.mportal.SubCategoryBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>SubCategory</abstract-schema-name>
      <cmp-field>
      <field-name>subCategoryId</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>subCategoryName</field-name>
      </cmp-field>
      <primkey-field>subCategoryId</primkey-field>
      <security-identity>

      <use-caller-identity></use-caller-identity>
      </security-identity>

      <query-method>
      <method-name>findBySubCategoryName</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>
      select object(s) from SubCategory s, Category c where c.category = ?1 and s.subCategoryName=?2
      </ejb-ql>


      <!-- SubCategoryEJB End -->
      <!-- Relationship Begin -->

      Category-SubCategory
      <ejb-relation>
      Category to SubCategory
      <ejb-relation-name>CategorytToSubCategory</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>CategoryEJB</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>CategoryEJB</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name> subCategories </cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>SubCategoryEJB</ejb-relationship-role-name>
      Many
      <cascade-delete />
      <relationship-role-source>
      <ejb-name>SubCategoryEJB</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>category</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>

      <ejb-relation>
      SubCategory to Product
      <ejb-relation-name>SubCategorytToProduct</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>SubCategoryEJB</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>SubCategoryEJB</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>products</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>ProductEJB</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>ProductEJB</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>subCategory</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>

      <ejb-relation>
      Vendor To Product
      <ejb-relation-name>VendorToProduct</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>VendorEJB</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>VendorEJB</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>products</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>ProductEJB</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>ProductEJB</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>vendor</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>



      Stack Trace

      2003-07-14 14:22:39,335 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException, causedBy:
      javax.ejb.EJBException: Method is not a known CMP field accessor, CMR field accessor, or ejbSelect method: methodName=getSubCategories
      at org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invoke(EntityBridgeInvocationHandler.java:111)
      at org.jboss.proxy.compiler.Runtime.invoke(Runtime.java:59)
      at com.gmi.mportal.CategoryBean$Proxy.getSubCategories(
      at com.gmi.mportal.CategoryBean.addSubCategory(CategoryBean.java:20)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1194)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:95)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:303)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
      at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:90)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:174)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:107)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:69)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:237)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:98)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:208)
      at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:493)
      at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invoke(BaseLocalContainerInvoker.java:301)
      at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
      at $Proxy65.addSubCategory(Unknown Source)
      at com.gmi.mportal.AdminSessionBean.createSubCategory(AdminSessionBean.java:117)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:660)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:237)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:98)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:208)
      at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
      at org.jboss.ejb.Container.invoke(Container.java:738)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:383)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:536)
      2003-07-14 14:22:39,345 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackException, causedBy:
      javax.ejb.EJBException: Method is not a known CMP field accessor, CMR field accessor, or ejbSelect method: methodName=getSubCategories
      at org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invoke(EntityBridgeInvocationHandler.java:111)
      at org.jboss.proxy.compiler.Runtime.invoke(Runtime.java:59)
      at com.gmi.mportal.CategoryBean$Proxy.getSubCategories(
      at com.gmi.mportal.CategoryBean.addSubCategory(CategoryBean.java:20)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1194)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:95)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:303)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
      at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:90)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:174)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:107)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:69)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:237)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:98)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:208)
      at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:493)
      at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invoke(BaseLocalContainerInvoker.java:301)
      at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
      at $Proxy65.addSubCategory(Unknown Source)
      at com.gmi.mportal.AdminSessionBean.createSubCategory(AdminSessionBean.java:117)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:660)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:237)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:98)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:208)
      at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
      at org.jboss.ejb.Container.invoke(Container.java:738)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:383)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:536)