Are you seeing a 907 Invalid COD or HTTP Error 406 when attempting to install a J2ME app on a Blackberry via GlassFish App Server? The problem can be intermittent, and doesn't necessarily affect all Blackberry models. Barring the fact that your JAD or COD file might actually be corrupt (which is an issue not covered here), the cause is most likely a missing mime-type for COD files in the GlassFish default-web.xml descriptor...
This problem has tripped me up time and time again, as the root cause is one of those little configuration options that it easy to forget when deploying your JEE/J2ME app to a fresh GlassFish install. It's time to blog the solution in the hopes that it might lodge in my memory...
Solution
The HTTP 406 "not acceptable" error is actually a red-herring, and after Googling the result you will most likely end up here, which although informative, doesn't provide much help. The actual cause is that GlassFish doesn't know what mime-type the COD extension maps to, which results in the COD file being served incorrectly to the BB device. This can be fixed by editing the <glassfish_install_dir>/domains/domain1/config/default-web.xml file and adding the following element under the root web-app element
<mime-mapping>
<extension>cod</extension>
<mime-type>application/vnd.rim.cod</mime-type>
</mime-mapping>
If you include this element with the rest of the mime-mappings your default-web.xml file will look something like this...
<?xml version="1.0" encoding="ISO-8859-1"?>
...
<!DOCTYPE web-app PUBLIC "-Sun Microsystems, Inc.DTD Web Application 2.3EN" "http:java.sun.com/dtd/web-app_2_3.dtd"><web-app>
...
<!-- ====== Default MIME Type Mappings ====== -->
...<mime-mapping>
<extension>cod</extension>
<mime-type>application/vnd.rim.cod</mime-type>
</mime-mapping>...
</web-app>
Key Points!
- You must restart your GlassFish server after making this change.
- You must also clear the Blackberry browser cache of any device that has attempted to download the mobile app previously i.e. any device which has visited your GlassFish server and potentially cached the available mime-types
If the above steps don't help, or you have already configured the GlassFish mime-types correctly check out this forum post for more guidance...
Daniel
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Daniel Bryant (Director) | Tai-Dev Ltd
www.tai-dev.co.uk - IT Consultancy Services Specialising in JEE, Web 2.0 and RDBMS

