I get 404 while deploying Tomcat and calling localhost://8080

Answered

I have a simple HelloWorld Apache Wicket Project (Dont mind just a Test :D) . The Server starts and Artifact deploys successfully but  When i call localhost, I get 404 Error. I Changed the ApplicationContext to "/" but the Error keeps coming. Does anyone know why this happens? 

Greetings,

Xaver

 

3
48 comments

and moreover:

when I try to deploy this app on a running TomCat-instance with tomcat7 plugin the app is deployed and is seen in the list of running app (on tomcat-app-manager-page). But the app still behaves in the same way - with the same 404-error message and the same description.

I tried to recode this tiny app with jersey2 (org.glassfish.jersey), but it didn't change anything.

0
Avatar
Yaroslav Bedrov

Seems Manifest is missing. Could you please try to create new project using your git link, add mentioned changes and run it once again.

0

Ok, I did so. Made a new branch: https://github.com/Sergei-Gots/simple-JAX-RX-implementation/tree/jersey-2_org.glassfish.jersey

cloned it  making a new project. 

as I could imagine (it seems that is wrong) that there is no manifest is needed  at all:

if I try to add a MANIFEST-file I've been asked about a project's main class and class path in my app. But a main class should contain a main()-methond which is not intended to be within servlet-project. E.g. I I have now such a code in the only java class:

import javax.ws.rs.GET;
import javax.ws.rs.Path;

@Path("/hello")
public class HelloService {
@GET
public String getMsg() {
return "Hello World !! - Jersey 2";
}
}

I think there is some fundamental misunderstanding. But can't  get what is wrong and how should the MANIFEST.mf look like in the absence of the main-method(). To my sad, I haven't found any mention everywhere about MANIFEST.mf in tutorials and examples. There are only pom.xml and web.xml mentioned. 

In addition, I tried to create a new Project "Java-Enterprise"  with a template "REST-service JAX-RS resource". Unfortunately, with the same result.

What I know about MANIFEST.mf: it will be created usually in target/<applicationName>/META-INF/, so it will be generated however throughout the maven build.

It works in such way for my java-JSP projects. As I can see now it looks very abstract. E.g.:

Manifest-Version: 1.0
Created-By: IntelliJ IDEA
Built-By: serj
Build-Jdk: Oracle OpenJDK version 18.0.1

 

0
Avatar
Yaroslav Bedrov

I checked your branch. It works fine on my side with default Tomcat run configuration. I just started it and then opened "http://localhost:8080/simple_JAX_RX_war_exploded/rest/hello"

0

Ok, thank you for that.

But what  I could do wrong if I still get 404-erorr upon "http://localhost:8080/simple_JAX_RX_war_exploded/rest/hello"

(It's obviously the misspelled  by me  "simple_JAX_RS"... but ok::)))

App is deployed as it output from Server Log. and I have this simple_JAX_RX_war_exploded artifact seems to be deployed.

and to my happy  http://localhost:8080/manager/html

there is a corresponding row in the application list:

/simple_JAX_RX_implementation_war_exploded - Archetype Created Web Application true

P.S last rows of log in IntelliJ are:

 

Connected to server
[2022-06-07 10:59:56,789] Artifact simple-JAX-RX-implementation:war exploded: Artifact is being deployed, please wait...
07-Jun-2022 22:59:58.923 INFO [RMI TCP Connection(2)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
[2022-06-07 10:59:59,155] Artifact simple-JAX-RX-implementation:war exploded: Artifact is deployed successfully
[2022-06-07 10:59:59,156] Artifact simple-JAX-RX-implementation:war exploded: Deploy took 2,366 milliseconds
07-Jun-2022 23:00:06.302 INFO [Catalina-utility-2] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/opt/apache-tomcat-10.0.21/webapps/manager]
07-Jun-2022 23:00:06.588 INFO [Catalina-utility-2] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/opt/apache-tomcat-10.0.21/webapps/manager] has finished in [276] ms

0
Avatar
Yaroslav Bedrov

Could you please try lower Tomcat version (e.g. Tomcat 9)?

0

Ok). I tried to use Tomcat 9.0.63 creating a new Run Configuration.

It works. 

And I hope it will work with the Tomcat-10 release soon.

But it is sad that there aren't any warnings and cautions about using the latest Tomcat release. 

Many thanks!)

0
Avatar
Yaroslav Bedrov

You are welcome! Seems we have related request on YouTrack: https://youtrack.jetbrains.com/issue/IDEA-277823/Support-deployment-to-the-Tomcat-10-webapps-javaee-directory. Please vote for it and follow the updates.

0

I'm getting a 404 error

0

Hello,

Have you tried lower Tomcat version?

0

Hi, Yaroslav, can I get your advice or anyone help me
My problem is that I see that my artifact was deployed sucessfully but it gives 404 not found
I am using tomcat 9,0,71 and I am pretty sure that problem is not about the link, because I've already read previous 40 comments

0

Is it reproducible with some sample project, so I could check it on my side?

0

Do you want to get screenshots or full directory?

 

0

It would be better to have project itself, so I could fully check it on my side.

0

Thanks for the example. I couldn't find what is wrong there. You may try to use project from this article as a template: https://mkyong.com/spring-mvc/spring-mvc-hello-world-example/

0

@... ty for your attemt of finding out the problem of my learning proccess! I really appreciate that, and I checked out your source, very helpful TY TY TY!

0

You are welcome!

0

Please sign in to leave a comment.