Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML Parsing Error: no element found Location: http://localhost:8081/web-app/pages/login.xhtml Line Number 1, Column 1: ^

My login.xhtml starts with:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

I am using Java 8, JSF, Primefaces, Maven, Tomcat8. I think that something is wrong with my configuration e.g. servlets and web.xml.

like image 579
Skyware Avatar asked Dec 25 '22 06:12

Skyware


1 Answers

XML Parsing Error: no element found Location: [...] Line Number 1, Column 1

To the point, this exact error means that the webbrowser retrieved an entirely empty response while it is being instructed to interpret the response as XML, usually via the Content-Type header such as application/xhtml+xml or application/xml, or if absent, via the file extension in URL such as .xhtml or .xml.

Given that this happens while requesting a JSF login page, this strongly suggests that it contained a syntax/runtime error and that the webapp doesn't have error handling correctly configured. Apparently error pages themselves are also blocked behind a login/security constraint, causing the server being unable to present a "normal" error page with all exception detail and therefore return a completely empty response.

Your best bet is reading the server logs for the actual exception and/or running a debugger and/or creating a JSF exception handler which explicitly logs exceptions to server log (just in case you couldn't find exceptions and thus they appear to be swallowed). Once having the actual exception at hands, it's usually a matter of using the exception type + message + 1st line as keywords to find clues on the Internet.

like image 127
BalusC Avatar answered Mar 31 '23 21:03

BalusC