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

前端 未结 2 2239
野的像风
野的像风 2021-01-19 14:54

My login.xhtml starts with:




        
相关标签:
2条回答
  • 2021-01-19 15:33

    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.

    0 讨论(0)
  • 2021-01-19 15:39

    XML Parsing Error: no root element found

    The ERROR occurs when your client send a request like below:

    curl -X GET --header 'Accept: application/json' 'http://192.168.1.249:9001/students/
    

    you can see in header like 'Accept: application/json' this means the client only accept the server response in JSON format.

    But Server produces a response type in XML content type and it will try to parse the XML to JSON. During this phase exception triggers.

    SOLUTION :

    Please change the response content type to application/json or Change the request header to 'Accept: application/xml'.

    Thanks.

    0 讨论(0)
提交回复
热议问题