Error: org.jboss.deployment.DeploymentException: Both roles of a relation-table mapped relationship must have key fields: ejb-relation-name=school-student


Hi,


I am running jboss-3.2.0RC4 with XDoclet 1.2 Beta 3. See the Error further down.

( The error does NOT occur when I am using jboss-3.0.4 with
XDoclet 1.2 Beta 2 )

As I get no error when using jboss-3.0.4 with XDoclet 1.2 Beta 2, I do not understand why I am getting the error with jboss-3.2.0RC4 with XDoclet 1.2 Beta 3.

Does Anyone know why I might be getting this error ?

I noticed there is a related discussion at:

http://opensource.atlassian.com/projects/xdoclet/secure/ViewIssue.jspa?key=XDT-244&page=comments

but I do not undestand the solution.

I have included my Bean files with the XDoclet tags in the comments further down this page.

Thanks

John Dickerson


ERROR ######

org.jboss.deployment.DeploymentException: Both roles of a relation-table mapped relationship must have key fields: ejb-relation-name=school-student
at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationMetaData.<init>(JDBCRelationMetaData.
java:330)
at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCApplicationMetaData.<init>(JDBCApplicationMet
aData.java:404)
at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCXmlFileLoader.load(JDBCXmlFileLoader.java:75)


at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadJDBCEntityMetaData(JDBCStoreManager.j
ava:743)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.initStoreManager(JDBCStoreManager.java:43
6)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:378)
at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManager.java:170)
at org.jboss.ejb.EntityContainer.startService(EntityContainer.java:339)
at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284
)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:966)
at $Proxy11.start(Unknown Source)
at org.jboss.system.ServiceController.start(ServiceController.java:392)
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.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284
)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
at $Proxy34.start(Unknown Source)
at org.jboss.ejb.EjbModule.startService(EjbModule.java:341)
at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284
)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:966)
at $Proxy11.start(Unknown Source)
at org.jboss.system.ServiceController.start(ServiceController.java:392)
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.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284
)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
at $Proxy21.start(Unknown Source)
at org.jboss.ejb.EJBDeployer.start(EJBDeployer.java:473)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:640)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:613)
at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284
)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
at $Proxy7.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:404)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:545)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeplo
ymentScanner.java:195)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploym
entScanner.java:206)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeployme
ntScanner.java:185)



My School Bean looks like: ###########################

package com.jes.cmrproj.ejb.entity.school.ejb;

import java.util.Collection;
import java.util.Iterator;
import java.util.Date;
import java.util.ArrayList;

import javax.ejb.CreateException;
import javax.ejb.RemoveException;
import javax.ejb.EntityBean;

import javax.naming.NamingException;

import com.jes.util.ejb.entity.BaseEntityBean;
import com.jes.cmrproj.ejb.entity.school.model.SchoolValue;
import com.jes.cmrproj.ejb.entity.school.interfaces.SchoolPK;
import com.jes.util.ejb.session.uidgenerator.util.UIDGeneratorUtil;

import com.jes.cmrproj.ejb.entity.student.interfaces.StudentLocal;
import com.jes.cmrproj.ejb.entity.student.util.StudentUtil;
import com.jes.cmrproj.ejb.entity.student.model.StudentValue;
import com.jes.cmrproj.ejb.entity.student.interfaces.StudentPK;

import com.jes.cmrproj.ejb.exceptions.student.StudentNotFoundException;

/**
* This is a School Entity Bean.
*
* @author <a href="mailto:[EMAIL PROTECTED]">John Dickerson</a>
*
*
* @ejb.bean
* name="School"
* type="CMP"
* view-type="local"
* local-jndi-name="local/com.jes.cmrproj.ejb.entity.school.ejb.School"
* primary-field="schoolId"
* schema="School"
* cmp-version="2.x"
*
* @ejb.value-object
* name="School"
* extends="com.jes.cmrproj.ejb.entity.school.model.SchoolValueBase"
* match="*"
*
* @ejb.transaction
* type="Required"
*
* @ejb.util
* generate="physical"
*
* @ejb.persistence
* table-name="T_SCHOOL"
*
* @ejb.finder
* signature="Collection findAll()"
* query="SELECT OBJECT(s) FROM School s"
* transaction-type="NotSupported"
* unchecked="true"
*
* @ejb.finder
* signature="Collection findByName( java.lang.String name )"
* query="SELECT OBJECT(s) FROM School AS s WHERE s.name=?1"
* transaction-type="Supports"
*
* @jboss.persistence
* create-table="${jboss.create.table}"
* remove-table="${jboss.remove.table}"
*
*/
public abstract class SchoolBean extends BaseEntityBean implements EntityBean
{
public static final String COUNTER_NAME = "School";


