hi,
my first many to one
test doesnt work
i get following error when i try to put something in my collection :
java.rmi.ServerException: RemoteException occurred in server
thread; nested exception is: java.rmi.ServerException: RuntimeException; nested exception is:
java.lang.ClassCastException
here is the code from my client it works until it trys to addBloks
code ----------------------------------------------
PaginaHome pagHome;
Pagina pag;
BlokTekstHome blokHome ;
BlokTekst blok;
Context ctx = new InitialContext();
Object home = (PaginaHome) ctx.lookup(PaginaHome.JNDI_NAME);
pagHome = (PaginaHome) PortableRemoteObject.narrow(home, PaginaHome.class);
pag = (Pagina)pagHome.create();
Object home1 = (BlokTekstHome) ctx.lookup(BlokTekstHome.JNDI_NAME);
blokHome = (BlokTekstHome) PortableRemoteObject.narrow(home1, BlokTekstHome.class);
Object[] bloks = new Object[2];
blok = (BlokTekst) blokHome.create();
blok.setTekst("test1");
bloks[0]=blok;
blok = (BlokTekst) blokHome.create();
blok.setTekst("test2");
bloks[1]=blok;
pag.addBlok( bloks);
code-----------------------
this is the pagina class
code----------------------------------
/*
* Created on 25-aug-2004
*
* TODO To change the template for this generated file go to
* Window - Preferences -
Java - Code Style - Code Templates
*/
package sven.ent.ejb;
import java.util.Arrays;
import java.util.Collection;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import sven.ent.interfaces.BlokTekstLocal;
import sven.ent.interfaces.PaginaUtil;
/**
* @author Sven
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
/**
* XDoclet-based CMP entity bean. This class must be declared
* <code>public abstract</code> because the concrete class will
* be implemented by the CMP provider's tooling.<br>
*
* To generate code:
* <br>
* <ul>
* <li> Add Standard
EJB module to XDoclet project properties
* <li> Customize XDoclet configuration
* <li> Run XDoclet
* </ul>
* <br>
* Please see the included XDoclet Overview
* and the XDoclet Reference in the help system for details
*
* @ejb.bean name = "Pagina"
* type = "CMP"
* cmp-version = "2.x"
* display-name = "Pagina"
* description = "Pagina EJB"
* view-type = "both"
* jndi-name = "ejb/PaginaHome"
* local-jndi-name = "ejb/PaginaLocalHome"
*primkey-field = "id"
* @ejb.persistence table-name = "tpagina"
* @jboss.persistence table-name = "tpagina"
* @ejb:util
* generate="physical"
*/
public abstract class Pagina implements EntityBean {
/**
* @return Return the group this user is in.
* @ejb:interface-method view-type="both"
* @ejb:relation
* name="BloksRel"
* role-name="ZijnErBlokken"
* target-role-name="geefPagina"
* target-cascade-delete="yes"
*
*
*/
public abstract Collection getBloks();
/** @ejb:interface-method view-type="both"
*
*/
public abstract void setBloks(Collection bloks);
/**
* @ejb.interface-method view-type = "both"
* @ejb.persistence column-name = "fid"
* @ejb.pk-field
*
* @return
*/
public abstract
String getId();
/**
* @ejb.interface-method view-type = "both"
*
* @param name
*/
public abstract void setId(String id);
/**
* @ejb.interface-method view-type = "both"
*
* @param Bloktekst[]
*/
public void addBlok(Object[] bloks){
setBloks(Arrays.asList((BlokTekstLocal[])bloks));
}
/**
* @ejb:interface-method view-type="both"
* @ejb

ersistent-field
* @ejb.persistence column-name="ftitel"
*/
public abstract String getTitel();
/** @ejb

ersistent-field
* @ejb.interface-method view-type = "both"
* */
public abstract void setTitel(String titel);
/** The EntityContext */
private EntityContext context;
/**
* @throws CreateException Thrown if the instance could not perform
* the function requested by the container because of an system-level error.
*
* @ejb.create-method
*/
public String ejbCreate() throws CreateException {
this.setId(PaginaUtil.generateGUID(this));
return null;
}
/**
* @throws EJBException Thrown if the instance could not perform
* the function requested by the container because of an system-level error.
*/
public void setEntityContext(EntityContext newContext) throws EJBException {
context = newContext;
}
/**
* This method is called with no transaction context.
*
* @throws EJBException Thrown if the instance could not perform
* the function requested by the container because of an system-level error.
*/
public void unsetEntityContext() throws EJBException {
context = null;
}
}
manny thanks for this