Home > database >  Spring App is not running from Intellij with Tomcat Server
Spring App is not running from Intellij with Tomcat Server

Time:09-17

If I run my spring app from Intellij with Tomcat Server it gives me:

HTTP Status 404 – Not Found
Type Status Report

Message The requested resource [/] is not available

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

Apache Tomcat/9.0.52

But If I put my app.war in tomcat/webapps/ as ROOT.war it works perfectly.

I have problems only when try to run from Intellij

This is the configuration:

server

This is the deployment:

deploy

And this is the output:

C:\apache-tomcat-9.0.52\bin\catalina.bat run
[2021-08-24 02:50:39,974] Artifact myappname:war exploded: Waiting for server connection to start artifact deployment...
Using CATALINA_BASE:   "C:\Users\Main\AppData\Local\JetBrains\IntelliJIdea2021.2\tomcat\f74e8856-a9b4-4e50-9d59-c901731f3dc7"
Using CATALINA_HOME:   "C:\apache-tomcat-9.0.52"
Using CATALINA_TMPDIR: "C:\apache-tomcat-9.0.52\temp"
Using JRE_HOME:        "C:\Program Files\Java\jdk-10.0.2"
Using CLASSPATH:       "C:\apache-tomcat-9.0.52\bin\bootstrap.jar;C:\apache-tomcat-9.0.52\bin\tomcat-juli.jar"
Using CATALINA_OPTS:   ""
24-Aug-2021 14:50:40.602 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/9.0.52
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jul 31 2021 04:12:17 UTC
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.52.0
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows 10
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            10.0
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             C:\Program Files\Java\jdk-10.0.2
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           10.0.2 13
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            "Oracle Corporation"
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         C:\Users\Main\AppData\Local\JetBrains\IntelliJIdea2021.2\tomcat\f74e8856-a9b4-4e50-9d59-c901731f3dc7
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         C:\apache-tomcat-9.0.52
24-Aug-2021 14:50:40.604 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
24-Aug-2021 14:50:40.604 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
24-Aug-2021 14:50:40.604 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED
24-Aug-2021 14:50:40.604 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
24-Aug-2021 14:50:40.604 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
24-Aug-2021 14:50:40.604 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\Main\AppData\Local\JetBrains\IntelliJIdea2021.2\tomcat\f74e8856-a9b4-4e50-9d59-c901731f3dc7\conf\logging.properties
24-Aug-2021 14:50:40.604 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
24-Aug-2021 14:50:40.604 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
24-Aug-2021 14:50:40.604 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.password.file=C:\Users\Main\AppData\Local\JetBrains\IntelliJIdea2021.2\tomcat\f74e8856-a9b4-4e50-9d59-c901731f3dc7\jmxremote.password
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.access.file=C:\Users\Main\AppData\Local\JetBrains\IntelliJIdea2021.2\tomcat\f74e8856-a9b4-4e50-9d59-c901731f3dc7\jmxremote.access
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\Main\AppData\Local\JetBrains\IntelliJIdea2021.2\tomcat\f74e8856-a9b4-4e50-9d59-c901731f3dc7
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\apache-tomcat-9.0.52
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\apache-tomcat-9.0.52\temp
24-Aug-2021 14:50:40.607 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [1.2.30] using APR version [1.7.0].
24-Aug-2021 14:50:40.607 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
24-Aug-2021 14:50:40.607 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
24-Aug-2021 14:50:40.610 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1k  25 Mar 2021]
24-Aug-2021 14:50:40.750 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
24-Aug-2021 14:50:40.763 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [279] milliseconds
24-Aug-2021 14:50:40.804 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
24-Aug-2021 14:50:40.804 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.52]
24-Aug-2021 14:50:40.812 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
24-Aug-2021 14:50:40.823 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [59] milliseconds
Connected to server
[2021-08-24 02:50:41,210] Artifact myappname:war exploded: Artifact is being deployed, please wait...
24-Aug-2021 14:50:45.369 INFO [RMI TCP Connection(3)-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.
[2021-08-24 02:50:45,523] Artifact myappname:war exploded: Artifact is deployed successfully
[2021-08-24 02:50:45,523] Artifact myappname:war exploded: Deploy took 4,313 milliseconds
24-Aug-2021 14:50:50.816 INFO [Catalina-utility-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\apache-tomcat-9.0.52\webapps\manager]
24-Aug-2021 14:50:50.851 INFO [Catalina-utility-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\apache-tomcat-9.0.52\webapps\manager] has finished in [35] ms

I want to run my app from the root: localhost:8080/.

Why I receive 404 - Not Found from Tomcat? And how to fix it?

If you need more details please tell me.

Version of Intellij IDEA: 2021.2 Ultimate Edition

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <version>2.5.3</version>
</dependency>

P.S.: I think something is not deployed right. Because after deploy, in console don't appears that big SPRING logo and logs about initializing. Or this is not necessarily?

CodePudding user response:

I found the solution for my problem.

My problem was solved by removing everything from Run/Debug Configuration -> Before Launch

Also instead of what was there I added maven clean install command.

  • Related