hi everybody!
during my tests of jboss I encountered some exceptions which I couldn't
grok first,
so I added some errormessages which seem more meaningful to me to
org.jboss.ejb.plugins.BMPPersistenceManager, maybe somebody is
interested...
gerolf.
- is there a EJB-verifier out there which tests if a ejbean has all the
needed methods? (in my case the error was a wrong ejbPostCreate...)
public void createEntity(Method m, Object[] args,
EntityEnterpriseContext ctx)
throws RemoteException, CreateException
{
// Get methods
try
{
Method createMethod,postCreateMethod;
try {
createMethod = con.getBeanClass().getMethod("ejbCreate",
m.getParameterTypes());
} catch (NoSuchMethodException nsme) {
throw new CreateException("corresponding ejbCreate not found " +
ArrayToString(m.getParameterTypes()) + nsme); }
try {
postCreateMethod =
con.getBeanClass().getMethod("ejbPostCreate", m.getParameterTypes());
} catch (NoSuchMethodException nsme) { throw new
CreateException("corresponding ejbPostCreate not found " +
ArrayToString(m.getParameterTypes()) + nsme); }
Object id;
// Call ejbCreate
try {
id = createMethod.invoke(ctx.getInstance(), args);
} catch (InvocationTargetException ite) {
throw new CreateException("Create failed(could not call
ejbCreate):"+ite);
}
ctx.setId(id);
// Lock instance in cache
con.getInstanceCache().insert(ctx);
// Create EJBObject
ctx.setEJBObject(con.getContainerInvoker().getEntityEJBObject(id));
try {
postCreateMethod.invoke(ctx.getInstance(), args);
} catch (InvocationTargetException ite) {
throw new CreateException("Create failed(could not call
ejbPostCreate):"+ite);
}
}
//catch (InvocationTargetException e)
// {
// throw new CreateException("Create failed:"+e);
// }
// catch (NoSuchMethodException e)
// {
// throw new CreateException("Create methods not found:"+e);
// }
catch (IllegalAccessException e)
{
throw new CreateException("Could not create entity:"+e);
}
}
private String ArrayToString(Object []a) {
String r = new String();
for(int i=0;i<a.length;i++) r = r + ", " + a[i];
return r;
}