WARNING: JSF1091: No mime type could be found for file dynamiccontent
Asked Answered
S

7

11

I get the following warning under eclipse :

WARNING: JSF1091: No mime type could be found for file dynamiccontent. To resolve this, add a mime-type mapping to the applications web.xml

This error is caused when I post a picture

below primefaces composant :

<p:graphicImage  value="#{bean.image}"/>

Java Bean :

private StreamedContent image;

// Getter
public StreamedContent getImage() {
    try {
        JFreeChart jfreechart = ChartFactory.createPieChart3D("",
                        createDataset(), true, true, false);

        PiePlot3D plot = (PiePlot3D) jfreechart.getPlot();

        File chartFile = new File("dynamichart");
        ChartUtilities.saveChartAsPNG(chartFile, jfreechart, 375, 300);
        chartImage = new DefaultStreamedContent(new FileInputStream(
                        chartFile), "image/png");
        return chartImage;
    } catch (Exception e) {
        e.printStackTrace();
        return new DefaultStreamedContent();
    }
}

// generate data for image
public static PieDataset createDataset() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("A",10);
    dataset.setValue("B", 11);
    dataset.setValue("C", 80);
    dataset.setValue("D", 12);
    return dataset;
}
Situated answered 20/2, 2013 at 15:51 Comment(7)
Maybe your filename must be dynamichart.png (note the suffix of the filename).Nob
Share with us more of your xhtml code. Where you are using this graphic image component?Madoc
+1 I get this message as well. I am interested in why, but then I never researched this because it doesn't seem to affect anything.Theretofore
@maple_shaft, never researched it? This is all you man :). This from the primefaces bug trackerArmbruster
@Armbruster HAHAHAA!! That's funny! C'mon man, how am I supposed to remember what I did a year ago? ;-)Theretofore
@ÖmerFarukAlmalı I have not used more than the indicated component.Situated
@LuiggiMendoza I still have the same WARNING with 'dynamichart.png' :(Situated
S
5

I found one solution.

by using the latest version of primefaces (3.5).

<dependency>  
    <groupId>org.primefaces</groupId>  
    <artifactId>primefaces</artifactId>  
    <version>3.5</version>  
</dependency> 

but there will unpleasant changes in IHM

Situated answered 21/2, 2013 at 9:28 Comment(0)
D
7

Try adding the following to your web.xml file

<mime-mapping>
    <extension>jsp <!--{or the extension of file}--></extension>
    <mime-type>text/html</mime-type>
  </mime-mapping>
Dibranchiate answered 23/11, 2013 at 14:16 Comment(0)
H
7

I just want to share my experience with a similar problem, I use maven, netbeans and payara. Once I had this warning:

WARNING No mime type could be found for file fontawesome-webfont.woff is logged

The solution to remove this warning was adding the following code to the web.xml:

<mime-mapping>
    <extension>woff</extension>
    <mime-type>application/font-woff</mime-type>
</mime-mapping>

Note: I had the same warning with different files, those files had different extensions (woff, eot, woff2 and ttf). The solution to this was to replace woff in <extension> with one of the extensions previously mentioned.

I hope that my answer will help someone someday.

PS : I found the solution in this page.

Humanist answered 15/8, 2017 at 15:1 Comment(0)
S
5

I found one solution.

by using the latest version of primefaces (3.5).

<dependency>  
    <groupId>org.primefaces</groupId>  
    <artifactId>primefaces</artifactId>  
    <version>3.5</version>  
</dependency> 

but there will unpleasant changes in IHM

Situated answered 21/2, 2013 at 9:28 Comment(0)
V
1

I had the JSF1091 warning for http://example.org  and javascript:; as well, with Icefaces instead of Primefaces.

Changing

<ice:outputLink onclick="..." value="javascript:;">...</ice:outputLink>

to

<ice:outputLink onclick="..." value="/some/url">...</ice:outputLink>

silenced the warning about javascript:;.

Changing

<ice:outputLink value="http://example.org"/>

to

<a href="http://example.org"/>

fixed it for the URL.

Valladolid answered 13/9, 2013 at 18:51 Comment(0)
E
1

Although I post this answer after a while probably it will be useful for other developers who face this problem.

To avoid that annoying warning from above add the following code into your web.xml :

<mime-mapping>
<extension>png</extension>
<mime-type>image/png</mime-type>
</mime-mapping>

For more details please check:

http://blog.eisele.net/2011/01/weblogic-10340-oepe-maven-primefaces.html

Entero answered 5/12, 2014 at 14:36 Comment(0)
M
1

For Spring Boot 2:

@Configuration
public class JsfConfigurationMimeMapper implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> {

    @Override
    public void customize(ConfigurableServletWebServerFactory factory) {
        MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
        mappings.add("xsd", "text/xml; charset=utf-8");
        mappings.add("otf", "font/opentype");
        mappings.add("ico", "image/x-icon");
        mappings.add("svg", "image/svg+xml");
        mappings.add("eot", "application/vnd.ms-fontobject");
        mappings.add("ttf", "application/x-font-ttf");
        mappings.add("woff", "application/x-font-woff");
        mappings.add("woff2", "application/x-font-woff2");
        mappings.add("xhtml", "application/xml");
        factory.setMimeMappings(mappings);

    }
}
Margarethe answered 13/4, 2020 at 1:57 Comment(1)
While this code may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please edit your answer to add explanations and give an indication of what limitations and assumptions apply.Lynnett
C
0

if you have spring you can also have (I added most of fa-Icons):

@Configuration
public class JsfConfigurationMimeMapper implements EmbeddedServletContainerCustomizer {

     @Override
     public void customize(ConfigurableEmbeddedServletContainer container) {
        MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
        mappings.add("xsd", "text/xml; charset=utf-8");
        mappings.add("otf", "font/opentype");
        mappings.add("ico", "image/x-icon");
        mappings.add("svg", "image/svg+xml");
        mappings.add("eot", "application/vnd.ms-fontobject");
        mappings.add("ttf", "application/x-font-ttf");
        mappings.add("woff", "application/x-font-woff");
        mappings.add("woff2", "application/x-font-woff2");
        mappings.add("xhtml", "application/xml");
        container.setMimeMappings(mappings);
    }
}
Chiao answered 30/8, 2017 at 8:9 Comment(2)
This is when you use Spring AND an embedded container, so you are most likely running SpringBoot?Hakan
yeah exactly, this is also a solution if you are using SpringBoot. an alternative for those who are not using web.xml. basically you are adding your maps on MimeMappings.Chiao

© 2022 - 2024 — McMap. All rights reserved.