   //==========================================
   // Business methods
   //==========================================

/**
* Adds a Student to the School
*
* @param studentValue Student to add
* @return StudentPK Primary key of student created
* @throws CreateException
*
* @ejb.interface-method
*/
public StudentPK addStudent( StudentValue studentValue ) throws CreateException
{
try
{
StudentLocal studentLocal
= StudentUtil.getLocalHome().create( studentValue );


           this.getStudents().add( studentLocal );
           StudentPK studentPK = ( StudentPK )studentLocal.getPrimaryKey();

           return studentPK;
       }
       catch ( NamingException n )
       {
           throw new CreateException( n.toString(  ) );
       }
   }


/** * Gets all students in a school who have the specified name * * @param studentNameIn Name of student we want to retrieve * @return Collection of SchoolLocal * * @ejb.interface-method */ public Collection getStudent( String studentNameIn ) throws StudentNotFoundException { Collection studentCollection = this.getStudents(); Iterator studentIterator = studentCollection.iterator();

       Collection studentCollectionOut
           = new ArrayList( studentCollection.size() );

while ( studentIterator.hasNext() )
{
StudentLocal studentLocal = ( StudentLocal )studentIterator.next();
String studentName = studentLocal.getStudentValue().getName();


           if ( studentName.equals( studentNameIn ) )
           {
               studentCollectionOut.add( studentLocal );
           }
       }

       if ( studentCollectionOut.size() == 0 )
       {
           throw new StudentNotFoundException
           (
               "Cannot find any students with name, " +
               studentNameIn
           );
       }

       return studentCollectionOut;
   }

   /**
   * Gets StudentValue for primary key
   *
   * @return StudentValue
   *
   * @ejb.interface-method
   */

   public StudentValue getStudentValue( StudentPK studentPK )
       throws StudentNotFoundException
   {
       Collection studentLocalCollection = this.getStudents();
       Iterator studentLocalIterator = studentLocalCollection.iterator();

       while ( studentLocalIterator.hasNext() )
       {
           StudentLocal studentLocal
               = ( StudentLocal )studentLocalIterator.next();

StudentValue studentValue = studentLocal.getStudentValue();

Integer studentIdIn = studentPK.getStudentId();
Integer studentIdOut = studentValue.getPrimaryKey().getStudentId();


           if ( studentIdIn.equals( studentIdOut ) )
           {
               return studentValue;
           }
       }

       throw new StudentNotFoundException
       (
           "Cannot find student with studentID, " +
           studentPK.getStudentId()
       );

}


/** * @return SchoolValue populated with a Map of StudentValue * * @ejb.interface-method */ public SchoolValue getSchoolValuePopulatedWithStudentValue() { SchoolValue schoolValue = this.getSchoolValue();

Collection studentLocalCollection = this.getStudents();

Iterator studentLocalIterator = studentLocalCollection.iterator();

while ( studentLocalIterator.hasNext() )
{
StudentLocal studentLocal = ( StudentLocal )studentLocalIterator.next();
schoolValue.addStudent( studentLocal.getStudentValue() );
}
return schoolValue;
}



/** * * @param studentPK * @throws StudentNotFoundException * @throws RemoveException * * @ejb.interface-method */ public void deleteStudent( StudentPK studentPK ) throws StudentNotFoundException, RemoveException { Collection studentLocalCollection = this.getStudents(); Iterator studentLocalIterator = studentLocalCollection.iterator();

boolean deleted = false;

while ( studentLocalIterator.hasNext() )
{
StudentLocal studentLocal = ( StudentLocal )studentLocalIterator.next();
if ( studentLocal.getPrimaryKey().equals( studentPK ) )
{
studentLocal.remove();
deleted = true;
return;
}
}


       throw new StudentNotFoundException
       (
           "Student not Found with StudentId, " +
           studentPK.getStudentId()
       );
   }

   //==========================================
   // CMP fields
   //==========================================

   /**
    * @ejb.pk-field
    * @ejb.persistence
    *      column-name="schoolId"
    * @ejb.interface-method
    * @ejb.transaction
    *      type="Supports"
    */
   public abstract Integer getSchoolId();

public abstract void setSchoolId( Integer schoolId );

   /**
    * @ejb.persistence
    *      column-name="name"
    *      jdbc-type="VARCHAR"
    *      sql-type="varchar(50)"
    */
   public abstract String getName();

public abstract void setName( String name );

   /**
    * @ejb.interface-method
    */
   public abstract void setSchoolValue( SchoolValue data );


/** * @ejb.interface-method */ public abstract SchoolValue getSchoolValue();


//========================================== // CMR fields //==========================================

