WebWorks Resource Name Not Valid Workaround

I’ve been looking at using Phonegap and Dojo for rapid application development on mobile devices. As I have been doing blackberry development for the past year or so I thought that this would be a good platform to start on. However, I almost immediately ran into a problem with the WebWorks packager.

The problem is that the packager will not permit paths with special characters in them – special characters including the somewhat limiting “_” and “-“. Instead of packaging the files it would return the error Invalid widget archive – resource name is not valid This is especially a problem with dojo and it commonly uses these conventions for stylesheets and js files.

After Googling, I found that this behaviour was by design. It seems that if you pass a file with a dash in it, the RAPC compiler thinks that it is a command line switch.

See:

https://www.blackberry.com/jira/browse/WEBAPI-50

http://supportforums.blackberry.com/t5/Web-Development/bbwp-quot-resource-name-not-valid-quot/m-p/607222

http://mobijournal.com/common-blackberry-webworks-development-pitfalls-that-can-be-avoided/

Fortunately, RIM has recently open sourced the Webworks API. I knew from my experience with bb-ant-tools that you were able to pass a file containing paths to the files to include in the package, thus circumventing the problem with the command line switches.

The packager now successfully packages _bad-path.txt.

To patch your webworks packager, download WebWorksPatched extract it and move the bbwp.jar to your webworks bin folder (Usually C:\Program Files\BlackBerry WebWorks Plug-in Eclipse\plugins\net.rim.browser.tools.wcpc_1.5.1.201010291444-22\wcpc\bin).

For the brave of heart, source code is available on GitHub at https://github.com/51systems/WebWorks