Re: [JBoss-user] exception handling advice
I don't think it would be a good idea to catch FinderExceptions and CreateExceptions and then re-throw EJBExceptions. The client would be just as confused as to what to do with any of them. Instead, say you are creating a customer and you get a CreateException. It might make sense in this case to throw a custom exception such as CouldNotCreateCustomerException. Then your application knows exactly what it was that went wrong and can at least translate that into more human consumable english like, "The customer could not be created." This translations from ejb.javax.* exceptions to custom exceptions can take place inside of a business delegate. -M@ On Thursday, September 11, 2003, at 02:21 AM, Brian McSweeney wrote: Thanks for the response Mathew, I'll look into the business delegate pattern, however I'm still confused as to what I should do with finder and Create exceptions from the session facades. Should these be: a) Thrown on to the clients b) caught and EJBExceptions thrown on if b) is true, how can the clients handle EJBExceptions? These are runtime exceptions no? Any advice for this issue would be really helpful, because I'm still very confused!! Thanks, Brian -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Matthew Hixson Sent: 10 September 2003 17:55 To: [EMAIL PROTECTED] Subject: Re: [JBoss-user] exception handling advice Hi Brian, You might want to look into the BusinessDelegate pattern. It would fit between your struts actions and the session facade. In this level you can wrap system level exceptions inside more application usable exceptions. -M@ On Wednesday, September 10, 2003, at 09:34 AM, Brian McSweeney wrote: Hi all, I’d like to know what the best practice on handling exceptions is. I’m using: Jsps>struts actions > session facades > entity beans Imagine for a second that the session façade allows CRUD operations on myentity beans. For example say I have a entity bean called customer. Now if I try to create a customer using a session façade method should I Throw a CreateException back to the struts action so I can tell the client I couldn’t create the customer? I have read that both FinderExceptions and CreateExceptions in session Facades should just log it and throw new EJBException [http://www-106.ibm.com/developerworks/java/library/j-ejbexcept.html ] buthow can you give a meaningful error back to the client as to what happened? So should I catch finder and create exceptions in the struts actions? I’m very confused. Perhaps someone can give me some advice Thanks, Brian --- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user --- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user --- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
RE: [JBoss-user] exception handling advice
Brian, We do the same as Harm described. One thing we have found to be useful is to send a e-mail to an account dedicated to the application. We send exceptions as well as output from cron jobs. Personally, I find it much easier to browse through a set of e-mails than scan the log. Messages are generated from the web and ejb tiers. John --- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
RE: [JBoss-user] exception handling advice
Glad I could help... Cheers, Harm. "Brian McSweeney" <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 09/11/2003 02:08 PM Please respond to [EMAIL PROTECTED] To <[EMAIL PROTECTED]> cc Subject RE: [JBoss-user] exception handling advice Hi Harm, Yes, your answer is very clear and is what I was thinking of doing myself. I found it strange that the ibm doc said you should throw new EJBExceptions whenever a finder or create exception occurs. I appreciate your help, Cheers, Brian -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: 11 September 2003 09:45 To: [EMAIL PROTECTED] Subject: RE: [JBoss-user] exception handling advice Hi Brian, I always do the following. I have one 'baseexception' class. Which all my application specific exceptions extend. (I call this Application Exception). This means that If I catch a ApplicationException it means it has to be some exception generated by my own application. And not some FinderException or CreateException or whatever. In my SessionBean I always do this: If a create exception occurs, I catch it and throw a new Exception (which extends my ApplicationException) with a more meaningfull error message, to the client. The same thing for FinderExceptions. If a FinderException occures (which means that a particular bean cannot be found) I throw a new ApplicationException with a more usefull error like: Cannot find Bean with id: 1123123". This way in the client I don't have to catch all the FinderExceptions / CreateExceptions / RemoteExceptions or whatever. And if they do occur for some reason, it is usualy an exception which cannot be dealed with by the user of the application. Because it is a system exception. It might be a remote error, a programming error or whatever. There is nothing the user can do to correct the problem. Therefore I send the user to a System error page. (I do log the error altough, because I have to see what went wrong to fix the problem). I hope this helps? Good luck, Harm de Laat Informatiefabriek "Brian McSweeney" <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 09/11/2003 11:21 AM Please respond to [EMAIL PROTECTED] To <[EMAIL PROTECTED]> cc Subject RE: [JBoss-user] exception handling advice Thanks for the response Mathew, I'll look into the business delegate pattern, however I'm still confused as to what I should do with finder and Create exceptions from the session facades. Should these be: a) Thrown on to the clients b) caught and EJBExceptions thrown on if b) is true, how can the clients handle EJBExceptions? These are runtime exceptions no? Any advice for this issue would be really helpful, because I'm still very confused!! Thanks, Brian -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Matthew Hixson Sent: 10 September 2003 17:55 To: [EMAIL PROTECTED] Subject: Re: [JBoss-user] exception handling advice Hi Brian, You might want to look into the BusinessDelegate pattern. It would fit between your struts actions and the session facade. In this level you can wrap system level exceptions inside more application usable exceptions. -M@ On Wednesday, September 10, 2003, at 09:34 AM, Brian McSweeney wrote: > Hi all, > > > > I’d like to know what the best practice on handling exceptions is. > > I’m using: > > > > > > Jsps>struts actions > session facades > entity beans > > > > Imagine for a second that the session façade allows CRUD operations on > > myentity beans. For example say I have a entity bean called customer. > > > > Now if I try to create a customer using a session façade method should > I > > Throw a CreateException back to the struts action so I can tell the > client > > I couldn’t create the customer? > > > > I have read that both FinderExceptions and CreateExceptions in session > > Facades should just log it and throw new EJBException > > > > [http://www-106.ibm.com/developerworks/java/library/j-ejbexcept.html ] > > > > buthow can you give a meaningful error back to the client as to what > > happened? So should I catch finder and create exceptions in the struts > > actions? > > > > I’m very confused. Perhaps someone can give me some advice > > Thanks, > > Brian > > > --- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user --- This sf.net email is sponsored by:ThinkGeek Welcom
RE: [JBoss-user] exception handling advice
Hi Harm, Yes, your answer is very clear and is what I was thinking of doing myself. I found it strange that the ibm doc said you should throw new EJBExceptions whenever a finder or create exception occurs. I appreciate your help, Cheers, Brian -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: 11 September 2003 09:45 To: [EMAIL PROTECTED] Subject: RE: [JBoss-user] exception handling advice Hi Brian, I always do the following. I have one 'baseexception' class. Which all my application specific exceptions extend. (I call this Application Exception). This means that If I catch a ApplicationException it means it has to be some exception generated by my own application. And not some FinderException or CreateException or whatever. In my SessionBean I always do this: If a create exception occurs, I catch it and throw a new Exception (which extends my ApplicationException) with a more meaningfull error message, to the client. The same thing for FinderExceptions. If a FinderException occures (which means that a particular bean cannot be found) I throw a new ApplicationException with a more usefull error like: Cannot find Bean with id: 1123123". This way in the client I don't have to catch all the FinderExceptions / CreateExceptions / RemoteExceptions or whatever. And if they do occur for some reason, it is usualy an exception which cannot be dealed with by the user of the application. Because it is a system exception. It might be a remote error, a programming error or whatever. There is nothing the user can do to correct the problem. Therefore I send the user to a System error page. (I do log the error altough, because I have to see what went wrong to fix the problem). I hope this helps? Good luck, Harm de Laat Informatiefabriek "Brian McSweeney" <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 09/11/2003 11:21 AM Please respond to [EMAIL PROTECTED] To <[EMAIL PROTECTED]> cc Subject RE: [JBoss-user] exception handling advice Thanks for the response Mathew, I'll look into the business delegate pattern, however I'm still confused as to what I should do with finder and Create exceptions from the session facades. Should these be: a) Thrown on to the clients b) caught and EJBExceptions thrown on if b) is true, how can the clients handle EJBExceptions? These are runtime exceptions no? Any advice for this issue would be really helpful, because I'm still very confused!! Thanks, Brian -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Matthew Hixson Sent: 10 September 2003 17:55 To: [EMAIL PROTECTED] Subject: Re: [JBoss-user] exception handling advice Hi Brian, You might want to look into the BusinessDelegate pattern. It would fit between your struts actions and the session facade. In this level you can wrap system level exceptions inside more application usable exceptions. -M@ On Wednesday, September 10, 2003, at 09:34 AM, Brian McSweeney wrote: > Hi all, > > > > I’d like to know what the best practice on handling exceptions is. > > I’m using: > > > > > > Jsps>struts actions > session facades > entity beans > > > > Imagine for a second that the session façade allows CRUD operations on > > myentity beans. For example say I have a entity bean called customer. > > > > Now if I try to create a customer using a session façade method should > I > > Throw a CreateException back to the struts action so I can tell the > client > > I couldn’t create the customer? > > > > I have read that both FinderExceptions and CreateExceptions in session > > Facades should just log it and throw new EJBException > > > > [http://www-106.ibm.com/developerworks/java/library/j-ejbexcept.html ] > > > > buthow can you give a meaningful error back to the client as to what > > happened? So should I catch finder and create exceptions in the struts > > actions? > > > > I’m very confused. Perhaps someone can give me some advice > > Thanks, > > Brian > > > --- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user --- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user +,
RE: [JBoss-user] exception handling advice
Hi Brian, I always do the following. I have one 'baseexception' class. Which all my application specific exceptions extend. (I call this Application Exception). This means that If I catch a ApplicationException it means it has to be some exception generated by my own application. And not some FinderException or CreateException or whatever. In my SessionBean I always do this: If a create exception occurs, I catch it and throw a new Exception (which extends my ApplicationException) with a more meaningfull error message, to the client. The same thing for FinderExceptions. If a FinderException occures (which means that a particular bean cannot be found) I throw a new ApplicationException with a more usefull error like: Cannot find Bean with id: 1123123". This way in the client I don't have to catch all the FinderExceptions / CreateExceptions / RemoteExceptions or whatever. And if they do occur for some reason, it is usualy an exception which cannot be dealed with by the user of the application. Because it is a system exception. It might be a remote error, a programming error or whatever. There is nothing the user can do to correct the problem. Therefore I send the user to a System error page. (I do log the error altough, because I have to see what went wrong to fix the problem). I hope this helps? Good luck, Harm de Laat Informatiefabriek "Brian McSweeney" <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 09/11/2003 11:21 AM Please respond to [EMAIL PROTECTED] To <[EMAIL PROTECTED]> cc Subject RE: [JBoss-user] exception handling advice Thanks for the response Mathew, I'll look into the business delegate pattern, however I'm still confused as to what I should do with finder and Create exceptions from the session facades. Should these be: a) Thrown on to the clients b) caught and EJBExceptions thrown on if b) is true, how can the clients handle EJBExceptions? These are runtime exceptions no? Any advice for this issue would be really helpful, because I'm still very confused!! Thanks, Brian -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Matthew Hixson Sent: 10 September 2003 17:55 To: [EMAIL PROTECTED] Subject: Re: [JBoss-user] exception handling advice Hi Brian, You might want to look into the BusinessDelegate pattern. It would fit between your struts actions and the session facade. In this level you can wrap system level exceptions inside more application usable exceptions. -M@ On Wednesday, September 10, 2003, at 09:34 AM, Brian McSweeney wrote: > Hi all, > > > > I’d like to know what the best practice on handling exceptions is. > > I’m using: > > > > > > Jsps>struts actions > session facades > entity beans > > > > Imagine for a second that the session façade allows CRUD operations on > > myentity beans. For example say I have a entity bean called customer. > > > > Now if I try to create a customer using a session façade method should > I > > Throw a CreateException back to the struts action so I can tell the > client > > I couldn’t create the customer? > > > > I have read that both FinderExceptions and CreateExceptions in session > > Facades should just log it and throw new EJBException > > > > [http://www-106.ibm.com/developerworks/java/library/j-ejbexcept.html ] > > > > buthow can you give a meaningful error back to the client as to what > > happened? So should I catch finder and create exceptions in the struts > > actions? > > > > I’m very confused. Perhaps someone can give me some advice > > Thanks, > > Brian > > > --- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user --- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user N¬±ù隊X¬²'²Þu¼)äç¤Yé\¢g¢½éá¶ÚþØbHzG(û$,²ë®f¢)à+-$,²ë®X¬¶Ë(º·~àzwÛi³ÿåËl²«qç讧zßåËlþX¬¶)ߣøۢË.±ê
RE: [JBoss-user] exception handling advice
Stop hijacking my thread :-) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Vijaya Sent: 11 September 2003 08:47 To: [EMAIL PROTECTED] Subject: Re: [JBoss-user] exception handling advice Hai, I followed your step-by-step instructions given to configure 2 instances on the same machine. While I'm trying to access the jsps, some warning messages are getting printed like No Tx support for findByPrimaryKey, setSession and all.Can we ignore these warnings? Then I tried to pass a String variable to the next jsp where it uses a set method to set the value after look up. This time I got a Non-serializable attribute exception. Then I added implements Serializable to the relevant classes and proceeded. This time, I got a servlet exception and the root cause as Out of Memory Error. Also an info message socket is closed is getting printed. When I tried to specify url in the jndi properties, server1:1100, server2:1100, it's directly looking up the second one ignoring the first one. Same problems I'm facing even if I run the instances on different machines. I got struck up with this and trying all possibilities I found on net. Can you please suggest how to proceed and where I'm configuring incorrectly? Thanks & Regards Vijaya --- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user --- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
Re: [JBoss-user] exception handling advice
Hai, I followed your step-by-step instructions given to configure 2 instances on the same machine. While I'm trying to access the jsps, some warning messages are getting printed like No Tx support for findByPrimaryKey, setSession and all.Can we ignore these warnings? Then I tried to pass a String variable to the next jsp where it uses a set method to set the value after look up. This time I got a Non-serializable attribute exception. Then I added implements Serializable to the relevant classes and proceeded. This time, I got a servlet exception and the root cause as Out of Memory Error. Also an info message socket is closed is getting printed. When I tried to specify url in the jndi properties, server1:1100, server2:1100, it's directly looking up the second one ignoring the first one. Same problems I'm facing even if I run the instances on different machines. I got struck up with this and trying all possibilities I found on net. Can you please suggest how to proceed and where I'm configuring incorrectly? Thanks & Regards Vijaya --- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
RE: [JBoss-user] exception handling advice
Thanks for the response Mathew, I'll look into the business delegate pattern, however I'm still confused as to what I should do with finder and Create exceptions from the session facades. Should these be: a) Thrown on to the clients b) caught and EJBExceptions thrown on if b) is true, how can the clients handle EJBExceptions? These are runtime exceptions no? Any advice for this issue would be really helpful, because I'm still very confused!! Thanks, Brian -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Matthew Hixson Sent: 10 September 2003 17:55 To: [EMAIL PROTECTED] Subject: Re: [JBoss-user] exception handling advice Hi Brian, You might want to look into the BusinessDelegate pattern. It would fit between your struts actions and the session facade. In this level you can wrap system level exceptions inside more application usable exceptions. -M@ On Wednesday, September 10, 2003, at 09:34 AM, Brian McSweeney wrote: > Hi all, > > > > Id like to know what the best practice on handling exceptions is. > > Im using: > > > > > > Jsps>struts actions > session facades > entity beans > > > > Imagine for a second that the session façade allows CRUD operations on > > myentity beans. For example say I have a entity bean called customer. > > > > Now if I try to create a customer using a session façade method should > I > > Throw a CreateException back to the struts action so I can tell the > client > > I couldnt create the customer? > > > > I have read that both FinderExceptions and CreateExceptions in session > > Facades should just log it and throw new EJBException > > > > [http://www-106.ibm.com/developerworks/java/library/j-ejbexcept.html ] > > > > buthow can you give a meaningful error back to the client as to what > > happened? So should I catch finder and create exceptions in the struts > > actions? > > > > Im very confused. Perhaps someone can give me some advice > > Thanks, > > Brian > > > --- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user --- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
Re: [JBoss-user] exception handling advice
Hi Brian, You might want to look into the BusinessDelegate pattern. It would fit between your struts actions and the session facade. In this level you can wrap system level exceptions inside more application usable exceptions. -M@ On Wednesday, September 10, 2003, at 09:34 AM, Brian McSweeney wrote: Hi all, I’d like to know what the best practice on handling exceptions is. I’m using: Jsps>struts actions > session facades > entity beans Imagine for a second that the session façade allows CRUD operations on myentity beans. For example say I have a entity bean called customer. Now if I try to create a customer using a session façade method should I Throw a CreateException back to the struts action so I can tell the client I couldn’t create the customer? I have read that both FinderExceptions and CreateExceptions in session Facades should just log it and throw new EJBException [http://www-106.ibm.com/developerworks/java/library/j-ejbexcept.html ] buthow can you give a meaningful error back to the client as to what happened? So should I catch finder and create exceptions in the struts actions? I’m very confused. Perhaps someone can give me some advice Thanks, Brian --- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] exception handling advice
Hi all, I’d like to know what the best practice on handling exceptions is. I’m using: Jsps >struts actions > session facades > entity beans Imagine for a second that the session façade allows CRUD operations on my entity beans. For example say I have a entity bean called customer. Now if I try to create a customer using a session façade method should I Throw a CreateException back to the struts action so I can tell the client I couldn’t create the customer? I have read that both FinderExceptions and CreateExceptions in session Facades should just log it and throw new EJBException [ http://www-106.ibm.com/developerworks/java/library/j-ejbexcept.html ] but how can you give a meaningful error back to the client as to what happened? So should I catch finder and create exceptions in the struts actions? I’m very confused. Perhaps someone can give me some advice Thanks, Brian