   /**
    * Returns a Collection of StudentLocal
    *
    * @return Collection of StudentLocal
    *
    * @ejb.interface-method
    * @ejb.relation
    *      name="school-student"
    *      role-name="school-has-students"
    *      target-ejb="Student"
    *      target-role-name="student-belongs_to-school"
    *      target-cascade-delete="yes"
    *
    * @jboss.target-relation
    *      fk-column="school_fk"
    *      related-pk-field="schoolId"
    *      fk-contraint="true"
    *
    */
   public abstract Collection getStudents();

public abstract void setStudents( Collection students );



   //==========================================
   // EJB callbacks
   //==========================================

/**
* @ejb.create-method
*
*/
public SchoolPK ejbCreate( SchoolValue schoolValue ) throws CreateException
{
int uid = 0;


try
{
uid = UIDGeneratorUtil.getLocalHome().create().getUniqueId( COUNTER_NAME );
}
catch ( NamingException n )
{
throw new CreateException( "Unable to generate the schoolId. Error="
+ n.toString( ) );
}


Integer uidInteger = new Integer( uid );

       setSchoolId( uidInteger );
       setSchoolValue( schoolValue );
       setCreationDate( new Date() );

       return new SchoolPK( uidInteger );
   }


public void ejbPostCreate() throws CreateException {} }


The StudentBean looks like : ##############################

package com.jes.cmrproj.ejb.entity.student.ejb;

import java.util.Collection;
import java.util.Date;

import javax.ejb.CreateException;
import javax.ejb.EntityBean;

import javax.naming.NamingException;

import com.jes.util.ejb.entity.BaseEntityBean;
import com.jes.cmrproj.ejb.entity.student.model.StudentValue;
import com.jes.cmrproj.ejb.entity.student.interfaces.StudentPK;

import com.jes.cmrproj.ejb.entity.school.interfaces.SchoolLocal;

import com.jes.util.ejb.session.uidgenerator.util.UIDGeneratorUtil;

/**
* This is a Student Entity Bean.
*
* @author <a href="mailto:[EMAIL PROTECTED]">John Dickerson</a>
*
@ejb.bean
* name="Student"
* type="CMP"
* view-type="local"
* local-jndi-name="local/com.jes.cmrproj.ejb.entity.student.ejb.Student"
* primary-field="studentId"
* schema="Student"
* cmp-version="2.x"
*
* @ejb.value-object
* name="Student"
* match="*"
*
* @ejb.transaction
* type="Required"
*
* @ejb.util
* generate="physical"
*
* @ejb.persistence
* table-name="T_STUDENT"
*
* @ejb.finder
* signature="Collection findAll()"
* query="SELECT OBJECT(s) FROM Student s"
* transaction-type="NotSupported"
* unchecked="true"
*
* @ejb.finder
* signature="Collection findByName( java.lang.String studentName )"
* query="SELECT OBJECT(s) FROM Student AS s WHERE s.name=?1"
* transaction-type="Supports"
*
* @jboss.persistence
* create-table="${jboss.create.table}"
* remove-table="${jboss.remove.table}"
*/
public abstract class StudentBean extends BaseEntityBean implements EntityBean
{
public static final String COUNTER_NAME = "Student";


   //==========================================
   // CMP fields
   //==========================================

   /**
    * @ejb.pk-field
    * @ejb.persistence
    *      column-name="studentId"
    * @ejb.interface-method
    * @ejb.transaction
    *      type="Supports"
    */
   public abstract Integer getStudentId();

public abstract void setStudentId( Integer studentId );

   /**
    * @ejb.persistence
    *      column-name="name"
    *      jdbc-type="VARCHAR"
    *      sql-type="varchar(50)"
    */
   public abstract String getName();

public abstract void setName( String name );

   /**
    * @ejb.interface-method
    */
   public abstract void setStudentValue( StudentValue data );

   /**
    * @ejb.interface-method
    */
   public abstract StudentValue getStudentValue();


//========================================== // CMR fields //==========================================

//public abstract SchoolLocal getSchool();

//public abstract void setSchool( School );

   //==========================================
   // EJB callbacks
   //==========================================

/**
* @ejb.create-method
*/
public StudentPK ejbCreate( StudentValue studentValue ) throws CreateException
{
int uid = 0;


try
{
uid = UIDGeneratorUtil.getLocalHome().create().getUniqueId( COUNTER_NAME );
}
catch ( NamingException n )
{
throw new CreateException( "Unable to generate the studentId. Error="
+ n.toString( ) );
}


Integer studentIdInteger = new Integer( uid );

       setStudentId( studentIdInteger );
       setStudentValue( studentValue );
       setCreationDate( new Date() );

       return new StudentPK( studentIdInteger );
   }

   public void ejbPostCreate() throws CreateException {}
}


_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail




-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb: Dedicated Hosting for just $79/mo with 500 GB of bandwidth! No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to