After upgrading my environment from Apache Tomcat 6.0.37 to 8.0.44 and Java from 1.7.0_45 to 1.8.0_131, one of my webapps will not deploy while the others run without issue.
My development environment is as follows.
Product Version: NetBeans IDE 8.2 (Build 201609300101)
Updates: NetBeans IDE is updated to version NetBeans 8.2 Patch 2
Java: 1.8.0_131; Java HotSpot(TM) 64-Bit Server VM 25.131-b11
Runtime: Java(TM) SE Runtime Environment 1.8.0_131-b11
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
User directory: C:\Users\heinzk\AppData\Roaming\NetBeans\8.2
Cache directory: C:\Users\heinzk\AppData\Local\NetBeans\Cache\8.2
When I attempt to run or debug my problematic webapp (which worked fine before these upgrades), I get the following server output.
Using CATALINA_BASE: "C:\Program Files\Apache Software Foundation\Tomcat 8.0"
Using CATALINA_HOME: "C:\Program Files\Apache Software Foundation\Tomcat 8.0"
Using CATALINA_TMPDIR: "C:\Program Files\Apache Software Foundation\Tomcat 8.0\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_131"
Using CLASSPATH: "C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin\bootstrap.jar;C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin\tomcat-juli.jar"
Listening for transport dt_shmem at address: tomcat_shared_memory_id
20-Jun-2017 12:52:55.059 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.0.44
20-Jun-2017 12:52:55.064 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: May 10 2017 17:21:09 UTC
20-Jun-2017 12:52:55.064 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.0.44.0
20-Jun-2017 12:52:55.064 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 7
20-Jun-2017 12:52:55.064 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 6.1
20-Jun-2017 12:52:55.065 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
20-Jun-2017 12:52:55.065 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk1.8.0_131\jre
20-Jun-2017 12:52:55.065 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_131-b11
20-Jun-2017 12:52:55.065 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
20-Jun-2017 12:52:55.065 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Program Files\Apache Software Foundation\Tomcat 8.0
20-Jun-2017 12:52:55.065 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 8.0
20-Jun-2017 12:52:55.066 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Program Files\Apache Software Foundation\Tomcat 8.0\conf\logging.properties
20-Jun-2017 12:52:55.066 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
20-Jun-2017 12:52:55.066 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.jmxremote.port=9876
20-Jun-2017 12:52:55.066 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.jmxremote.ssl=false
20-Jun-2017 12:52:55.066 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.jmxremote.authenticate=false
20-Jun-2017 12:52:55.066 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dhttp.nonProxyHosts=localhost|127.0.0.1|US3C0771A3E9F2
20-Jun-2017 12:52:55.066 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
20-Jun-2017 12:52:55.067 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
20-Jun-2017 12:52:55.067 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -agentlib:jdwp=transport=dt_shmem,address=tomcat_shared_memory_id,server=y,suspend=n
20-Jun-2017 12:52:55.067 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 8.0\endorsed
20-Jun-2017 12:52:55.067 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Program Files\Apache Software Foundation\Tomcat 8.0
20-Jun-2017 12:52:55.067 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 8.0
20-Jun-2017 12:52:55.067 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 8.0\temp
20-Jun-2017 12:52:55.067 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.8.0_131\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\RSA SecurID Token Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Perforce;C:\Program Files (x86)\Tools;C:\Program Files\adt-bundle-windows-x86_64-20140321\sdk\tools;C:\Program Files\Git\cmd;C:\cygwin64\bin;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Users\heinzk\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\WebEx\Productivity Tools;C:\Program Files (x86)\WebEx\PTools020000000;C:\Program Files (x86)\Scrivener;C:\Program Files (x86)\Scrivener\Aspell;C:\Program Files (x86)\Scrivener\Aspell\bin;.
20-Jun-2017 12:52:55.499 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
20-Jun-2017 12:52:59.671 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
20-Jun-2017 12:52:59.676 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
20-Jun-2017 12:52:59.685 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
20-Jun-2017 12:52:59.686 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 5325 ms
20-Jun-2017 12:52:59.751 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
20-Jun-2017 12:52:59.752 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.44
20-Jun-2017 12:52:59.765 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying configuration descriptor C:\Program Files\Apache Software Foundation\Tomcat 8.0\conf\Catalina\localhost\Device_Monitor.xml
20-Jun-2017 12:53:05.430 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Device_Monitor]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:587)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1798)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at java.util.Hashtable.get(Hashtable.java:363)
at java.util.Properties.getProperty(Properties.java:969)
at org.apache.catalina.startup.ContextConfig.authenticatorConfig(ContextConfig.java:400)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:794)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:307)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5213)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
... 10 more
Unfortunately the NullPointerException on the HashTable is not of much help.
The context.xml file is and always has been as follows.
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/Device_Monitor"/>
Obviously there's a property being retrieved for which the property name is null. However, I have no idea which it might be as the stack trace is truncated.
Is there a way to get the balance of the "cause's" stack trace?
Is it possible that the context.xml file is incomplete for this new environment?
A sampling of the web.xml is as follows.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Device Monitor</display-name>
<description>Device Monitor application to monitor devices</description>
<context-param>
<param-name>db_hostname</param-name>
<param-value>device-monitor-database</param-value>
<description>Database server hostname/IP address</description>
</context-param>
<context-param>
<param-name>db_name</param-name>
<param-value>device_monitor</param-value>
<description>Database schema name</description>
</context-param>
<context-param>
<param-name>db_password</param-name>
<param-value>device_monitor</param-value>
<description>Database account password</description>
</context-param>
<context-param>
<param-name>db_username</param-name>
<param-value>device_monitor</param-value>
<description>Database account username</description>
</context-param>
<context-param>
<param-name>db_trim_connections</param-name>
<param-value>True</param-value>
<description>Set true to dynamically trim database conections</description>
</context-param>
<context-param>
<param-name>max_HTTP_requests</param-name>
<param-value>25</param-value>
<description>Maximum number of HTTP requests that
may be processed at a time.
Set to "0" (zero) for no limit</description>
</context-param>
<servlet>
<servlet-name>DM Database</servlet-name>
<description>Start first to ensure table definitions are loaded
so any needed repairs can be initiated</description>
<servlet-class>database.Main</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>DM Message</servlet-name>
<description>Start next to ensure only old messages are cleared and
caches are preloaded</description>
<servlet-class>message.Main</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>DM GlobalSetting</servlet-name>
<description>This servlet is loaded next to read the global settings
stored in the database before anything other than messages starts</description>
<servlet-class>globalSetting.Main</servlet-class>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet>
<servlet-name>DM Device</servlet-name>
<description>Load after messages to update the health status of each
device per any uncleared messages</description>
<servlet-class>device.Main</servlet-class>
<init-param>
<param-name>removeDeletionsAfterMonths</param-name>
<param-value>6</param-value>
</init-param>
<init-param>
<param-name>deleteChangesAfterMonths</param-name>
<param-value>6</param-value>
</init-param>
<load-on-startup>4</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>DM Database</servlet-name>
<url-pattern>/Database</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>DM Device</servlet-name>
<url-pattern>/Device</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>DM Message</servlet-name>
<url-pattern>/Message</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>DM GlobalSetting</servlet-name>
<url-pattern>/GlobalSetting</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>600</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<login-config>
<realm-name>Device-Monitor</realm-name>
</login-config>
</web-app>
After downloading and reviewing the pertinent the Tomcat source files as well as reading the javadocs and examining/comparing the context.xml and web.xml files between this projector and those that worked, I found that the following in my web.xml file was causing the issue.
<login-config>
<realm-name>Device-Monitor</realm-name>
</login-config>
After removing this login-config element my application started without issue.
It is odd to note that this did not cause an issue in my development environment under Tomcat 6.0 and Java 1.7.
Related
I'm new to Spring and trying MVC. I built simple demo app and run it on tomcat 9.0.41
It seems artifact is deploied correctly and problem seems to be in Controller mapping ... it simply can not find my jsp.
here is my project structure
here is web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<display-name>spring-mvc-demo</display-name>
<!-- <context-param>-->
<!-- <param-name>contextConfigLocation</param-name>-->
<!-- <param-value>/WEB-INF/applicationContext.xml</param-value>-->
<!-- </context-param>-->
<!-- <listener>-->
<!-- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>-->
<!-- </listener>-->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-mvc-demo-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
spring-mvc-demo-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<display-name>spring-mvc-demo</display-name>
<!-- <context-param>-->
<!-- <param-name>contextConfigLocation</param-name>-->
<!-- <param-value>/WEB-INF/applicationContext.xml</param-value>-->
<!-- </context-param>-->
<!-- <listener>-->
<!-- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>-->
<!-- </listener>-->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-mvc-demo-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
HomeController
package com.springmvcdemo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
#Controller
public class HomeController {
#RequestMapping("/")
public String showPage(){
return "main-menu";
}
}
and simple main-menu.jsp
<html>
<body>
<h2>
Spring Demo MVC - Home page
</h2>
</body>
</html>
here is server log
"C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin\catalina.bat" run
[2021-02-03 07:52:45,945] Artifact SpringMVCdemo:war exploded: Waiting for server connection to start artifact deployment...
Using CATALINA_BASE: "C:\Users\User\AppData\Local\JetBrains\IntelliJIdea2020.1\tomcat\Tomcat_9_0_41_SpringMVCdemo"
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-15.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.rmi/sun.rmi.transport=ALL-UNNAMED
03-Feb-2021 19:52:46.548 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/9.0.41
03-Feb-2021 19:52:46.549 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Dec 3 2020 11:43:00 UTC
03-Feb-2021 19:52:46.549 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.41.0
03-Feb-2021 19:52:46.549 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10
03-Feb-2021 19:52:46.549 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Версия ОС: 10.0
03-Feb-2021 19:52:46.549 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Архитектура: amd64
03-Feb-2021 19:52:46.550 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk-15.0.1
03-Feb-2021 19:52:46.550 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Версия JVM: 15.0.1+9-18
03-Feb-2021 19:52:46.550 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
03-Feb-2021 19:52:46.550 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\User\AppData\Local\JetBrains\IntelliJIdea2020.1\tomcat\Tomcat_9_0_41_SpringMVCdemo
03-Feb-2021 19:52:46.550 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 9.0
03-Feb-2021 19:52:46.551 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
03-Feb-2021 19:52:46.551 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
03-Feb-2021 19:52:46.551 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
03-Feb-2021 19:52:46.552 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\User\AppData\Local\JetBrains\IntelliJIdea2020.1\tomcat\Tomcat_9_0_41_SpringMVCdemo\conf\logging.properties
03-Feb-2021 19:52:46.552 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
03-Feb-2021 19:52:46.552 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
03-Feb-2021 19:52:46.552 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
03-Feb-2021 19:52:46.552 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
03-Feb-2021 19:52:46.552 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.password.file=C:\Users\User\AppData\Local\JetBrains\IntelliJIdea2020.1\tomcat\Tomcat_9_0_41_SpringMVCdemo\jmxremote.password
03-Feb-2021 19:52:46.552 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.access.file=C:\Users\User\AppData\Local\JetBrains\IntelliJIdea2020.1\tomcat\Tomcat_9_0_41_SpringMVCdemo\jmxremote.access
03-Feb-2021 19:52:46.552 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
03-Feb-2021 19:52:46.552 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
03-Feb-2021 19:52:46.552 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
03-Feb-2021 19:52:46.553 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
03-Feb-2021 19:52:46.553 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\User\AppData\Local\JetBrains\IntelliJIdea2020.1\tomcat\Tomcat_9_0_41_SpringMVCdemo
03-Feb-2021 19:52:46.553 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 9.0
03-Feb-2021 19:52:46.553 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 9.0\temp
03-Feb-2021 19:52:46.563 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [1.2.25] using APR version [1.7.0].
03-Feb-2021 19:52:46.563 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
03-Feb-2021 19:52:46.563 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
03-Feb-2021 19:52:46.566 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1g 21 Apr 2020]
03-Feb-2021 19:52:46.723 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
03-Feb-2021 19:52:46.748 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [347] milliseconds
03-Feb-2021 19:52:46.785 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
03-Feb-2021 19:52:46.785 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.41]
03-Feb-2021 19:52:46.791 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
03-Feb-2021 19:52:46.797 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [49] milliseconds
Connected to server
[2021-02-03 07:52:47,043] Artifact SpringMVCdemo:war exploded: Artifact is being deployed, please wait...
[2021-02-03 07:52:47,364] Artifact SpringMVCdemo:war exploded: Artifact is deployed successfully
[2021-02-03 07:52:47,364] Artifact SpringMVCdemo:war exploded: Deploy took 321 milliseconds
03-Feb-2021 19:52:56.801 INFO [Catalina-utility-2] org.apache.catalina.startup.HostConfig.deployDirectory Установка веб приложения в папку [C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\manager]
03-Feb-2021 19:52:56.879 INFO [Catalina-utility-2] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\manager] has finished in [78] ms
i have tried #RequestMapping(value="/", method = RequestMethod.GET) and ("/main-menu"). Serched stack for similar errors and used sugestions but nothing works. Tried creatign different project from scratch... It's driving me nuts, seems everything is done by the book but still errors
Why is your spring-mvc-demo-servlet.xml file the exact copy of web.xml? Try changing spring-mvc-demo-servlet.xml to:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="com.springmvcdemo" />
<mvc:default-servlet-handler />
<mvc:view-controller path="/" view-name="main-menu"/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
OR...
In web.xml change the mapping as something similar as follows:
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/demo/*</url-pattern>
</servlet-mapping>
You will append demo in your url as http://localhost:8080/demo/
This is the complete documentation in case you haven't seen it yet:
Configuring View Controllers
i posted wrong code for spring-mvc-demo-servlet.xml
<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">
<!-- Step 3: Add support for component scanning -->
<context:component-scan base-package="com.springmvcdemo" />
<!-- Step 4: Add support for conversion, formatting and validation support -->
<mvc:annotation-driven/>
<!-- Step 5: Define Spring MVC view resolver -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>```
SOLVED
added extra mapping for method
#Controller
#RequestMapping
public class HomeController {
#RequestMapping("/home")
public String showPage(){
return "home-page";
}
}
added to web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
then lowered my language level to 13 since artifact could not deploy because of level 15 was unsupported by Spring (java.lang.IllegalArgumentException: Unsupported class file major version 59)
then i just call home page from browser
http://localhost:8080/SpringMVCdemo_war_exploded/home
Maybe this will help someone )
I have developed an Oracle ADF application and configured the Data source name and made changes as mentioned here .After deploying the ADF war file in webapps folder I clicked on start command from tomcat web application manager console at localhost:8080/manager/html/start then i am getting
below message
FAIL - Application at context path [/HrEntry_ViewController1_webapp]
could not be started FAIL - Encountered exception
[org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/HrEntry_ViewController1_webapp]]]
Below is the catalina log
04-Apr-2018 02:07:38.227 INFO [localhost-startStop-2]
org.apache.catalina.startup.HostConfig.deployWAR Deploying web
application archive [C:\Program Files\Apache Software
Foundation\Tomcat 8.5\webapps\sample.war]
04-Apr-2018 02:07:44.133 INFO [localhost-startStop-2] 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.
04-Apr-2018 02:07:44.164 INFO [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web
application archive [C:\Program Files\Apache Software
Foundation\Tomcat 8.5\webapps\sample.war] has finished in [5,953] ms
04-Apr-2018 02:07:54.180 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
org.apache.catalina.startup.HostConfig.undeploy Undeploying context
[/sample]
04-Apr-2018 02:07:54.258 INFO [localhost-startStop-3] org.apache.catalina.startup.HostConfig.deployWAR Deploying web
application archive [C:\Program Files\Apache Software
Foundation\Tomcat 8.5\webapps\sample.war]
04-Apr-2018 02:07:58.242 INFO [localhost-startStop-3] 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.
04-Apr-2018 02:07:58.242 INFO [localhost-startStop-3] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web
application archive [C:\Program Files\Apache Software
Foundation\Tomcat 8.5\webapps\sample.war] has finished in [3,984] ms
04-Apr-2018 02:08:21.007 INFO [Thread-6] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler
["http-nio-8080"]
04-Apr-2018 02:08:21.117 INFO [Thread-6] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler
["ajp-nio-8009"]
04-Apr-2018 02:08:21.195 INFO [Thread-6] org.apache.catalina.core.StandardService.stopInternal Stopping service
[Catalina]
04-Apr-2018 02:08:21.241 INFO [Thread-6] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler
["http-nio-8080"]
04-Apr-2018 02:08:21.241 INFO [Thread-6] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler
["ajp-nio-8009"]
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:
Apache Tomcat/8.5.29
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:
Mar 5 2018 13:11:12 UTC
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:
8.5.29.0
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:
Windows Server 2012 R2
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:
6.3
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:
amd64
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:
C:\Program Files\Java\jre1.8.0_161
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:
1.8.0_161-b12
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:
Oracle Corporation
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:
C:\Program Files\Apache Software Foundation\Tomcat 8.5
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:
C:\Program Files\Apache Software Foundation\Tomcat 8.5
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line
argument: -Dcatalina.home=C:\Program Files\Apache Software
Foundation\Tomcat 8.5
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line
argument: -Dcatalina.base=C:\Program Files\Apache Software
Foundation\Tomcat 8.5
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line
argument: -Djava.io.tmpdir=C:\Program Files\Apache Software
Foundation\Tomcat 8.5\temp
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line
argument:
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line
argument: -Djava.util.logging.config.file=C:\Program Files\Apache
Software Foundation\Tomcat 8.5\conf\logging.properties
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line
argument: exit
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line
argument: abort
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line
argument: -Xms128m
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line
argument: -Xmx256m
04-Apr-2018 02:08:34.101 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR
based Apache Tomcat Native library which allows optimal performance in
production environments was not found on the java.library.path:
[C:\Program Files\Apache Software Foundation\Tomcat
8.5\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
Files\Amazon\cfn-bootstrap\;;.]
04-Apr-2018 02:08:34.616 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler
["http-nio-8080"]
04-Apr-2018 02:08:34.882 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a
shared selector for servlet write/read
04-Apr-2018 02:08:34.897 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler
["ajp-nio-8009"]
04-Apr-2018 02:08:34.897 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a
shared selector for servlet write/read
04-Apr-2018 02:08:34.897 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in
2004 ms
04-Apr-2018 02:08:35.147 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting
service [Catalina]
04-Apr-2018 02:08:35.147 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet
Engine: Apache Tomcat/8.5.29
04-Apr-2018 02:08:35.194 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web
application archive [C:\Program Files\Apache Software
Foundation\Tomcat 8.5\webapps\ADFTomcatDemo_ViewController_webapp.war]
04-Apr-2018 02:08:35.819 WARNING [localhost-startStop-1] org.apache.tomcat.util.scan.StandardJarScanner.processURLs Failed to
scan
[file:/C:/Program%20Files/oracle_common/modules/oracle.osdt/osdt_cert.jar]
from classloader hierarchy
java.io.FileNotFoundException: C:\Program Files\oracle_common\modules\oracle.osdt\osdt_cert.jar (The system
cannot find the path specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(Unknown Source)
at java.util.zip.ZipFile.(Unknown Source)
at java.util.jar.JarFile.(Unknown Source)
at java.util.jar.JarFile.(Unknown Source)
at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:188)
at org.apache.tomcat.util.scan.JarFileUrlJar.(JarFileUrlJar.java:65)
at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:49)
at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:374)
at org.apache.tomcat.util.scan.StandardJarScanner.processURLs(StandardJarScanner.java:309)
at org.apache.tomcat.util.scan.StandardJarScanner.doScanClassPath(StandardJarScanner.java:266)
at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:229)
at org.apache.catalina.startup.ContextConfig.processJarsForWebFragments(ContextConfig.java:1888)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1116)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:765)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:299)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5113)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:986)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I get 404 error in my browser, after I start my tomcat :
I type in localhost:8080/mvc/hello or localhost:8080/mvc/hello.jsp
But if I type in localhost:8080, it is normal, can access:
In my springmvc-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-4.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">
<!-- scan the package and the sub package -->
<context:component-scan base-package="com.ypd.springmvcdemo"/>
<!-- don't handle the static resource -->
<mvc:default-servlet-handler />
<!-- if you use annotation you must configure following setting -->
<mvc:annotation-driven />
<!-- configure the InternalResourceViewResolver -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" id="internalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
And in my MVCController.java:
#Controller
#RequestMapping("/mvc")
public class MVCController {
#RequestMapping("/hello")
public String hello() {
return "hello";
}
}
In my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<!--configure the setting of springmvcDispatcherServlet and configure the mapping-->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc-servlet.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
This is my page of hello.jsp:
(I am sorry about the springmvc-servlet.xml's position, I have locate it to under the resource library)
UPDATE - 1:
I am so sorry about it, there is a mistake when I post this snapshot, in my issue project, the web folder has no blue dot on it.See my answer I find the issue with it.
Update image:
So, where is the mistake?
EDIT
My hello.jsp:
<%# page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
Hello, world, jack loly!
</body>
</html>
EDIT
Logs looks like correct:
[2017-03-20 03:06:48,255] Artifact SpringMVCDemo:war exploded: Server is not connected. Deploy is not available.
Connected to the target VM, address: '127.0.0.1:51764', transport: 'socket'
20-Mar-2017 15:06:50.080 info [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/9.0.0.M17
20-Mar-2017 15:06:50.085 info [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jan 10 2017 20:59:20 UTC
20-Mar-2017 15:06:50.085 info [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 9.0.0.0
20-Mar-2017 15:06:50.085 info [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Mac OS X
20-Mar-2017 15:06:50.088 info [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.12.2
20-Mar-2017 15:06:50.089 info [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: x86_64
20-Mar-2017 15:06:50.089 info [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre
20-Mar-2017 15:06:50.089 info [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_121-b13
20-Mar-2017 15:06:50.089 info [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
20-Mar-2017 15:06:50.089 info [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /Users/jack/Library/Caches/IntelliJIdea2016.3/tomcat/Tomcat_9_0_0_M17_SpringMVCDemo
20-Mar-2017 15:06:50.090 info [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /Users/jack/Library/Tomcat9
20-Mar-2017 15:06:50.091 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/Users/jack/Library/Caches/IntelliJIdea2016.3/tomcat/Tomcat_9_0_0_M17_SpringMVCDemo/conf/logging.properties
20-Mar-2017 15:06:50.091 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
20-Mar-2017 15:06:50.091 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:51764,suspend=y,server=n
20-Mar-2017 15:06:50.091 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
20-Mar-2017 15:06:50.092 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
20-Mar-2017 15:06:50.093 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
20-Mar-2017 15:06:50.093 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
20-Mar-2017 15:06:50.093 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
20-Mar-2017 15:06:50.093 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
20-Mar-2017 15:06:50.093 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
20-Mar-2017 15:06:50.093 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/Users/jack/Library/Caches/IntelliJIdea2016.3/tomcat/Tomcat_9_0_0_M17_SpringMVCDemo
20-Mar-2017 15:06:50.094 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/Users/jack/Library/Tomcat9
20-Mar-2017 15:06:50.094 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/Users/jack/Library/Tomcat9/temp
20-Mar-2017 15:06:50.094 info [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /Users/jack/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
20-Mar-2017 15:06:50.527 info [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
20-Mar-2017 15:06:50.560 info [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
20-Mar-2017 15:06:50.563 info [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
20-Mar-2017 15:06:50.565 info [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
20-Mar-2017 15:06:50.581 info [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1455 ms
20-Mar-2017 15:06:50.709 info [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
20-Mar-2017 15:06:50.709 info [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/9.0.0.M17
20-Mar-2017 15:06:50.745 info [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [http-nio-8080]
20-Mar-2017 15:06:50.766 info [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [ajp-nio-8009]
20-Mar-2017 15:06:50.769 info [main] org.apache.catalina.startup.Catalina.start Server startup in 187 ms
Connected to server
[2017-03-20 03:06:51,046] Artifact SpringMVCDemo:war exploded: Artifact is being deployed, please wait...
[2017-03-20 03:06:51,751] Artifact SpringMVCDemo:war exploded: Artifact is deployed successfully
[2017-03-20 03:06:51,751] Artifact SpringMVCDemo:war exploded: Deploy took 705 milliseconds
20-Mar-2017 15:07:00.750 info [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /Users/jack/Library/Tomcat9/webapps/manager
20-Mar-2017 15:07:00.802 info [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /Users/jack/Library/Tomcat9/webapps/manager has finished in 52 ms
EDIT
My tomcat deployment config:
EDIT -2
I think your tomcat deployment configuration is not all okay. your application context should be the context from where you are going to load your application and tell tomcat to dispatch all request within that context.
e.g. your Application Context: could be /helloApp. Now when you will start tomcat, your application would be loaded at localhost:8080/helloApp/. And this is your application root context. Now if you hit at localhost:8080/helloApp/mvc/hello, you are expected to see your content.
Put your springmvc-servlet.xml file in the WEB-INF and change lines of web.xml
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc-servlet.xml</param-value>
</init-param>
To
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/springmvc-servlet.xml</param-value>
</init-param>
There are couple of things to notice.
No project name specified in url
URL should be : http://localhost:8080/SpringMVCDemo/mvc/hello
Why are you mentioning two RequestMapping(mvc,hello) for only one page.You can remove #RequestMapping(value="/mvc") and keep #RequestMapping("/hello") on hello() method.
Update:
add load-on-startup in web.xml
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
At last, I find the issue I was lost. See my question -> UPDATE -1
No blue dot on it means Web Source Dictory is incorrect. See below image I find the issue.
So I delete the red directory, and then re-choose the web directory:
Then in my project, I can see the blue dot on web directory now:
And then I restart tomcat, I success:
Basically i have a java ee project configured with apache v9.0 and eclipse, based on research i had i found that gmail have a free smtp server that allows us to perform our mail services. now the problem is what when ever i input my smtp mail code to my project for sending a simple mail, apache pops an error saying:
Server Tomcat v9.0 Server at localhost failed to start?
Apache logs:
First file:
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/9.0.0.M9
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jul 4 2016 18:22:47 UTC
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 9.0.0.0
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 8
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 6.2
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: x86
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files (x86)\Java\jre1.8.0_101
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_101-b13
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\temp
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: - Djava.util.logging.config.file=C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\conf\logging.properties
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: exit
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms128m
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx256m
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.2.8 using APR version 1.5.2.
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
02-Sep-2016 09:03:21.548 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.0.2h 3 May 2016)
02-Sep-2016 09:03:23.095 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-30012"]
02-Sep-2016 09:03:25.548 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
02-Sep-2016 09:03:25.564 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-30013"]
02-Sep-2016 09:03:25.564 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
02-Sep-2016 09:03:25.564 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 8457 ms
02-Sep-2016 09:03:25.814 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
02-Sep-2016 09:03:25.814 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/9.0.0.M9
02-Sep-2016 09:03:25.861 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\docs
02-Sep-2016 09:03:26.548 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\docs has finished in 687 ms
02-Sep-2016 09:03:26.548 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\examples
02-Sep-2016 09:03:28.142 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\examples has finished in 1,594 ms
02-Sep-2016 09:03:28.142 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\host-manager
02-Sep-2016 09:03:28.251 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\host-manager has finished in 109 ms
02-Sep-2016 09:03:28.251 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\manager
02-Sep-2016 09:03:28.267 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\manager has finished in 16 ms
02-Sep-2016 09:03:28.267 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\ROOT
02-Sep-2016 09:03:28.314 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\ROOT has finished in 47 ms
02-Sep-2016 09:03:28.314 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [http-nio-30012]
02-Sep-2016 09:03:28.439 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [ajp-nio-30013]
02-Sep-2016 09:03:28.454 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 2888
Second File:
[2016-09-02 09:03:11] [info] [ 3436] Commons Daemon procrun (1.0.15.0 32-bit) started
[2016-09-02 09:03:11] [info] [ 3436] Running 'Tomcat9' Service...
[2016-09-02 09:03:12] [info] [ 3468] Starting service...
[2016-09-02 09:03:17] [info] [ 3468] Service started in 5035 ms.
Third File:
02-Sep-2016 09:03:28.095 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized()
02-Sep-2016 09:03:28.095 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized()
Fourth File:
2016-09-02 09:03:11 Commons Daemon procrun stderr initialized
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/9.0.0.M9
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jul 4 2016 18:22:47 UTC
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 9.0.0.0
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 8
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 6.2
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: x86
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files (x86)\Java\jre1.8.0_101
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_101-b13
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\temp
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\conf\logging.properties
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: exit
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms128m
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx256m
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.2.8 using APR version 1.5.2.
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
02-Sep-2016 09:03:21.548 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.0.2h 3 May 2016)
02-Sep-2016 09:03:23.095 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-30012"]
02-Sep-2016 09:03:25.548 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
02-Sep-2016 09:03:25.564 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-30013"]
02-Sep-2016 09:03:25.564 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
02-Sep-2016 09:03:25.564 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 8457 ms
02-Sep-2016 09:03:25.814 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
02-Sep-2016 09:03:25.814 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/9.0.0.M9
02-Sep-2016 09:03:25.861 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\docs
02-Sep-2016 09:03:26.548 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\docs has finished in 687 ms
02-Sep-2016 09:03:26.548 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\examples
02-Sep-2016 09:03:28.142 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\examples has finished in 1,594 ms
02-Sep-2016 09:03:28.142 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\host-manager
02-Sep-2016 09:03:28.251 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\host-manager has finished in 109 ms
02-Sep-2016 09:03:28.251 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\manager
02-Sep-2016 09:03:28.267 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\manager has finished in 16 ms
02-Sep-2016 09:03:28.267 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\ROOT
02-Sep-2016 09:03:28.314 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\ROOT has finished in 47 ms
02-Sep-2016 09:03:28.314 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [http-nio-30012]
02-Sep-2016 09:03:28.439 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [ajp-nio-30013]
02-Sep-2016 09:03:28.454 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 2888 ms
Last File Log:
2016-09-02 09:03:11 Commons Daemon procrun stdout initialized
here is my smtp implementation code:
package duck.reg.pack;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
#WebServlet("/sendmailtls")
public class SendMailTLS extends HttpServlet {
public static void main() {
final String username = "hello#gmail.com";
final String password = "MYPassword";
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", "587");
Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("myemail#gmail.com"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("myemail#yahoo.com"));
message.setSubject("Testing Subject");
message.setText("Dear Mail Crawler,"
+ "\n\n No spam to my email, please!");
Transport.send(message);
System.out.println("Done");
} catch (MessagingException e) {
throw new RuntimeException(e);
}
}
}
My Web.xml File:
<?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>Duck</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
I'm newbie in web development with Java and try to run my first "Hello World" app on Intellij 14 + Tomcat 8.0. Every time I got error "404".
Tomcat without Intellij work perfectly on http://localhost:8080/ as Windows 7 service.
My web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
My index.xhtml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:view>
<h:outputLabel value="Hello, world"/>
</f:view>
</html>
Configuration of Tomcat 8:
Debug configuration
Catalina.log:
09-Nov-2015 08:11:12.741 WARNING [main] org.apache.catalina.core.StandardServer.await StandardServer.await: Invalid command '' received
09-Nov-2015 08:11:15.890 WARNING [main] org.apache.catalina.core.StandardServer.await StandardServer.await: Invalid command '' received
09-Nov-2015 08:11:24.473 INFO [Thread-6] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8080"]
09-Nov-2015 08:11:24.674 INFO [Thread-6] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-nio-8009"]
09-Nov-2015 08:11:24.725 INFO [Thread-6] org.apache.catalina.core.StandardService.stopInternal Stopping service Catalina
09-Nov-2015 08:11:24.959 INFO [Thread-6] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]
09-Nov-2015 08:11:25.012 INFO [Thread-6] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-nio-8009"]
09-Nov-2015 09:12:48.990 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.0.28
09-Nov-2015 09:12:48.997 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Oct 7 2015 18:25:21 UTC
09-Nov-2015 09:12:48.997 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.0.28.0
09-Nov-2015 09:12:48.997 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 7
09-Nov-2015 09:12:48.997 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 6.1
09-Nov-2015 09:12:48.998 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
09-Nov-2015 09:12:48.998 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jre1.8.0_65
09-Nov-2015 09:12:48.998 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_65-b17
09-Nov-2015 09:12:48.998 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
09-Nov-2015 09:12:48.999 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Program Files\Apache Software Foundation\Tomcat 8.0
09-Nov-2015 09:12:48.999 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 8.0
09-Nov-2015 09:12:48.999 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 8.0
09-Nov-2015 09:12:48.999 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Program Files\Apache Software Foundation\Tomcat 8.0
09-Nov-2015 09:12:49.000 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 8.0\endorsed
09-Nov-2015 09:12:49.000 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 8.0\temp
09-Nov-2015 09:12:49.000 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
09-Nov-2015 09:12:49.000 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Program Files\Apache Software Foundation\Tomcat 8.0\conf\logging.properties
09-Nov-2015 09:12:49.000 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: exit
09-Nov-2015 09:12:49.000 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms128m
09-Nov-2015 09:12:49.000 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx256m
09-Nov-2015 09:12:49.001 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\Java\jre1.8.0_60\bin;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\Doctrine extensions for PHP\;;.
09-Nov-2015 09:12:50.595 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
09-Nov-2015 09:12:51.071 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
09-Nov-2015 09:12:51.073 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
09-Nov-2015 09:12:51.076 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
09-Nov-2015 09:12:51.076 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 4183 ms
09-Nov-2015 09:12:51.156 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
09-Nov-2015 09:12:51.156 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.28
09-Nov-2015 09:12:51.190 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\docs
09-Nov-2015 09:12:52.137 INFO [localhost-startStop-1] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [251] milliseconds.
09-Nov-2015 09:12:52.163 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\docs has finished in 973 ms
09-Nov-2015 09:12:52.163 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\manager
09-Nov-2015 09:12:52.217 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\manager has finished in 54 ms
09-Nov-2015 09:12:52.217 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\ROOT
09-Nov-2015 09:12:52.265 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\ROOT has finished in 48 ms
09-Nov-2015 09:12:52.272 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
09-Nov-2015 09:12:52.282 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
09-Nov-2015 09:12:52.285 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 1209 ms
09-Nov-2015 09:15:07.235 INFO [Thread-6] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8080"]
09-Nov-2015 09:15:07.247 INFO [Thread-6] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-nio-8009"]
09-Nov-2015 09:15:07.298 INFO [Thread-6] org.apache.catalina.core.StandardService.stopInternal Stopping service Catalina
09-Nov-2015 09:15:07.355 INFO [Thread-6] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]
09-Nov-2015 09:15:07.358 INFO [Thread-6] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-nio-8009"]
09-Nov-2015 10:08:14.705 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.0.28
09-Nov-2015 10:08:14.707 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Oct 7 2015 18:25:21 UTC
09-Nov-2015 10:08:14.707 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.0.28.0
09-Nov-2015 10:08:14.708 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 7
09-Nov-2015 10:08:14.708 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 6.1
09-Nov-2015 10:08:14.708 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
09-Nov-2015 10:08:14.708 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jre1.8.0_65
09-Nov-2015 10:08:14.708 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_65-b17
09-Nov-2015 10:08:14.708 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
09-Nov-2015 10:08:14.709 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Program Files\Apache Software Foundation\Tomcat 8.0
09-Nov-2015 10:08:14.709 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 8.0
09-Nov-2015 10:08:14.709 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 8.0
09-Nov-2015 10:08:14.709 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Program Files\Apache Software Foundation\Tomcat 8.0
09-Nov-2015 10:08:14.709 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 8.0\endorsed
09-Nov-2015 10:08:14.710 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 8.0\temp
09-Nov-2015 10:08:14.710 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
09-Nov-2015 10:08:14.710 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Program Files\Apache Software Foundation\Tomcat 8.0\conf\logging.properties
09-Nov-2015 10:08:14.710 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: exit
09-Nov-2015 10:08:14.710 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms128m
09-Nov-2015 10:08:14.711 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx256m
09-Nov-2015 10:08:14.711 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\Java\jre1.8.0_60\bin;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\Doctrine extensions for PHP\;;.
09-Nov-2015 10:08:14.884 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
09-Nov-2015 10:08:14.972 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
09-Nov-2015 10:08:14.974 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
09-Nov-2015 10:08:14.977 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
09-Nov-2015 10:08:14.977 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 725 ms
09-Nov-2015 10:08:15.002 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
09-Nov-2015 10:08:15.002 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.28
09-Nov-2015 10:08:15.011 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\docs
09-Nov-2015 10:08:15.482 INFO [localhost-startStop-1] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [130] milliseconds.
09-Nov-2015 10:08:15.500 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\docs has finished in 489 ms
09-Nov-2015 10:08:15.500 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\manager
09-Nov-2015 10:08:15.579 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\manager has finished in 79 ms
09-Nov-2015 10:08:15.579 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\ROOT
09-Nov-2015 10:08:15.609 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\ROOT has finished in 30 ms
09-Nov-2015 10:08:15.621 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
09-Nov-2015 10:08:15.632 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
09-Nov-2015 10:08:15.634 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 656 ms
09-Nov-2015 10:08:33.224 INFO [Thread-6] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8080"]
09-Nov-2015 10:08:33.227 INFO [Thread-6] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-nio-8009"]
09-Nov-2015 10:08:33.278 INFO [Thread-6] org.apache.catalina.core.StandardService.stopInternal Stopping service Catalina
09-Nov-2015 10:08:33.313 INFO [Thread-6] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]
09-Nov-2015 10:08:33.317 INFO [Thread-6] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-nio-8009"]
According to your Deployment screenshot tab, you have to fix value of the field Open browser on tab Server to value http://localhost:8080/JSFDemo and use this path to work with your web-application run from IDEA.