1.) Add the mime type to the the domain’s default-web.xml (ex. domains/domain1/config/default-web.xml)
2.) Restart the domain
3.) Redeploy the web application where the file related to the new mime type is being served.
Sound simple? It is simple! But it took me a week to figure this out! The documentation is flaky on this subject. First, I just tried the Help in the Admin Console. I searched mime. Nothing. So I tried the documentation. In the Developer’s Guide, I found this:
Using the default-web.xml File
The mime-mapping elements in default-web.xml are global and inherited by all web applications. You can override these mappings or define your own using mime-mapping elements in your web application’s web.xml file. For more information about mime-mapping elements, see the Servlet specification.
You can use the Admin Console to edit the default-web.xml file. For details, click the Help button in the Admin Console. As an alternative, you can edit the file directly using the following steps.
To Use the default-web.xml File
- Place the JAR file for the filter, security constraint, or other feature in the domain-dir/lib directory.
- Edit the domain-dir/config/default-web.xml file to refer to the JAR file.
- Restart the server.
From this, I gathered 2 important facts:
1.) I can add a global mime type to default-web.xml
2.) I will probably need to start the server
On the glassfish forum, I gathered that for default-web.xml changes to take effect, the application that needs them requires a redeployment. Great! No problem…didn’t work.I was overlooking a small detail. I redeployed the wrong application. I redeployed that application that links to the file I was miming, instead of the application that actually contains the file: the “/” application that serves the purpose of document root. Once I redeployed “/”, it all worked fine.