-
1. Re: How does a container wrap EJBException?
mschoning Feb 26, 2003 12:34 PM (in response to zgapp)Hi.
My guess is that you have different class paths for your client and for your ejb container. So the client is probably picking up another version (from another jar) of the EJBException class. You can create your own exception class and you will probably be able to throw that exception as they both will have to pick up the same version of the new Exception class. To correct your problem with the EJBException, go hunting! Try to find all the jars that have this class in them and make sure that you load the same jar for the client and the container.
- good, luck Michael -
2. Re: How does a container wrap EJBException?
bman917 Feb 26, 2003 11:04 PM (in response to zgapp)I think EJBExceptions are wrapped in a RemoteException. Any way the properway of handling your SQL exception is the throw the exception in your mehtod. For example:
public void youMehtod(...) throws SQLException
{
//do your SQL thing
}
In this way you can directly catch the SQLException instead of trying to wrap it in some weird EJBException which we don't know very well. -
3. Re: How does a container wrap EJBException?
bman917 Feb 26, 2003 11:06 PM (in response to zgapp)I think EJBExceptions are wrapped in a RemoteException. Any way the properway of handling your SQL exception is the throw the exception in your mehtod. For example:
public void youMehtod(...) throws SQLException
{
//do your SQL thing
}
In this way you can directly catch the SQLException instead of trying to wrap it in some weird EJBException which we don't know very well. -
4. Re: How does a container wrap EJBException?
bman917 Feb 26, 2003 11:09 PM (in response to zgapp)I think EJBExceptions are wrapped in a RemoteException. Any way the properway of handling your SQL exception is the throw the exception in your mehtod. For example:
public void yourMehtod(...) throws SQLException
{
//do your SQL thing
}
In this way you can directly catch the SQLException instead of trying to wrap it in some weird EJBException which we don't know very well. -
5. Re: How does a container wrap EJBException?
bman917 Feb 26, 2003 11:18 PM (in response to zgapp)I don't think the container wraps it all. Any way, the proper way of handling your SQL exception is to throw the exception in your method. For example:
public void yourMehtod(...) throws SQLException
{
//do your SQL thing
}
In this way you can directly catch the SQLException instead of trying to wrap it in some weird EJBException which we don't know very well. -
6. Re: How does a container wrap EJBException?
bman917 Feb 26, 2003 11:20 PM (in response to zgapp)I don't think the container wraps it all. Any way, the proper way of handling your SQL exception is to throw the exception in your method. For example:
public void yourMehtod(...) throws SQLException
{
//do your SQL thing
}
In this way you can directly catch the SQLException instead of trying to wrap it in some weird EJBException which we don't know very well. -
7. Re: How does a container wrap EJBException?
petertje Feb 28, 2003 6:06 AM (in response to zgapp)I totally disagree: that (the last posts i mean) is not the proper way of handling an SQLException.
An SQLException in your bean means there is something wrong with your system. Either your code is sending incorrect SQL statements, or the database connection is lost or something like that. That is what we call a system exception, not an application exception. Proper handling of a system exception is indeed to throw an EJBException or a subclass. The EJB container is mandated (by the spec) to log these exceptions. At the client side, this is translated to a RemoteException indeed, and that is exactly what you want: it indicates that something is going wrong in the server at system level. Returning SQLExceptions to the client is considered bad style; the client shouldn't have to know anything about sql nor about it's exceptions.
Peter.