aspose file tools*
The moose likes BEA/Weblogic and the fly likes ejbc error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "ejbc error" Watch "ejbc error" New topic
Author

ejbc error

Maximilian Trenks
Ranch Hand

Joined: Jul 22, 2002
Posts: 104
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) {
System.out.println(
"Unable to insert new persion with ID "+id+" and name "+name);
}
return id;
}catch (SQLException e) {
e.printStackTrace();}
try {
ps.close();
con.close();
con=null;
} catch (Exception e) {}
return "Unable to insert new persion with ID "+id+" and name "+name;
}


Student of Business Informatics<br />Kepler University Linz, Austria
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
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.
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
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:
Maximilian Trenks
Ranch Hand

Joined: Jul 22, 2002
Posts: 104
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).
Thanx,
Max
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ejbc error