Bug 1195203 - openjdk 6: MimetypesFileTypeMap no default mime.types
openjdk 6: MimetypesFileTypeMap no default mime.types
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: java-1.6.0-openjdk (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Andrew John Hughes
Lukas Zachar
Depends On:
Blocks: 1271375
  Show dependency treegraph
Reported: 2015-02-23 06:14 EST by Aleksandar Kostadinov
Modified: 2016-05-10 16:29 EDT (History)
4 users (show)

See Also:
Fixed In Version: java-1.6.0-openjdk-
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2016-05-10 16:29:54 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
Icedtea Bugzilla 2800 None None None 2016-01-21 01:22 EST

  None (edit)
Description Aleksandar Kostadinov 2015-02-23 06:14:14 EST
Description of problem:
Trying to get mime type of files with MimetypesFileTypeMap.getDefaultFileTypeMap() [1] results in always returning "application/octet-stream" regardless of file type or extension.

I couldn't find any default mime.types file used by java. So I tried a workaround:
> ln -s /etc/mime.types ~/.mime.types

And it starts to work. I IMO the openjdk package should be modified to take default mime.types from /etc/mime.types and then search in other locations for the file.

[1] http://docs.oracle.com/javaee/5/api/javax/activation/MimetypesFileTypeMap.html

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. use the following groovy script:
  import javax.activation.MimetypesFileTypeMap;

  println MimetypesFileTypeMap.getDefaultFileTypeMap().getContentType(args[0])
2. $ groovy mime-type.groovy /tmp/test.html

Actual results:

Expected results:

Additional info:
The same issue does not exist in openjdk 1.8 as shipped with fedora 21. So it must have been fixed somehow in later versions.
Comment 3 Andrew John Hughes 2015-07-13 05:57:45 EDT
Confirmed; the bug is present on 6 & 7, but not 8.

$ /usr/lib/jvm/icedtea-6/bin/java RH1195203 ~/projects/httpdocs/redirect.html 

$ /usr/lib/jvm/icedtea-7/bin/java RH1195203 ~/projects/httpdocs/redirect.html 

$ /usr/lib/jvm/icedtea-8/bin/java RH1195203 ~/projects/httpdocs/redirect.html 
Comment 5 Andrew John Hughes 2016-01-11 12:44:32 EST
There are files missing from resources.jar in 6 & 7, presumably due to some mistake during the old build process.

$ ls resources-7/META-INF/
MANIFEST.MF  services/

$ ls resources-8/META-INF/
mailcap.default  MANIFEST.MF  mimetypes.default  services/
Comment 6 Andrew John Hughes 2016-01-12 13:26:49 EST
There are two parts to fixing this:

1. Fix the build bug which is preventing /META-INF/mimetypes.default and other files being included in resources.jar
2. Make use of the mime.types supplied by mailcap which is more comprehensive and e.g. allows Java to recognise Java source files.
Comment 7 Andrew John Hughes 2016-01-21 01:17:00 EST
Part 2 is done and that resolves this issue. The missing default file should be resolved upstream.
Comment 12 errata-xmlrpc 2016-05-10 16:29:54 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.