Recently, I’ve been converting a project to use Spring. My main method looks something like this.
ApplicationContext context = new ClassPathXmlApplicationContext("context.xml");
Main main = (Main) context.getBean("main");
main.run();
There’s a problem though. Several of my beans need to be configurable. Normally, I’d resolve this by using a PropertyPlaceholderConfigurer (or more likely [...]
I’ve just noticed something rather nice in Eclipse. The “Mark Occurrences” feature () will show you where an exception is thrown. For example, here I’ve clicked on the IOEXception in the method definition.
You can clearly see that read(), write(), flush() and close() are points at which the IOEXception can be thrown.
Similarly, you can [...]
I’ve just found an annoying bug in a product at work. I was formatting a date (as part of a test) and expecting to get back a known value. The easiest way to do this is:
Date when = new Date(0); // 1970-01-01 00:00:00
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd’t'HH:mm:ss");
String whenStr = [...]
By default, when eclipse creates a try/catch block for you, you end up with something like this:
try {
doSomething();
catch (EvilException e) {
// TODO auto-generated catch block.
e.printStackTrace();
}
This is worse than useless, as it (effectively) covers up the exception1. [...]
An interesting problem cropped up today. We want to use a servlet for the home page in a Spring Web MVC project. Initially we had this in web.xml.
<servlet>
<servlet-name>foo</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>foo</servlet-name>
[...]
Last night, I was looking at generating SAMS XML from Java objects. It made me realise two things:
Java sucks badly at creating XML (by default).
I should really be looking at XML Binding.
I’m interested in point 1. I’ve done it before, trying to write XML using DOM (as there doesn’t appear to be a [...]
A colleague gave me a nudge today. “This page doesn’t validate because of an encoding error”. It was fairly simple: the string “Jiménez” contained a single byte—Latin1. Ooops. It turned out that we were generating the page as ISO-8859-1 instead of UTF-8 (which is what the page had been declared as [...]
I was wondering why one of my computers seemed to have an older version of m2eclipse installed. It turns out that they moved the update site from m2eclipse.codehaus.org/update/ to m2eclipse.sonatype.org/update/. Doh. It’d be nice if they mentioned that one the front page.
I hate maven. The UI sucks so badly, it’s incredibly painful to use. Anything that can take the edge off this has to be a good thing. In the past, I’ve experimented with m2eclipse, but to be quite frank, it’s not much improvement over the command line. And the tools are [...]
I’m looking at Wicket this evening. There’s a wicket tutorial on theserverside.com. However, the first code example fails!
Initially I tried to get things working by downloading wicket. However, the article recommends maven (as does the quickstart), so I grit my teeth and went ahead.
Once again, I get 50 lines of gibberish, including [...]