Weblogic mime type configuration Steps

Few times its seen that when weblogic is used to serve as a webserver or used to download files via some deployed application, the file comes corrupted or with junk characters.
We had the same issue where excel files were not able to render properly instead it will open in html format rendering all junk characters, to avoid this situation we have followed below step to fix weblogic mime type configuration issue.

Error:

Mime Type Missing Error in Weblogic

Mime Type Missing Error in Weblogic while opening a excel file

In weblogic 5.x and 6.x there use to be a property where you can set the mimetypes on the fly but thease are depricated in later versions. You can read more about the weblogic 5.x,6.x mimetype here.
For the newer version of weblogic please use the steps provided below.
Note: We have used weblogic 11g for the example here.

1. Here we are creating a domain wide mime types mimemappings.properties file to define a type for the “.extension” extension.

2. Login to admin console as admin user.
3. Navigate to Your Domain > Web Applications

Weblogic Admin Console Domain

Weblogic Admin Console Domain

4. Make sure below path to properties file is present, if not please add it.

Weblogic Mime Types Property location

Weblogic Mime Types Property location

5. Login to the weblogic host machine and cd to /HOME/Middleware/user_projects/domains/Your_domain/config folder. create a new mimemappings.properties file and add entries like below to register the new file extension.

xlsx=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

docx=application/vnd.openxmlformats-officedocument.wordprocessingml.document

Sample Entries List to refer:

Note: Care shall be taken while putting the mimetypes. The format needs to be used is extension=mime-type as given above in bold letters, below example mime-types are in mime-type=extension format and only for reference. Do not copy paste blindly.

application/envoy=evy
application/fractals=fif
application/futuresplash=spl
application/hta=hta
application/internet-property-stream=acx
application/mac-binhex40=hqx
application/msword=doc
application/octet-stream=*
application/oda=oda
application/olescript=axs
application/pdf=pdf
application/pics-rules=prf
application/pkcs10=p10
application/pkix-crl=crl
application/postscript=ps
application/rtf=rtf
application/set-payment-initiation=setpay
application/set-registration-initiation=setreg
application/vnd.ms-excel=xls
application/vnd.ms-outlook=msg
application/vnd.ms-pkicertstore=sst
application/vnd.ms-pkiseccat=cat
application/vnd.ms-pkistl=stl
application/vnd.ms-powerpoint=ppt
application/vnd.ms-project=mpp
application/vnd.ms-works=wps
application/winhlp=hlp
application/x-bcpio=bcpio
application/x-cdf=cdf
application/x-compress=z
application/x-compressed=tgz
application/x-cpio=cpio
application/x-csh=csh
application/x-director=dir
application/x-dvi=dvi
application/x-gtar=gtar
application/x-hdf=hdf
application/x-internet-signup=isp
application/x-iphone=iii
application/x-javascript=js
application/x-gzip=gz
application/x-latex=latex
application/x-msaccess=mdb
application/x-mscardfile=crd
application/x-msclip=clp
application/x-msdownload=dll
application/x-msmediaview=mvb
application/x-msmetafile=wmf
application/x-msmoney=mny
application/x-mspublisher=pub
application/x-msschedule=scd
application/x-msterminal=trm
application/x-mswrite=wri
application/x-netcdf=cdf
application/x-perfmon=pma
application/x-pkcs12=pfx
application/x-pkcs7-certificates=spc
application/x-pkcs7-certreqresp=p7r
application/x-pkcs7-mime=p7m
application/x-pkcs7-signature=p7s
application/x-sh=sh
application/x-shar=shar
application/x-shockwave-flash=swf
application/x-stuffit=sit
application/x-sv4cpio=sv4cpio
application/x-sv4crc=sv4crc
application/x-tar=tar
application/x-tcl=tcl
application/x-tex=tex
application/x-texinfo=texi
application/x-troff=tr
application/x-troff-man=man
application/x-troff-me=me
application/x-troff-ms=ms
application/x-ustar=ustar
application/x-wais-source=src
application/x-x509-ca-cert=cer
application/ynd.ms-pkipko=pko
application/zip=zip
application/json=json
audio/basic=au
audio/mid=mid
audio/mpeg=mp3
audio/x-aiff=aiff
audio/x-mpegurl=m3u
audio/x-pn-realaudio=ram
audio/x-wav=wav
image/bmp=bmp
image/cis-cod=cod
image/gif=gif
image/ief=ief
image/jpeg=jpg
image/pipeg=jfif
image/svg+xml=svg
image/tiff=tif
image/x-cmu-raster=ras
image/x-cmx=cmx
image/x-icon=ico
image/x-portable-anymap=pnm
image/x-portable-bitmap=pbm
image/x-portable-graymap=pgm
image/x-portable-pixmap=ppm
image/x-rgb=rgb
image/x-xbitmap=xbm
image/x-xpixmap=xpm
image/x-xwindowdump=xwd
image/png=png
message/rfc822=mht
text/css=css
text/h323=323
text/html=html
text/iuls=uls
text/plain=txt
text/richtext=rtx
text/scriptlet=sct
text/tab-separated-values=tsv
text/webviewhtml=htt
text/x-component=htc
text/x-setext=etx
text/x-vcard=vcf
video/mpeg=mpeg
video/quicktime=mov
video/x-la-asf=lsf
video/x-ms-asf=asf
video/x-msvideo=avi
video/x-sgi-movie=movie
x-world/x-vrml=xof
application/xhtml+xml=xhtml
application/vnd.openxmlformats-officedocument.wordprocessingml.template=dotx
application/vnd.openxmlformats-officedocument.wordprocessingml.document=docx
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet=xlsx
application/vnd.openxmlformats-officedocument.presentationml.presentation=pptx
# Defines some mapping between MIME type and filename extention

6. After adding all the mimetypes save the file and restart the weblogic server and check.

7. Few tips to remember, if you want to remove a mime type from the server default mimetypes you can just leave blank after the extension text. Example :

xlsm=
8. Make sure you do a complete temp and cache cleanup before you restart the weblogic servers and clean browser cache before you test the mimetype settings.

Leave a Reply

  1. Hi,

    First, thanks for this post, it help me a lot.

    I tried this solution but it didn’t work, so I did a change and works for me, the solution is extension=mime-type ,not mime-type=extension.

    svg=image/svg+xml
    # Defines some mapping between filename extension and MIME type: extension=mime-type

    I took the idea from this place:
    https://community.oracle.com/thread/2283179?tstart=0

    Regards,

    • Thanks jorgitoito. It was only sample values for reference on which mime-type is for which extension. It is good that you pointed out that its not clear. I have added a new note before the example so that other readers will not copy paste directly.

  2. Hi Ramakanta,

    I have the same problem, the file comes corrupted or with junk characters at begin of file and when I open the file with notepad++ and remove the fisrt eight characters I can open the “.xls”.

    later 30 minutes I apply your changes of mimemappings.properties but didn’t work.

    later away I read the next post:

    https://community.oracle.com/thread/1100188?tstart=0

    And finally, I put:

    response.reset();

    before the line of :

    response.setContentType(“application/vnd.ms-excel”);

    and its working fine!