• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

404 with Tomcat Local server

 
Greenhorn
Posts: 22
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,"
I have got question-why when Im trying to enter "http://localhost:8082/test" or (im not sure which should I use-I think the first one is correct cause I made only /test endpoint) "http://localhost:8082/app_war_exploded/test"  I have got 404?
Configuration class: https://hastebin.com/ocosebogod.kotlin
ApiHello class (my @RestController) : https://hastebin.com/etugoqutop.kotlin
pom.xml https://hastebin.com/avukoxijev.xml
Im using Tomcat Local, I set server at http port 8082, jmx port 1098, I added exploded app:war to deployment, it should work but its not.
 
Saloon Keeper
Posts: 22784
153
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using Tomcat's default deployment mechanism, you would copy your WAR to TOMCAT_HOME/webapps/. You do not actually have to explode WAR files. Tomcat will do that as part of the deployment.

If you have a WAR file mywebapp.war, exploded to TOMCAT_HOME/webapps/mywebapp, then the URL for its /index.jsp page would be: http://localhost:8082/mywebapp/index.jsp.

If you do this and still get a "404" check the Tomcat logs to make sure that there was no error in deploying the webapp.
 
Jan Kaczmarek
Greenhorn
Posts: 22
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:If you are using Tomcat's default deployment mechanism, you would copy your WAR to TOMCAT_HOME/webapps/. You do not actually have to explode WAR files. Tomcat will do that as part of the deployment.

If you have a WAR file mywebapp.war, exploded to TOMCAT_HOME/webapps/mywebapp, then the URL for its /index.jsp page would be: http://localhost:8082/mywebapp/index.jsp.

If you do this and still get a "404" check the Tomcat logs to make sure that there was no error in deploying the webapp.



So i checked in Tomcat Manager and app is deployed. In Tomcat adres /webapps there is nothing about this app.
Tomcat logs from deploying (Edit)  

Im not sure if I understand it right but I think Im missing something in Spring configuration
 
Tim Holloway
Saloon Keeper
Posts: 22784
153
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generally we'd prefer that you paste in your log info in code tags on this site rather than having them as an off-site reference. It helps other people that may have the same problem and reduces the likelihood that the log info might get taken down before thay can read it.

As near as I can tell, the only webapp that Tomcat deployed was the "manager" app, and not your own app. That's less likely to be a Spring problem as it is that your "WAR" wasn't recognized as a WAR. If you just throw stuff under TOMCAT_HOME/webapps and it isn't conformant with the specifications for a WAR in the JEE standards doc, Tomcat will just ignore it.

I am, incidentally, referring to stand-alone Tomcat webapps. If you're using Spring Boot then things operate a little differently.
 
Jan Kaczmarek
Greenhorn
Posts: 22
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I edited my post and added code directly.
So this is my app manager at this localhost and it showing that "something" is deployed (I added this as a attachment to be sure its not going to vanish)
I manually created WAR file, it was automatically added to webapps folder. Im trying to access to http://localhost:8082/app-1.0-SNAPSHOT with index.jsp, without it, with /test etc and still throwing 404
tomcat.jpg
[Thumbnail for tomcat.jpg]
 
Marshal
Posts: 3257
487
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code and configuration files referenced in the original post ...


Configuration class:
ApiHello class (my @RestController):
pom.xml:

 
Bartender
Posts: 1979
13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe in IntelliJ, you can change the context path to anything you want.
Here is a reference:
https://mkyong.com/intellij/intellij-idea-run-debug-web-application-on-tomcat/

You can see from section 3.2 of  this reference . You can set localhost:8080/ for starting up the app.
 
Tim Holloway
Saloon Keeper
Posts: 22784
153
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Himai Minh wrote:I believe in IntelliJ, you can change the context path to anything you want.
Here is a reference:
https://mkyong.com/intellij/intellij-idea-run-debug-web-application-on-tomcat/

You can see from section 3.2 of  this reference . You can set localhost:8080/ for starting up the app.



That only works for IntelliJ. IntelliJ is simply deploying the IntelliJ web project according to Tomcat's rules.


The admin webapp shows that there are 3 webapps (Applications) deployed in that Tomcat server:

* The /admin webapp
* The /app_exploded webapp
* The /app-1.0-SNAPSHOT webapp

Those last 2 apps do not show in the catalina.out log sample you posted, so I have to assume that the log sample was incomplete, possibly taken before the other 2 apps deployed.

Note that the Application context paths in the admin page are all hyperlinks. Clicking on them should take you to the welcome page defined in web.xml. If no welcome page was defined, then you should get a directory listing of the root directory in the WAR.
 
Jan Kaczmarek
Greenhorn
Posts: 22
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, these two new webapps are result of manual addition of WAR to Tomcat server+Intellij deployment.
Hmm to be honest-I don't have got web.xml file in my project. I thought when I use annotations I don't need a web.xml file-so it looks like im wrong.
I just created it and now I need to fill it with something ( I will find some reasonably correct tutorial )-I hope this one is going to work, Im not ready for 3rd day with this problem.
 
Tim Holloway
Saloon Keeper
Posts: 22784
153
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You only need web.xml in 2 situations.

1. You need to configure a webapp with a parameter(s) that aren't supported by annotations. Such as stuff that doesn't fit into any of the class files. That might include the welcome page definition, though I'm not sure.

2. You need to override an annotation. This might happen if you're using a re-usable component whose default annotation value isn't what you want.

I use the term "web.xml" because before annotations web.xml was the sole place to setup server-independent deployment info. These days, there's a "virtual" web.xml that's build by assembling all the web-related annotations, reading and applying an actual web.xml file if it exists, and working with the composite result, so it's just easier to call all of it "web.xml". Technically, it's the "server-independent deployment descriptor" just as the Context XML element is Tomcat's "server-dependent deployment descriptor".
 
Jan Kaczmarek
Greenhorn
Posts: 22
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If someone else may have same problem-I just solved it. It was all about configuration in Config class.
I left getServletMappings() and getServletConfigClasses() with default, empty implementation. To make it works I just had to add "/" for servlet mapping and  point class with configuration. Thank you for all advice and help!  


 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic