Tomcat: status code 404 at the request of each application

Each application deployed on my Tomcat returns a status code 404 for every request I make. I tried several projects, helloworlds or skeletons, and each project behaves the same as the others:

enter image description here


Some of the projects I used are:

https://github.com/mwarman/skeleton-ws-spring-boot

https://spring.io/guides/gs/rest-service/ (I can run it using mvn spring-boot:run , but it does not work as deployed in Tomcat)

https://github.com/shagstrom/spring-mvc-hibernate-skeleton


I am using the latest Tomcat8 (8.0.27) , Oracle JDK 8 . I also tried Tomcat7 using OpenJDK 7 . Used Tomcats work on MAC and Debian . I create applications through mvn and through Intellij Idea .

Tomcats are clean, no configuration has been changed (except for adding the user manager-gui).

Since I tried many different projects, I do not think that the problem is in the code. Is this in Tomcat configuration? How can I make it work?

EDIT: server.xml code:

 <?xml version='1.0' encoding='utf-8'?> <Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> <!--APR library loader. Documentation at /docs/apr.html --> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> <!-- Prevent memory leaks due to use of particular java/javax APIs--> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> <!-- Global JNDI resources Documentation at /docs/jndi-resources-howto.html --> <GlobalNamingResources> <!-- Editable user database that can also be used by UserDatabaseRealm to authenticate users --> <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" /> </GlobalNamingResources> <Service name="Catalina"> <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <!-- Define an AJP 1.3 Connector on port 8009 --> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> <Engine name="Catalina" defaultHost="localhost"> <!-- Use the LockOutRealm to prevent attempts to guess user passwords via a brute-force attack --> <Realm className="org.apache.catalina.realm.LockOutRealm"> <!-- This Realm uses the UserDatabase configured in the global JNDI resources under the key "UserDatabase". Any edits that are performed against this UserDatabase are immediately available for use by the Realm. --> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" /> </Host> </Engine> </Service> </Server> 
+5
source share
2 answers

If you installed tomcat successfully, you may have seen the tomcat main page from http: // localhost: 8080 / URL. (Otherwise, you need to check tomcat installation first.)

I assume that you may have a built-in bank by placing the sites you mentioned above. I am wondering if you use the jar in your cat or not, because you mentioned the same result from any other projects. You need to apply a jar or war to your tomcat in order to apply a java program.

Here are the links I would like to help you.

War Packing: How to Make a War File in Eclipse

Tomcat - military file deployment: https://www.youtube.com/watch?v=9X9DA8oVodk

0
source

If the cat returns 404, you should check the following items:

  • verify deployment
  • check for errors in bootstratp and its initialization ServletContext.
  • check if your resource has been successfully opened.

To check these problems, you should set:

  • static resource test
  • web service resource test

this way you can eliminate pitfalls that you may encounter during application deployment

0
source

Source: https://habr.com/ru/post/1233484/


All Articles