Tracking down error 80020101 in Internet Exploder

So yesterday, after all of the travel fun and games of the few days, it was back to the real world with a bump. I had a pile of bugs to fix on various projects. Most were very simple to get through, but one has taken me several hours to track down so I thought it would be useful to record the problem and my solution.

In IdeaJam we use Mootools as I have mentioned many a time before. Mootools, when executing Ajax requests does some very funky stuff to make the request as efficient as possible. One of those things, is that will detect the content type of the page you're requesting and try it's best to process it as it should, that is, if you request Javascript then it will try and execute it. Unfortunately if you're in IE, then it uses the following technique 

window.execScript(code)

This is all well and good until there is an error in the Javascript it is evaluating (and it is very picky about syntax here). When there is an error you will get something like:

Could not complete the operation due to error 80020101

There are a *lot* of websites out there where people have come across this problem and then tracked it down to a specific problem with their code so they assume that this error message means you should remove comment tags from your script, or there's a missing semi colon on the end of a line, or an array is incorrectly formed. All of these may well be true, but the error message just means "There is an error", you can read no more into it than that.

Instead, you need to look very closely at whatever is being returned and evaluate it manually yourself to track down the issue.

What was especially galling for me, is that my problem was entirely my own fault. I had set the content type of the page I was requesting using Ajax to be text/javascript when it actually it should have been text/html. So Mootools was trying to evaluate some "code" which could never possibly work. So my fix was simply to change the content type of my response page.

The point is that your problem may be something entirely different, and you'd still get exactly the same error message from IE. Thanks for that Microsoft.

Cross browser testing using VMWare

As an Apple user, when I'm doing Domino development I live in VMWare Fusion to emulate Windows. And since the release of the Windows 7 Release Candidate (free until next year) doing testing in IE6 and IE7 is nigh on impossible. There are tools that you can use to emulate the different browsers (such as IETester) but I have found them to be unreliable.

It's a little know fact that Microsoft actually give out free copies of Virtual PCs setup for IE6 and IE7 compliance testing from their website. Of course because it's a virtual PC image and not a VMWare image we have to go a little further and convert the one to the other. That's where these instructions come in. You'll need to download a conversion tool, the one that worked for me was Q which is actually mentioned in the comments rather than the main body.

Once you've done the conversion, you end up with small (i.e. <1gb) Virtual Machines that you can do "proper" IE testing in until you get the nerve to tell you're idiot IE users that they need to move into the 21st century and start using one of the proper browsers.

Anyway, what it does mean is that you can leave XP and IE6 behind altogether except for your testing which can only be a good thing. Windows 7 really is a big step forwards, even for those of us who don't even like Windows.

Log4J logging to the console

I'm conscious that technical posts have been notable by their absence here recently, but it's just the nature of what I'm doing right now. Anyway I'm not sure this counts but it's caused me to waste half an hour searching for it.

Log4J is an excellent Java logging solution (if you're not using then I highly recommend it). The only problem I've had is that when writing test classes I get an error "log4j:WARN No appenders could be found for logger", so, how to get the logging output to be sent to the console in MyEclipse? It's a very simple problem but is something I always forget. Well, all you need to do is add one line at the start of the main method:

BasicConfigurator.configure();


So your test class will look like this:
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;

public class MyClass{
   static Logger logger = Logger.getLogger(MyClass.class);
   public static void main(String[] args) {
      BasicConfigurator.configure();
      logger.debug("This will appear in your console now");
   }
}

Next week I'll be teaching you how to suck eggs!

A demo iText application

I always find the best way to learn some new geekery is to write something with it rather than just reading a book. So in that spirit I've used one of my spare domain names to bring you Invoicr. I know, you're wondering where I got the idea for the name from, let's just call it inspiration!

So Invoicr is a simple form which uses a couple of neat little Javascript-y things in Andrew Tetlaw's really easy field validation with Prototype and the DHTML XGrid for the dynamic table.

They are nice but not really the point of the app, which was to play around with iText which I mentioned earlier this week. The PDF I'm producing doesn't really stretch what iText is capable of but it does show off element positioning, tables, font formatting etc which is all I really need at the moment. So have a look and if you're interested in how it all works, then you can get the nsf here.

Heavy Duty Javascript-ing

The new project I'm working on is moving on quickly and I'm in the middle of some really heavy duty Javascript work for a complicated web form. We are making use of a Javascript library which I think I've mentioned before called the DHTMLXGrid which is a full featured dynamic table solution which can store it's data as XML and HTML. No single bit of it is especially complex but put together it would take several months to duplicate and it only costs £150 for the professional version so we've forked out for it. Well worth a look, even the basic, free version is very good.