• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

declarative exception tag ignored!

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When declaratively handling exceptions, struts is completely ignoring the exception tag I specify in my action:



I have the following Exception hierarchy (low to high):
DuplicateRecordException -> DataAccessException -> ApplicationException -> BaseException -> NestableException

My UserAction invokes a register method, which like other business logic methods throws an ApplicationException so that struts can handle it.

In the case above, a DuplicateRecordException is thrown if a user tries to register with a user name that already exists. I can see through my logged output that the exception is indeed being thrown, but the registration page doesn't indicate it. This is the message I get from <html:errors/>:
???en_US.DataAccessException error in register(): ic.pd.common.DuplicateRecordException: Duplicate user exists for username='100251162'???

Whereas I'm expecting the message from the resources bundle specified by the key (error.register.duplicate) that I configured for the exception in struts-config.xml. In fact, even if I change the path in the exception tag to somewhere else, it still takes me back to my registration page, so it appears to be completely ignoring my exception tag!

Any idea why?

Thanks in advance,
Brad.
 
Brad Carson
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I solved my own problem!

I came across this excellent article by Hu Ji Rong: "Handle Exceptions in Web Applications with EJB and STRUTS"

I rewrote my exception classes with respect to the article, made a new DuplicateUserException class extending from ApplicationException and modified the struts-config.xml respectively and voila -- it worked!

I'm guess it must have something to do with how my exceptions were written and that struts was unable to traverse through the hierarchy to handle the DuplicateRecordException. I suspect that it could previously only handle ApplicationException types and not its children.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic