Monday, 26 November 2007

If you search the web, you will encounter lots of discussions about what causes a class cast exception in JAXB when you try and implement the NamespacePrefixMapper and then call marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", ... ).

However, the simplest cases are not always discussed.

We encountered this problem with marshalling xml in an EJB3 environment and it turned out to be a genuine class cast exception as follows:

Code was being called from a servlet. However, the Web Server was using JAX-WS which was using a different version of JAXB to the back-end. (sharing the libraries during deployment).

The solution (quick hack for us) was to get the Servlet to call a session bean which was using the correct version of JAXB. Obviously at some point we should ensure consistency across the board, but for anyone who is getting a ClassCastException when using NamespacePrefixMapper - check the jars first ;)

Saturday, 3 November 2007

Background

Having lived and breathed computers since 1980, I have been a long term customer of the Microsoft Track. Despite various roles in Unix Admin and development ranging from Minix thru Sco Unix to AIX, HPUX and now Linux, my home pcs have always been Microsoft boxes.

I develop in Java, C and C++ and so I have always wanted a powerful machine; and I travel a lot and so I have always wanted a laptop. By the time you’ve loaded Netbeans, Eclipse, JBOSS, Oracle or some other database, XML Spy and whatever else my current project deems to be important at the time; the machine and the operating system is taking quite a hit.

The Impetus to Move

More recently, when running all this on Vista I have found the machine just too unresponsive and so the decision had to be taken to change machines once again. My choices were simple (to me):

a Sony Vaio SZ5, 2.16 Intel Core 2 Duo with 2GB ram, or

a MacBook Pro, 2.4GHz Intel Core 2 Duo with 4GB ram.

Normally I would shy away from Mac because I have 15 years of files that are all windows files - documents, etc.

However, this time I found out about Parallels which allows Windows to be installed in parallel with Mac OS X.

Parallels, a demo of a 15” MacBook Pro and frustration at how long it was taking NetBeans to load finally did it for me.

The rest is the migration...

Useful Reading

As a first timer to Mac I decided to do a bit of reading beforehand. These two books were really useful and made the transition from Windows to Mac a breeze

- Switching to the Mac: The Missing Manual - Tiger Edition

- MAC OS X: The Missing Manual - Tiger Edition

Existing Setup

Before going on to the integration of my new Mac into my home, let’s take a look at my existing setup:

I won’t go into too much detail into the whys and wherefores for such a setup, suffice it to say that I can access all my files on the Thecus from whichever machine I am on, and whenever the BT Broadband fails, I don’t have all the hassle that Vista now gives me selecting (instead of auto connecting to) my wireless router.

Moving to the Mac

Okay, here goes. I’ve got my Mac and for now I am ignoring the wireless network and going with the wire network. So, cable into back of machine, power up and go with all the defaults until the machine is running.

The Mac has come complete with OS X 10.4 (Tiger) so the first few things I do are:

Configure Mac to require login

From the menu bar at the top, select:

- -> System Preferences...

- Security

check the following:

- Require password to wake this computer...

- Disable automatic login

Setup User Account Password

From the menu bar at the top, select:

- -> System Preferences...

- Accounts

Setup your accounts as you want them

Connect to the N5200

Double click the hard drive icon on the desktop

- Network -> My Group -> N5200 -> Connect

Select the required folder, click OK

Ignore the login/password options, but when prompted say OK to adding the entry to the KeyChain.

Connecting the Printer

From the menu bar at the top, select:

- -> System Preferences...

- Print and Fax

do the following:

- Click + to add printer

- Protocol: IPP

- Address: :631 - e.g. 192.168.1.64:631

- Queue: /printers/usb-printer

- Name: Home Printer, or whatever you choose

- Location: Living Room...

- Print Using: ...

When it comes to selecting the Printer Driver I found that the Canon printer drivers left me printing documents 1/4 size. I found that if you download the PrintFab drivers before you install your printer, you can use the appropriate PrintFab printer driver and they are much more reliable.

Installing Vista in Parallel

This is so easy, it is hardly worth mentioning. Insert the Parallels dvd and follow the instructions, installing all the defaults.

Then, insert your Vista dvd and Parallels will see it and take over the installation. Here’s the beauty; every time you are required to reboot Vista, it only reboots the Parallels window and not your whole machine. So you can still keep playing with your Mac.

If you want Vista to run inside it’s own Parallels window then leave everything as default.

If you want the Vista start button to be integrated with your Mac desktop then click the Coherence button (on the right hand pane of the Parallels window).

Repartitioning the Hard Drive

As always, I was so keen to play with my Mac that I got everything up and running and then my OS X 10.5 Leopard (beta) DVD arrived in the post from joining the Mac Developer Network.

Now, I have to resize my hard disk and a cursory glance at the Disk Utility tool would suggest that it can’t be done...

- but wait!

...

Open a Terminal Window

(look in the folder Applications -> Utilities -> Terminal)

...

At the command prompt type

computer name:~ login$ diskutil list

The computer will display a list of your hard disks and information about them.

Mine showed that my Tiger installation was on the whole disk as follows:

# type name size identifier

2: Apple HFS Macintosh HD 160GB disk0s2

...

This is the partition that I want to shrink so I can install Leopard. So first I determine the minimum and max size I can set the partition to using:

diskutil resizevolume disk0s2 limits

This gives me:

Current Size: 160GB

Min Size: 67GB

Max Size: 160GB

...

I am supposed to be able to resize the volume and create a new one at the same time but I managed to screw that up, so here is the command that I ran by accident :(

diskutil resizevolume disk0s2 80G

Now sit back and wait while the partition is verified and resized. Eventually you will be prompted to reboot the computer.

...

Reboot the computer from the Apple Icon in the top menu.

...

Now open the Disk Utility by selecting the icon:

Applications -> Utilities -> Disk Utility

...

Once in the Disk Utility, the disk will appear as disk0s3 but you cannot access it because it is not mounted.

Click on the Erase tab.

Set the following:

- Volume Format: Mac OS Extended (Journaled)

- Name: Leopard

Click the erase button

...

Now the volume appears on the computer.

Installing Leopard

Insert the Leopard dvd and click Install Max OS X

The computer will prompt you to restart the computer and also to enter your password to enable the installation.

Enter the password and click ok.

...

Follow the defaults.

When you are prompted to choose the installation location for Leopard, click on the Leopard drive and click.

Follow the defaults.

Backing up Mail

Backing up Mail is a simple case of copying files and folders:

Once you have created a backup folder the files/folders you need to backup are: