• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

ejbc error

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;
}
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Let's get him boys! We'll make him read this tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic