IIRC the origin field on the manifest doesn't hold an actual URI, it just holds a name. So this two lines should just be:
webappTargetDirName = webapps.pckManifest.origin;