0 Replies Latest reply on Jan 27, 2005 12:23 PM by louis gueye

    Problem deploying CMP, relations not found in ejb-jar.xml

    louis gueye Newbie

      Hi everybody.

      I'm trying to deploy 2 CMP (Author and Story) in a jboss-4.0.0 container on windows XP.
      The 2 CMP are related by a java.lang.String field (simplest form).

      I get this error :
      org.jboss.deployment.DeploymentException: Configuration found in jbosscmp-jdbc.xml for relation Author-Story but relation is not a jbosscmp-jdbc-managed relation in ejb-jar.xml

      I looked at the code and It seems to mean that a relationship is found in jbosscmp-jdbc.xml (<ejb-relation-name>Author-Story</ejb-relation-name>) but not in ejb-jar.xml. But this relation is in both files :(. I dont know what to do, maybe a parser issue but ...


      my ejb-jar.xml :

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
      
      <ejb-jar >
      
       <description>[CDATA[No Description.]]</description>
       <display-name>j2eetutorial CMP Entity Beans</display-name>
      
       <enterprise-beans>
      
       <!-- Course -->
       <entity >
       <ejb-name>Course</ejb-name>
      
       <local-home>org.j2eetutorial.ejb.cmp.CourseLocalHome</local-home>
       <local>org.j2eetutorial.ejb.cmp.CourseLocal</local>
       <ejb-class>org.j2eetutorial.ejb.cmp.CourseCMP</ejb-class>
      
       <reentrant>False</reentrant>
       <persistence-type>Container</persistence-type>
       <cmp-version>2.x</cmp-version>
      
       <abstract-schema-name>PoudlardCourse</abstract-schema-name>
      
       <primkey-field>id</primkey-field>
       <prim-key-class>java.lang.String</prim-key-class>
      
       <cmp-field ><field-name>id</field-name></cmp-field>
       <cmp-field ><field-name>teacher</field-name></cmp-field>
       </entity>
      
       <!-- Author -->
       <entity>
       <display-name>Author Entity Bean</display-name>
       <ejb-name>Author</ejb-name>
      
       <local-home>org.j2eetutorial.ejb.cmp.AuthorLocalHome</local-home>
       <local>org.j2eetutorial.ejb.cmp.AuthorLocal</local>
       <ejb-class>org.j2eetutorial.ejb.cmp.AuthorBean</ejb-class>
      
       <reentrant>False</reentrant>
       <persistence-type>Container</persistence-type>
       <cmp-version>2.x</cmp-version>
      
       <abstract-schema-name>author</abstract-schema-name>
      
       <primkey-field>username</primkey-field>
       <prim-key-class>java.lang.String</prim-key-class>
      
       <cmp-field><field-name>username</field-name></cmp-field>
       <cmp-field><field-name>password</field-name></cmp-field>
       <cmp-field><field-name>name</field-name></cmp-field>
       </entity>
      
       <!-- Story -->
       <entity>
       <display-name>Story Entity Bean</display-name>
       <ejb-name>Story</ejb-name>
      
       <local-home>org.j2eetutorial.ejb.cmp.StoryLocalHome</local-home>
       <local>org.j2eetutorial.ejb.cmp.StoryLocal</local>
       <ejb-class>org.j2eetutorial.ejb.cmp.StoryBean</ejb-class>
      
       <reentrant>False</reentrant>
       <persistence-type>Container</persistence-type>
       <cmp-version>2.x</cmp-version>
      
       <abstract-schema-name>story</abstract-schema-name>
      
       <primkey-field>storyId</primkey-field>
       <prim-key-class>java.lang.Integer</prim-key-class>
      
       <cmp-field><field-name>storyId</field-name></cmp-field>
       <cmp-field><field-name>pubDate</field-name></cmp-field>
       <cmp-field><field-name>title</field-name></cmp-field>
       <cmp-field><field-name>text</field-name></cmp-field>
       <cmp-field><field-name>username</field-name></cmp-field>
      
       <query>
       <query-method>
       <method-name>findByUsername</method-name>
       <method-params>
       <method-param>java.lang.String</method-param>
       </method-params>
       </query-method>
       <ejb-ql>[CDATA[
       SELECT OBJECT(s)
       FROM story s
       WHERE s.username = ?1
       ]]</ejb-ql>
       </query>
       </entity>
      
       <relationships>
       <ejb-relation>
       <ejb-relation-name>Author-Story</ejb-relation-name>
       <ejb-relationship-role>
       <ejb-relationship-role-name>author-stories</ejb-relationship-role-name>
      
       <multiplicity>One</multiplicity>
      
       <relationship-role-source>
       <ejb-name>Author</ejb-name>
       </relationship-role-source>
      
       <cmr-field>
       <cmr-field-name>stories</cmr-field-name>
       <cmr-field-type>java.util.Collection</cmr-field-type>
       </cmr-field>
       </ejb-relationship-role>
      
       <ejb-relationship-role>
       <ejb-relationship-role-name>stories-author</ejb-relationship-role-name>
      
       <multiplicity>Many</multiplicity>
       <cascade-delete/>
      
       <relationship-role-source>
       <ejb-name>Story</ejb-name>
       </relationship-role-source>
      
       <cmr-field>
       <cmr-field-name>author</cmr-field-name>
       </cmr-field>
       </ejb-relationship-role>
       </ejb-relation>
       </relationships>
      
       <assembly-descriptor>
       <container-transaction>
       <method>
       <ejb-name>Author</ejb-name>
       <method-name>*</method-name>
       </method>
       <method>
       <ejb-name>Story</ejb-name>
       <method-name>*</method-name>
       </method>
       <trans-attribute>Required</trans-attribute>
       </container-transaction>
       </assembly-descriptor>
      
       </enterprise-beans>
      </ejb-jar>
      




      the jbosscmp-jdbc.xml :
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 4.0//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_4_0.dtd">
      
      <jbosscmp-jdbc>
       <defaults>
       <datasource>java:PoudlardDS</datasource>
       <datasource-mapping>mySQL</datasource-mapping>
       <create-table>false</create-table>
       <remove-table>false</remove-table>
       <pk-constraint>true</pk-constraint>
       <preferred-relation-mapping>foreign-key</preferred-relation-mapping>
       </defaults>
      
       <enterprise-beans>
      
       <!-- Course -->
       <entity>
       <ejb-name>Course</ejb-name>
       <table-name>basic_courses</table-name>
       <cmp-field>
       <field-name>id</field-name>
       <column-name>id</column-name>
       <jdbc-type>VARCHAR</jdbc-type>
       <sql-type>VARCHAR</sql-type>
       </cmp-field>
       <cmp-field>
       <field-name>teacher</field-name>
       <column-name>teacher</column-name>
       <jdbc-type>VARCHAR</jdbc-type>
       <sql-type>VARCHAR</sql-type>
       </cmp-field>
       </entity>
      
       <!-- Author -->
       <entity>
       <ejb-name>Author</ejb-name>
       <table-name>author</table-name>
      
       <cmp-field>
       <field-name>username</field-name>
       <not-null/>
       </cmp-field>
       <cmp-field>
       <field-name>password</field-name>
       <not-null/>
       </cmp-field>
       <cmp-field>
       <field-name>name</field-name>
       </cmp-field>
       </entity>
      
       <!-- Story -->
       <entity>
       <ejb-name>Story</ejb-name>
       <table-name>story</table-name>
      
       <cmp-field>
       <field-name>storyId</field-name>
       <column-name>story_id</column-name>
       <not-null/>
       </cmp-field>
       <cmp-field>
       <field-name>pubDate</field-name>
       <column-name>pub_date</column-name>
       <not-null/>
       </cmp-field>
       <cmp-field>
       <field-name>title</field-name>
       <not-null/>
       </cmp-field>
       <cmp-field>
       <field-name>text</field-name>
       <not-null/>
       </cmp-field>
       <cmp-field>
       <field-name>username</field-name>
       </cmp-field>
       </entity>
      
       </enterprise-beans>
      
      
       <relationships>
       <ejb-relation>
       <ejb-relation-name>Author-Story</ejb-relation-name>
       <foreign-key-mapping/>
      
       <ejb-relationship-role>
       <ejb-relationship-role-name>author-stories</ejb-relationship-role-name>
       <key-fields>
       <key-field>
       <!-- Note: Field in Author. -->
       <field-name>username</field-name>
       <!-- Note: Column in Story table. -->
       <column-name>username</column-name>
       </key-field>
       </key-fields>
       </ejb-relationship-role>
      
       <ejb-relationship-role>
       <ejb-relationship-role-name>stories-author</ejb-relationship-role-name>
       <key-fields/>
       </ejb-relationship-role>
       </ejb-relation>
       </relationships>
      
      </jbosscmp-jdbc>
      


      the server logs :
      2005-01-27 17:51:36,819 ERROR [org.jboss.ejb.EntityContainer] Starting failed jboss.j2ee:jndiName=ejb/j2eetutorial/StoryLocal,service=EJB
      org.jboss.deployment.DeploymentException: Configuration found in jbosscmp-jdbc.xml for relation Author-Story but relation is not a jbosscmp-jdbc-managed relation in ejb-jar.xml
       at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCApplicationMetaData.<init>(JDBCApplicationMetaData.java:465)
       at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCXmlFileLoader.load(JDBCXmlFileLoader.java:75)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadJDBCEntityMetaData(JDBCStoreManager.java:721)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.initStoreManager(JDBCStoreManager.java:409)
       at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:353)
       at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManager.java:157)
       at org.jboss.ejb.EntityContainer.startService(EntityContainer.java:340)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:271)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:221)
       at sun.reflect.GeneratedMethodAccessor81.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:891)
       at $Proxy0.start(Unknown Source)
       at org.jboss.system.ServiceController.start(ServiceController.java:416)
       at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy240.start(Unknown Source)
       at org.jboss.ejb.EjbModule.startService(EjbModule.java:394)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:271)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:221)
       at sun.reflect.GeneratedMethodAccessor81.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:891)
       at $Proxy0.start(Unknown Source)
       at org.jboss.system.ServiceController.start(ServiceController.java:416)
       at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy19.start(Unknown Source)
       at org.jboss.ejb.EJBDeployer.start(EJBDeployer.java:605)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:935)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:746)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:709)
       at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:119)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:131)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy8.deploy(Unknown Source)
       at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:305)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:481)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:215)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)


      Any help would be appreciated, thanx in advance.

      Best regards,

      Louis