Tuesday, June 8, 2010

How Do I Hate Struts? Let Me Count The Ways

The more I use Struts, the more I learn to hate it.  Today I was trying to figure out why a particular Java class was throwing a null pointer exception when it executed a particular method.  Had I broken something?  No.  Struts ActionForward scheme is a method for a Java method running on the server to tell the browser what JSP should be loaded next.  In a warped way, it's rather like the evil goto statement--but between two programs running on two computers that don't even have to be on the same planet.  (And yes, I'm serious.  JPL updates software on their space probes via ftp, so if you were really, really warped, you could run a server on a space probe circling Uranus, and have it respond to web requests here on Earth.)

It turns out that the ActionForward scheme looks up where to go next in an XML file--and it is, of course, case sensitive.  And if the code has the wrong case (as was this code written years ago by someone who is no longer present), instead of some sort of useful exception that might give you a clue as to problem, something like UnrecognizedActionNameException, it just throws NullPointerException.

Java, I like. Struts, I detest.

1 comment:

  1. One of the hats I wear involves diagnosing the failure of QA tests in an environment built on Struts and Hibernate, and the combination makes for a very painful debugging experience. Worse, the developers are so accustomed to seeing the garbage stack traces and absurd SQL queries that they tend to blame the failures on user error unless someone ("me") can navigate through the mess of logs to find the root cause.

    I've come to dislike Struts. I loathe Hibernate.