Wednesday 12 September 2007

Lesson of the Day: restart the sodding server. And eat lentils.

Aaaaaaarrgghhhhh! JSP is hard, let's eat.

OK, so as a generic bioinformatics IT type, I have to deal with all kinds of code. I don't get to specialise in a language. Get a JSP app running when I've never even read, let alone coded, a JSP page before in my life? Sure, no worries. It's only code, how hard can it be? I've downloaded and unpacked the source, popped it into tomcat, it mostly goes. But there are errors. I have to get this file upload page working. I fix the database problem with the duplicate statements. I fix the javascript error with the windoze-specific file separator. I'm feeling good, powering along, and then comes the jsp refusing to compile.

That turned into an all-day battle. It can't resolve a type. I find the library with the relevant class in it - it's org.apache.commons.fileupload. It all seems to be correct, it's right there in the WEB-INF/lib directory. I don't understand this. I try everything I can think of - moving it to other possible directory structures; putting it right in tomcat's lib directory; editing the import statements to get only the specific class needed; fully qualifying the class name... I send begging emails to the friendly Italians who wrote the original code. (Yes, I am trying to debug code with occasional comments like "Non ci sono input". No, I don't speak Italian.) I can see it's attempting to recompile each time, so it's not a caching error. I check that the jar file is complete and contains the class. Yes, it's not corrupt, it's fine. Nothing works. And then the bloke says to me "did you restart the server?"

Well, no. I hadn't. It didn't occur to me - and why would it? Tomcat is clearly attempting to recompile the jsp each time I reload - it's aware that the code has changed. But apparently it's NOT aware that libraries have moved. But that is the trick, and finally it works! Or at least, I no longer have an error on line 32 but on line 75, which is good enough for me to call it a day. Talk about a trap for new players.

Since I've been working at home for the last few hours, dinner is almost immediately available. I just need to wash and steam some greens. The sausage and lentil casserole is sitting there in the slow cooker. It's warm and comforting - both healthy and tasty. The thin rabbit sausages from EcoMeats are mildly spicy, and they match the earthy herby lentils nicely. Last night I fried up a finely diced onion and carrot, browned the sausages, and deglazed the pan with brandy. In the morning, I tossed it all in the slow cooker, with the de-fatted lamb stock, a bit of red wine, Australian green lentils, and some bay laves, thyme and rosemary from the garden. When I left for work I turned it on low; I came home early after a meeting and it was smelling great.

See? I knew I'd think of something to do with that lamb stock. Oh, and the curry yesterday was fine - actually it turned out a bit too mild. Rescue mission successful.

Cooking today: Sausage and lentil casserole.

No comments: