Hello, A while back Rick Hightower submitted a request to change the way Struts handles errors. His problem (and mine) is that Struts tends to catch exceptions and throw different exceptions indicating the problem. Needless to say this can badly obscure the original cause of the error.
So today I set about remedying it using AspectJ--an aspect oriented extension to Java produced by Xerox PARC (http://www.aspectj.org). I added the following aspect to the org.apache.struts package: public aspect ExceptionLogger+AHs- before(Throwable e) : args(e) +ACYAJg- handler(Throwable+-)+AHs- System.err.println(+ACI-Exception caught in the Struts framework:+ACI-)+ADs- e.printStackTrace(System.err)+ADs- +AH0- +AH0- Then I compiled Struts with an Ant task for AspectJ compilation: +ADw-target name+AD0AIg-compile.library+ACI- depends+AD0AIg-prepare.library+ACI- description+AD0AIg-Compile Struts library files+ACIAPg- +ADw-ajc srcdir+AD0AIgAkAHs-src.share.dir+AH0AIg- destdir+AD0AIgAkAHs-build.home+AH0-/library/classes+ACIAPg- +ADw-classpath refid+AD0AIg-compile.classpath+ACI-/+AD4- +ADw-/ajc+AD4- +AFs-...task continues as normal...+AF0- Now all exceptions caught in the Struts framework are automatically logged to System.err. So my question is: Should we consider the use of AspectJ in Struts? This would potentially have no effect on the users of the framework, but could be valuable for implementing logging and error-handling policies. The above code could be modified to write to a log4j log if that would be more convenient. Does this intrigue anyone? Should we continue investigation? Cheers, Nicholas Lesiecki (For more info on AspectJ, look for my forthcoming article on IBM's developerWorks.) Technical Team Lead eBlox, Inc. (520) 615-9345 x104 Check out my new book+ACE-: Java Tools for Extreme Programming: Mastering Open Source Tools, including Ant, JUnit, and Cactus http://www.amazon.com/exec/obidos/ASIN/047120708X/ -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>