JBoss -> GlassFish: Context Root for War file name starting with number

This entry is based on this blog.

If the war file name begins with a leading number, then on JBoss the leading numbers are dropped when the context root is dervied. However, on glassfish, the leading number will be preserved.

The solution is to use the context-root element in sub-web.xml to explicitly set the context-root.

Note on Java EE Compatibility: Java EE specification requires that when a war file is packaged in an ear file and there is no deploment descriptor included in application package (ear file), then the context root of the web module is derived from the war file name by dropping the .war extension. GlassFish therefore preserves the leading number in a war file name when deriving the context-root. When the war file file is deployed standalone (i.e. not packaged in an application package - ear file), then GlassFish likewise (for consistency) performs the same mapping and so the leading numbers are preserved as well.