HTTP Status 500–internal Server Error

Source: Internet
Author: User
Tags stack trace apache tomcat

Users.xml is present in the hard drive, but the prompt: The system cannot find the path specified.

Workaround:

Set the encoding format of a string

1 realpath = Urldecoder.decode (Realpath, "UTF-8");

Source:

1  Packagecn.itcast.utils;2 3 ImportJava.io.File;4 ImportJava.io.FileOutputStream;5 Importjava.io.IOException;6 Importjava.io.UnsupportedEncodingException;7 ImportJava.net.URL;8 ImportJava.net.URLDecoder;9 Ten Importorg.dom4j.Document; One Importorg.dom4j.DocumentException; A ImportOrg.dom4j.io.OutputFormat; - ImportOrg.dom4j.io.SAXReader; - ImportOrg.dom4j.io.XMLWriter; the  -  Public classXmlutils { -  -     Private StaticString filename = "Users.xml"; +  -      Public StaticDocument GetDocument ()throwsdocumentexception, unsupportedencodingexception { +  AURL url = xmlutils.class. getClassLoader (). getresource (filename); atString Realpath =Url.getpath (); -  -Realpath = Urldecoder.decode (Realpath, "UTF-8"); -  -Saxreader reader =NewSaxreader (); -         returnReader.read (NewFile (Realpath)); in     } -  to      Public Static voidWrite2xml (document Document)throwsIOException { +  -URL url = xmlutils.class. getClassLoader (). getresource (filename); theString Realpath =Url.getpath (); *  $Realpath = Urldecoder.decode (Realpath, "UTF-8");Panax Notoginseng  -OutputFormat format =outputformat.createprettyprint (); theXMLWriter writer =NewXMLWriter (NewFileOutputStream (Realpath), format); + Writer.write (document); A writer.close (); the     } +}

HTTP Status 500–internal Server Error

Type Exception Report

Message org.dom4j.documentexception:c:\program%20files\apache%20software%20foundation\tomcat%208.5\ Webapps\day09_user\web-inf\classes\users.xml (the system cannot find the path specified.) ) Nested exception:c:\program%20files\apache%20software%20foundation\tomcat%208.5\webapps\day09_user\web-inf\ Classes\users.xml (the system cannot find the path specified.) )

Description The server encountered an unexpected condition this prevented it from fulfilling the request.

Exception

java.lang.runtimeexception:org.dom4j.documentexception:c:\program%20files\apache%20software%20foundation\ Tomcat%208.5\webapps\day09_user\web-inf\classes\users.xml (the system cannot find the path specified.) ) Nested exception:c:\program%20files\apache%20software%20foundation\tomcat%208.5\webapps\day09_user\web-inf\ Classes\users.xml (the system cannot find the path specified.) ) Cn.itcast.dao.impl.UserDaoXmlImpl.find (userdaoxmlimpl.java:35) Cn.itcast.service.impl.BusinessServiceImpl.loginUser (businessserviceimpl.java:29) Cn.itcast.web.controller.LoginServlet.doGet (loginservlet.java:23) Cn.itcast.web.controller.LoginServlet.doPost ( loginservlet.java:38) Javax.servlet.http.HttpServlet.service (httpservlet.java:661) Javax.servlet.http.HttpServlet.service (httpservlet.java:742) Org.apache.tomcat.websocket.server.WsFilter.doFilter (wsfilter.java:52)

Root cause

Org.dom4j.documentexception:c:\program%20files\apache%20software%20foundation\tomcat%208.5\webapps\day09_user\ Web-inf\classes\users.xml (the system cannot find the path specified.) ) Nested exception:c:\program%20files\apache%20software%20foundation\tomcat%208.5\webapps\day09_user\web-inf\ Classes\users.xml (the system cannot find the path specified.) ) Org.dom4j.io.SAXReader.read (saxreader.java:266) cn.itcast.utils.XmlUtils.getDocument (xmlutils.java:28) Cn.itcast.dao.impl.UserDaoXmlImpl.find (USERDAOXMLIMPL.JAVA:18) Cn.itcast.service.impl.BusinessServiceImpl.loginUser (businessserviceimpl.java:29) Cn.itcast.web.controller.LoginServlet.doGet (loginservlet.java:23) Cn.itcast.web.controller.LoginServlet.doPost ( loginservlet.java:38) Javax.servlet.http.HttpServlet.service (httpservlet.java:661) Javax.servlet.http.HttpServlet.service (httpservlet.java:742) Org.apache.tomcat.websocket.server.WsFilter.doFilter (wsfilter.java:52)

Note The full stack trace of the root cause are available in the server logs.

Apache tomcat/8.5.24

HTTP Status 500–internal Server Error

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.