Forums Register Login
ejbc error
Hi, I am trying to build a BMP entity bean with local and remote interfaces.
When using ejbc i have the following error:
ERROR: Error from ejbc:
In EJB dipl.PersonBMPBean, the throws clause for ejbCreate method ejbCreate(java.lang.String,java.lang.String,java.lang.String,java.
lang.Integer,java.lang.Integer) contains exceptions which are NOT in the throws clause of the corresponding local home interface method.
ERROR: ejbc found errors
I don't know what to do with this error. The only exception I don't have in method signature is the RemoteException, which doesn't apply to my LOCAL home interface.
Here the method:
- The localhome interface:
public PersonBMPLocal create(String id, String name,String birthday, Integer size, Integer height)
throws CreateException;

- The bean class:
public String ejbCreate(String id, String name,String birthday, Integer size, Integer height) throws RemoteException, CreateException {
PreparedStatement ps = null;
try {
con = getConnection();
ps = con.prepareStatement(
"insert into persons values (?,?,?,?,?)");
ps.setString(1, id);
ps.setString(2, name);
ps.setString(3, birthday);
ps.setInt(4, size.intValue());
ps.setInt(5, height.intValue());
if (ps.executeUpdate() != 1) {
"Unable to insert new persion with ID "+id+" and name "+name);
return id;
}catch (SQLException e) {
try {
} catch (Exception e) {}
return "Unable to insert new persion with ID "+id+" and name "+name;
Your bean implementation class should not declare that it throws a RemoteException. Nor should it ever explicitly throw a RemoteException. Remove that and you should be golden.
BTW, you should not be returning error messages in your classes. The proper way to handle errors in Java is to throw an exception. In this particular example, you should be throwing a CreateException, otherwise the Container and Client will assume that the Entity was successfully created.
Therfore instead of:

Should be something like:
OK, but then it seems that I can't deploy a BMP Bean with local and remote interfaces like with CMP. Because now I get the following ejbc error:
In EJB PersonBMPBean, method ejbCreate(java.lang.String,java.lang.String,java.lang.String,java.lang.Integer,java.lang.Integer) on th
e home interface does not throw java.rmi.RemoteException. This is a required exception.

And what's up with that method in this error ?
In EJB PersonBMPBean, the home method ejbCreate(java.lang.String,java.lang.String,java.lang.String,java.lang.Integer,java.lang.Integ
er) was defined in the home interface, but a matching ejbHomeEjbCreate(java.lang.String,java.lang.String,java.lang.String,java.lang.Integer,
java.lang.Integer) method was not found on the bean class.
ERROR: ejbc found errors

My goal is to deply a BMP Bean that can be used by a SessionFacade (Local Interfaces) and for comparing puropse also with remote (and remote home) interfaces. Can I accomplish this with just one bean class implementation (I mentioned before that I did with CMP).
The bean implementation should never declare that it may throw a RemoteException, neither should the local interface. However, the remote interface should declare that it throws a RemoteException.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

This thread has been viewed 802 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jan 19, 2018 20:45:41.