Intellij idea + Tomcat workaround for HTTP status 404 error

Source: Internet
Author: User
Tags tomcat server



I'm going to make a POC, get an old project, use the war exploded to deploy to the native Tomcat (version 8.5)



When you start Tomcat by IntelliJ idea, you find that the login page of the system is http-status-404 error, and when you open http://localhost:8080 directly in the browser, you can open the Tomcat welcome page, It means Tomcat is up, but it doesn't load the WebApps directory properly.



Even more strangely, the startup script under Tomcat's Bin directory can start normally, either by double-clicking Startup.bat or by using Catalina.bat run under the directory's CMD to start the project normally.






If you have a similar situation of friends, you can pay attention to the two startup mode at the start of the log environment variables, especially catalina_home.



Because the value of this variable is different on my machine when it is started in two ways, Catalina_home is the Tomcat directory where the bin is located when it is started by the bat script in the bin directory;



But when you start with IntelliJ idea, the value of the variable changes to: C:\Users\Cratical\. Intellijidea2017.1\system\tomcat\unnamed_test-project_3_0_4



Two directories under the Conf folder, the folder inside the name and number of configuration files are the same, through the comparison, found in the Conf directory, Server.xml content There are some differences, note this line






autodeploy= "true" deployonstartup= " False "deployignore=" ^ (?! (manager) | (Tomee) $). * ">






Because in IntelliJ idea, a war format artifact can modify the location of the output directory, the default is the target folder under the current project root directory, if you use IntelliJ directly When idea started Tomcat, the WebApps directory under the Tomcat directory was unable to find the associated deployment folder.



IntelliJ idea is to achieve this goal by generating one of its own catalina_home, modifying the appbase in Server.xml.






Go back to that line of configuration, note that the deployignore property, my web directory name is exactly matched by the above regular expression, so Tomcat is directly ignored when loading, resulting in the 404 error.






The meanings of the various configurations in Tomcat Server.xml, see: http://www.importnew.com/17124.html



Intellij idea + Tomcat resolution for HTTP status 404 error


Related Article

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.