Friday, 6 August 2010

Being dumb with JAXB and Spring

Yesterday I wasted a coupled of hours and it is my own fault. Just in case you hit the same problem (or in case I hit it again and forget) I'll note it here.

I'm using a mix of JAXB and Spring and I was getting an error message:
javax.xml.bind.JAXBException: "com.mypackage.MyClass" 
    doesn't contain ObjectFactory.class or jaxb.index

This is when Spring tries to load this bean:
<bean 
    class="org.springframework.oxm.jaxb.Jaxb2Marshaller" 
    id="PIMJaxb">
    <property name="contextPaths">
        <list>
            <value>com.mypackage.MyClass</value>
            <value>com.mypackage.MyClass2</value>
        </property>
</bean>

You may have spotted the obvious mistake already but I didn't
The contextPaths property has to be a list of packages not classes.
It is trying to use the class name I have it as a package name and it is trying to find an ObjectFactory class or a jaxb.index file in that package. Since there is no such package then it reports that it cannot find them. Fair enough.

I, however, assumed there was some complication to do with JAXB versions (I have had several of those) and wasted more time than I should have.

For the record, the bean definition needs to be like this:
<bean 
    class="org.springframework.oxm.jaxb.Jaxb2Marshaller" 
    id="PIMJaxb">
    <property name="contextPaths">
        <list>
            <value>com.mypackage</value>
        </property>
</bean>

Monday, 2 August 2010

Clonezilla

What a great idea.

I am quite careful about backups because I use my laptop for work and if something goes wrong with it then I stop earning, or at least I mess about the people I work for.

So we have two laptops the same, one for me and one for my wife. If mine goes wrong I figured I can pop the hard disk from mine, plug it into hers and I'm away (okay, she's one laptop short but we're good at sharing).

But what if my hard disk is the thing that dies? I can go to my backups and restore on a new disk but I just know there will be some files somewhere that missed the backup, probably some vital system setting that I'll spend precious hours sorting out.

Enter Clonezilla. This will clone your disk onto a spare one. Everything. You do need to have a spare disk (at $NZ100-ish that's easy) some way to connect to the laptop (USB drive).

Then you burn the Clonezilla software to a CD and boot from that, follow the instructions and it will clone your old disk to your new disk. For me the process took about 1.5 hours and I tested it by booting off the new disk. Everything was there.

I plan to redo this about every six months.

So if I lose my hard drive I can boot the clone, restore my backups to it, and I'm up and running with minimal fuss.

I usually back up weekly to another USB drive and all backup drives are kept on a separate site. We had a house fire once so I know that storing then in a cupboard in my house is not good enough. I'd lose both the laptop and the backups.

I have another USB drive for archive stuff, but I plan to copy those to archive quality DVDs now that I have all my photos scanned.