6

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

enter image description here


Some of the projects I've used:

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

https://spring.io/guides/gs/rest-service/ (I can run it with mvn spring-boot:run but it's not working as deployed to Tomcat)

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


I'm using the newest Tomcat8 (8.0.27), Oracle JDK 8. I've also tried Tomcat7 with OpenJDK 7. Used Tomcats are running on MAC and Debian. I've build apps via mvn and via Intellij Idea.

Tomcats are clean, no configs are changed (except adding manager-gui user).

Since I've tried many different projects, I don't believe the problem is in the code. Is it in Tomcat's config? How can I get it to 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> 
11
  • 1
    How are you deploying your projects in tomcat? Are you sure they're being deployed by checking the logs? Commented Oct 11, 2015 at 21:48
  • Are the applications listing in the Tomcat Manager, and are they started? Is the HOME page working (http://localhost:8080/)? Commented Oct 11, 2015 at 21:50
  • @LuiggiMendoza I'm deploying it via Idea or via manager. From logs: "Artifact is deployed successfully" confirms that deploy was successful. Commented Oct 11, 2015 at 22:02
  • @Andreas HOME page is working, my applications listed in manager are running. Commented Oct 11, 2015 at 22:04
  • @2rec are applications in your tomcat's webapps folder ? Can you post your conf/server.xml ? Commented Oct 12, 2015 at 8:36

3 Answers 3

0

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

I guess you may have built jar by fallowing above sites that you mentioned. I am wondering whether you applied the jar into your tomcat or not because you mentioned same result from any other projects. You need to apply jar or war into your tomcat in order to apply java program.

Here are links that I wish they might be helpful to you.

Packaging war : How to make war file in Eclipse

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the reply but I am able to create and deploy war from these projects, also Tomcat's index page and manager are ok. Deploy is successful and project is running.
0

If tomcat returns 404 response, you have to check those points:

  • check if your deploy was correct
  • check if war bootstrap and its ServletContext initialization has no errors
  • check if the resource your invoking was successfully exposed.

To test these issues you have to expose:

  • static resource test
  • web service resource test

in this way you can exclude the pitfalls you can meet during application deploy

Comments

0

status code 404

 <!-- 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> 

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.