Opening Facelets page errors with "This XML file does not appear to have any style information associated with it."

I'm trying to run my Eclipse JSF project on Apache Tomcat on other computer. I created a WAR file with this tutorial. However, when I deploy the WAR and open the Facelet page in Firefox, I'm getting only the following error message:

This XML file does not appear to have any style information associated with it. The document tree is shown below.

This my first time when I try run my JSF app without Eclipse. How is this caused and how can I solve it?

I'm actually trying to open the following Facelet page:

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition template="/WEB-INF/templates/template_a.xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets">
    <ui:define name="title">
        tytol
    </ui:define>
</ui:composition>

Answers


This XML file does not appear to have any style information associated with it. The document tree is shown below.

You will get this error in the client side when the client (the webbrowser) for some reason interprets the HTTP response content as text/xml instead of text/html and the parsed XML tree doesn't have any XML-stylesheet. In other words, the webbrowser incorrectly parsed the retrieved HTTP response content as XML instead of as HTML due to the wrong or missing HTTP response content type.

In case of JSF/Facelets files which have the default extension of .xhtml, that can in turn happen if the HTTP request hasn't invoked the FacesServlet and thus it wasn't able to parse the Facelets file and generate the desired HTML output based on the XHTML source code. Firefox is then merely guessing the HTTP response content type based on the .xhtml file extension which is in your Firefox configuration apparently by default interpreted as text/xml.

You need to make sure that the HTTP request URL, as you see in browser's address bar, matches the <url-pattern> of the FacesServlet as registered in webapp's web.xml, so that it will be invoked and be able to generate the desired HTML output based on the XHTML source code. If it's for example *.jsf, then you need to open the page by /some.jsf instead of /some.xhtml. Alternatively, you can also just change the <url-pattern> to *.xhtml. This way you never need to fiddle with virtual URLs.

See also:

Note thus that you don't actually need a XML stylesheet. This all was just misinterpretation by the webbrowser while trying to do its best to make something presentable out of the retrieved HTTP response content. It should actually have retrieved the properly generated HTML output, Firefox surely knows precisely how to deal with HTML content.


If you are using Eclipse there are plenty of Simple way to create war .. 1- Right Click on your project 2- Then choose Export->WAR File 3- It will show you Web Project Name and now give destination where you will want to save war file. 4- If you want to export source file check Export Source File option. 5-Then click on finish .

Thats it you will get your project war file and copy this war and put in Tomcat Webapps directory and start the Server.


Need Your Help

How to handle response encoding from urllib.request.urlopen()

python regex encoding urllib

I'm trying to search a webpage using regular expressions, but I'm getting the following error:

Set HTML5 doctype with XSLT

html5 xslt doctype xhtml-transitional xdv

How would I cleanly set the doctype of a file to HTML5 &lt;!DOCTYPE html&gt; via XSLT (in this case with collective.xdv)