Issue
I saw in a tutorial that he wanted to create a Spring MVC app and he also created the following files, but the continuation of the tutorial was in eclipse and I work with IntelliJ and I configured tomcat and when I run the program on it, the tomcat starts but the HTML page does not open.
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>spring-org.isoft.mvc-demo</display-name>
<absolute-ordering />
<servlet>
<servlet-name>isoftDispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>org/isoft/mvc/configuration/spring-mvc-demo-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>isoftDispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
spring-mvc-demo-servlet.xml :
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:component-scan base-package="org.isoft" />
<mvc:annotation-driven/>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="org/isoft/mvc/view/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
HomeController:
@Controller
public class HomeController {
@RequestMapping("/")
public String showHomePage(){
System.out.println("Home Page started!");
return "home-page";
}
}
home-page.jsp:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=yes, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Home Page</title>
</head>
<body>
<h1>The first Spring MVC app</h1>
</body>
</html>
output:
"C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin\catalina.bat" run
[2022-04-25 02:51:42,855] Artifact artifact: Waiting for server connection to start artifact deployment…
Using CATALINA_BASE: "C:\Users\User\AppData\Local\JetBrains\IntelliJIdea2021.3\tomcat\8e74877d-73ba-4dbb-a1e4-c6dfbb2f5fb3"
Using CATALINA_HOME: "C:\Program Files\Apache Software Foundation\Tomcat 9.0"
Using CATALINA_TMPDIR: "C:\Program Files\Apache Software Foundation\Tomcat 9.0\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk-17.0.1"
Using CLASSPATH: "C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin\bootstrap.jar;C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin\tomcat-juli.jar"
Using CATALINA_OPTS: ""
NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
25-Apr-2022 14:51:44.254 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/9.0.62
25-Apr-2022 14:51:44.258 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Mar 31 2022 14:34:15 UTC
25-Apr-2022 14:51:44.258 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.62.0
25-Apr-2022 14:51:44.259 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10
25-Apr-2022 14:51:44.259 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.0
25-Apr-2022 14:51:44.259 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
25-Apr-2022 14:51:44.259 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk-17.0.1
25-Apr-2022 14:51:44.259 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 17.0.1+12-LTS-39
25-Apr-2022 14:51:44.260 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
25-Apr-2022 14:51:44.260 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\User\AppData\Local\JetBrains\IntelliJIdea2021.3\tomcat\8e74877d-73ba-4dbb-a1e4-c6dfbb2f5fb3
25-Apr-2022 14:51:44.260 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 9.0
25-Apr-2022 14:51:44.263 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
25-Apr-2022 14:51:44.273 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
25-Apr-2022 14:51:44.273 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED
25-Apr-2022 14:51:44.273 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
25-Apr-2022 14:51:44.274 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
25-Apr-2022 14:51:44.274 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\User\AppData\Local\JetBrains\IntelliJIdea2021.3\tomcat\8e74877d-73ba-4dbb-a1e4-c6dfbb2f5fb3\conf\logging.properties
25-Apr-2022 14:51:44.274 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
25-Apr-2022 14:51:44.274 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
25-Apr-2022 14:51:44.274 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
25-Apr-2022 14:51:44.275 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
25-Apr-2022 14:51:44.275 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.password.file=C:\Users\User\AppData\Local\JetBrains\IntelliJIdea2021.3\tomcat\8e74877d-73ba-4dbb-a1e4-c6dfbb2f5fb3\jmxremote.password
25-Apr-2022 14:51:44.275 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.access.file=C:\Users\User\AppData\Local\JetBrains\IntelliJIdea2021.3\tomcat\8e74877d-73ba-4dbb-a1e4-c6dfbb2f5fb3\jmxremote.access
25-Apr-2022 14:51:44.275 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
25-Apr-2022 14:51:44.276 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
25-Apr-2022 14:51:44.276 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
25-Apr-2022 14:51:44.276 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
25-Apr-2022 14:51:44.276 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\User\AppData\Local\JetBrains\IntelliJIdea2021.3\tomcat\8e74877d-73ba-4dbb-a1e4-c6dfbb2f5fb3
25-Apr-2022 14:51:44.276 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 9.0
25-Apr-2022 14:51:44.276 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 9.0\temp
25-Apr-2022 14:51:44.285 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [1.2.32] using APR version [1.7.0].
25-Apr-2022 14:51:44.285 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
25-Apr-2022 14:51:44.285 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
25-Apr-2022 14:51:44.291 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1n 15 Mar 2022]
25-Apr-2022 14:51:44.742 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8081"]
25-Apr-2022 14:51:44.788 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [887] milliseconds
25-Apr-2022 14:51:44.893 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
25-Apr-2022 14:51:44.893 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.62]
25-Apr-2022 14:51:44.910 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8081"]
25-Apr-2022 14:51:44.996 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [207] milliseconds
Connected to server
[2022-04-25 02:51:45,181] Artifact artifact: Artifact is being deployed, please wait…
[2022-04-25 02:51:45,202] Artifact artifact: Error during artifact deployment. See server log for details.
[2022-04-25 02:51:45,203] Artifact artifact: com.intellij.javaee.oss.admin.jmx.JmxAdminException: com.intellij.execution.ExecutionException: C:\Users\User\IdeaProjects\spring_demo1\out\artifacts\artifact not found for the web module.
Solution
The IDE tries to run the application using an artifact at \spring_demo1\out\artifacts\artifact but I think it is the case only if you do not use Gradle or Maven. But since you use Spring Framework I believe you using one of them. In the case of Gradle, you have artifacts in /build/lib folder, and in the case of maven in the /target folder.
So something is messed up with the configuration.
- Potentially IDE does not recognize your project as Gradle/maven.
- Your 'build artifact' job from the configuration picture doesn't work, or creates an artifact in a different place.
Answered By - Alex
Answer Checked By - Marie Seifert (JavaFixing Admin)