Tomcat + Spring deploying error - java

I need help. I run spring java server under tomcat.
2-Sep-2017 10:35:52.595 INFO [main]
org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.5.20
02-Sep-2017 10:35:52.595 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Aug 2 2017 21:35:49 UTC
02-Sep-2017 10:35:52.595 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.5.20.0
02-Sep-2017 10:35:52.595 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 7
02-Sep-2017 10:35:52.595 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 6.1
02-Sep-2017 10:35:52.595 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
02-Sep-2017 10:35:52.595 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk1.8.0_144\jre
02-Sep-2017 10:35:52.595 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_144-b01
02-Sep-2017 10:35:52.595 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
02-Sep-2017 10:35:52.595 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\Bosun\.IntelliJIdea2017.2\system\tomcat\Unnamed_beautifulmindonlineserver
02-Sep-2017 10:35:52.595 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Users\Bosun\Desktop\apache-tomcat-8.5.20
02-Sep-2017 10:35:52.611 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\Bosun\.IntelliJIdea2017.2\system\tomcat\Unnamed_beautifulmindonlineserver\conf\logging.properties
02-Sep-2017 10:35:52.611 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
02-Sep-2017 10:35:52.611 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
02-Sep-2017 10:35:52.611 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
02-Sep-2017 10:35:52.611 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
02-Sep-2017 10:35:52.611 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
02-Sep-2017 10:35:52.611 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
02-Sep-2017 10:35:52.611 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
02-Sep-2017 10:35:52.611 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
02-Sep-2017 10:35:52.611 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\Bosun\.IntelliJIdea2017.2\system\tomcat\Unnamed_beautifulmindonlineserver
02-Sep-2017 10:35:52.611 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Users\Bosun\Desktop\apache-tomcat-8.5.20
02-Sep-2017 10:35:52.611 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Users\Bosun\Desktop\apache-tomcat-8.5.20\temp
02-Sep-2017 10:35:52.611 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library [1.2.12] using APR version [1.5.2].
02-Sep-2017 10:35:52.611 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
02-Sep-2017 10:35:52.611 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
02-Sep-2017 10:35:53.641 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.0.2k 26 Jan 2017]
02-Sep-2017 10:35:54.280 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
02-Sep-2017 10:35:54.311 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
02-Sep-2017 10:35:54.327 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
02-Sep-2017 10:35:54.327 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
02-Sep-2017 10:35:54.327 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 2528 ms
02-Sep-2017 10:35:54.405 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
02-Sep-2017 10:35:54.405 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.20
02-Sep-2017 10:35:54.436 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
02-Sep-2017 10:35:54.452 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
02-Sep-2017 10:35:54.452 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 125 ms
Connected to server
[2017-09-02 10:35:54,889] Artifact beautifulmindonlineserver:war: Artifact is being deployed, please wait...
02-Sep-2017 10:36:00.224 INFO [RMI TCP Connection(2)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
02-Sep-2017 10:36:02.938 INFO [RMI TCP Connection(2)-127.0.0.1] org.hibernate.jpa.internal.util.LogHelper.logPersistenceUnitInformation HHH000204: Processing PersistenceUnitInfo [
name: default
...]
02-Sep-2017 10:36:03.281 INFO [RMI TCP Connection(2)-127.0.0.1] org.hibernate.Version.logVersion HHH000412: Hibernate Core {5.2.10.Final}
02-Sep-2017 10:36:03.281 INFO [RMI TCP Connection(2)-127.0.0.1] org.hibernate.cfg.Environment.<clinit> HHH000205: Loaded properties from resource hibernate.properties: {hibernate.dialect=org.hibernate.dialect.PostgreSQL9Dialect, hibernate.show_sql=true, hibernate.bytecode.use_reflection_optimizer=false, hibernate.hbm2ddl.auto=validate}
02-Sep-2017 10:36:03.578 INFO [RMI TCP Connection(2)-127.0.0.1] org.hibernate.annotations.common.reflection.java.JavaReflectionManager.<clinit> HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
02-Sep-2017 10:36:04.451 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Users\Bosun\Desktop\apache-tomcat-8.5.20\webapps\manager]
02-Sep-2017 10:36:04.561 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\Bosun\Desktop\apache-tomcat-8.5.20\webapps\manager] has finished in [94] ms
02-Sep-2017 10:36:04.873 INFO [RMI TCP Connection(2)-127.0.0.1] org.hibernate.dialect.Dialect.<init> HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL9Dialect
02-Sep-2017 10:36:05.450 INFO [RMI TCP Connection(2)-127.0.0.1] org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl.useContextualLobCreation HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
02-Sep-2017 10:36:05.450 INFO [RMI TCP Connection(2)-127.0.0.1] org.hibernate.type.BasicTypeRegistry.register HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType#4d851601
02-Sep-2017 10:36:07.774 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
02-Sep-2017 10:36:07.774 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
02-Sep-2017 10:36:07.821 WARNING [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] registered the JDBC driver [org.postgresql.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
[2017-09-02 10:36:07,868] Artifact beautifulmindonlineserver:war: Error during artifact deployment. See server log for details.
hybernate.properties file
hibernate.dialect=org.hibernate.dialect.PostgreSQL9Dialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=validate
I found that if I comment this line
public interface UsersRepository extends JpaRepository {
}
in UserRepository file related to my User ORM class, everything compiled well.
My dependencies:
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<!--Web-->
<!--Json converter-->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
</dependency>
<!-- Database-->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>${spring-data-jpa.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate-entitymanager.version}</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>${commons-dbcp2.version}</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.25</version>
</dependency>
</dependencies>
As I am novice in server-side development and spring, ask for extended response.
UPDATED:
package com.blackbosun.beatufilmind.server;
import com.blackbosun.beatufilmind.server.config.WebConfig;
import com.blackbosun.beatufilmind.server.repository.UsersRepository;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
public class Application implements WebApplicationInitializer {
private final static String DISPATCHER = "dispatcher";
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.register(WebConfig.class);
servletContext.addListener(new ContextLoaderListener(ctx));
ServletRegistration.Dynamic servlet = servletContext.addServlet(DISPATCHER, new DispatcherServlet(ctx));
servlet.addMapping("/");
servlet.setLoadOnStartup(1);
}
}

Related

Spring App is not running from Intellij with Tomcat Server

If I run my spring app from Intellij with Tomcat Server it gives me:
HTTP Status 404 – Not Found
Type Status Report
Message The requested resource [/] is not available
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/9.0.52
But If I put my app.war in tomcat/webapps/ as ROOT.war it works perfectly.
I have problems only when try to run from Intellij
This is the configuration:
This is the deployment:
And this is the output:
C:\apache-tomcat-9.0.52\bin\catalina.bat run
[2021-08-24 02:50:39,974] Artifact myappname:war exploded: Waiting for server connection to start artifact deployment...
Using CATALINA_BASE: "C:\Users\Main\AppData\Local\JetBrains\IntelliJIdea2021.2\tomcat\f74e8856-a9b4-4e50-9d59-c901731f3dc7"
Using CATALINA_HOME: "C:\apache-tomcat-9.0.52"
Using CATALINA_TMPDIR: "C:\apache-tomcat-9.0.52\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk-10.0.2"
Using CLASSPATH: "C:\apache-tomcat-9.0.52\bin\bootstrap.jar;C:\apache-tomcat-9.0.52\bin\tomcat-juli.jar"
Using CATALINA_OPTS: ""
24-Aug-2021 14:50:40.602 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/9.0.52
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jul 31 2021 04:12:17 UTC
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.52.0
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.0
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk-10.0.2
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 10.0.2+13
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: "Oracle Corporation"
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\Main\AppData\Local\JetBrains\IntelliJIdea2021.2\tomcat\f74e8856-a9b4-4e50-9d59-c901731f3dc7
24-Aug-2021 14:50:40.603 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\apache-tomcat-9.0.52
24-Aug-2021 14:50:40.604 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
24-Aug-2021 14:50:40.604 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
24-Aug-2021 14:50:40.604 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED
24-Aug-2021 14:50:40.604 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
24-Aug-2021 14:50:40.604 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
24-Aug-2021 14:50:40.604 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\Main\AppData\Local\JetBrains\IntelliJIdea2021.2\tomcat\f74e8856-a9b4-4e50-9d59-c901731f3dc7\conf\logging.properties
24-Aug-2021 14:50:40.604 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
24-Aug-2021 14:50:40.604 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
24-Aug-2021 14:50:40.604 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.password.file=C:\Users\Main\AppData\Local\JetBrains\IntelliJIdea2021.2\tomcat\f74e8856-a9b4-4e50-9d59-c901731f3dc7\jmxremote.password
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.access.file=C:\Users\Main\AppData\Local\JetBrains\IntelliJIdea2021.2\tomcat\f74e8856-a9b4-4e50-9d59-c901731f3dc7\jmxremote.access
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\Main\AppData\Local\JetBrains\IntelliJIdea2021.2\tomcat\f74e8856-a9b4-4e50-9d59-c901731f3dc7
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\apache-tomcat-9.0.52
24-Aug-2021 14:50:40.605 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\apache-tomcat-9.0.52\temp
24-Aug-2021 14:50:40.607 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [1.2.30] using APR version [1.7.0].
24-Aug-2021 14:50:40.607 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
24-Aug-2021 14:50:40.607 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
24-Aug-2021 14:50:40.610 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1k 25 Mar 2021]
24-Aug-2021 14:50:40.750 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
24-Aug-2021 14:50:40.763 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [279] milliseconds
24-Aug-2021 14:50:40.804 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
24-Aug-2021 14:50:40.804 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.52]
24-Aug-2021 14:50:40.812 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
24-Aug-2021 14:50:40.823 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [59] milliseconds
Connected to server
[2021-08-24 02:50:41,210] Artifact myappname:war exploded: Artifact is being deployed, please wait...
24-Aug-2021 14:50:45.369 INFO [RMI TCP Connection(3)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
[2021-08-24 02:50:45,523] Artifact myappname:war exploded: Artifact is deployed successfully
[2021-08-24 02:50:45,523] Artifact myappname:war exploded: Deploy took 4,313 milliseconds
24-Aug-2021 14:50:50.816 INFO [Catalina-utility-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\apache-tomcat-9.0.52\webapps\manager]
24-Aug-2021 14:50:50.851 INFO [Catalina-utility-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\apache-tomcat-9.0.52\webapps\manager] has finished in [35] ms
I want to run my app from the root: localhost:8080/.
Why I receive 404 - Not Found from Tomcat? And how to fix it?
If you need more details please tell me.
Version of Intellij IDEA: 2021.2 Ultimate Edition
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.5.3</version>
</dependency>
P.S.: I think something is not deployed right. Because after deploy, in console don't appears that big SPRING logo and logs about initializing. Or this is not necessarily?
I found the solution for my problem.
My problem was solved by removing everything from Run/Debug Configuration -> Before Launch
Also instead of what was there I added maven clean install command.

DispatcherServlet - no mapping for any request. Java annotation config

I'm learning Spring and trying to run application on two different databases: H2 and Amazon AWS. For Amazon I used Manual configuration with Tomcat. In Deployment option I added project .war. See here:
For H2 I am using annotation #SpringBootApplication
The problem is - when I use H2 - all works fine, but when I start Tomcat manually - get an error from Dispatcher Servlet: can't find any mapping for any requests.
Previously, before I added H2, it works well. Where do I mistake? Project Structure:
Configurations:
public class MyWebAppInitializer implements WebApplicationInitializer {
#Override
public void onStartup(ServletContext container) {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.setConfigLocation("com.socnetw.socnetw.configurations");
container.addListener(new ContextLoaderListener(context));
ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(context));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
}
}
#EnableWebMvc
#Configuration
#ComponentScan(basePackages = {"com.socnetw.socnetw"})
#PropertySource("classpath:database.properties")
public class Config implements WebMvcConfigurer {
#Value("${db.url}")
private String dbUrl;
#Value("${db.username}")
private String username;
#Value("${db.password}")
private String password;
#Value("${db.driverClassName}")
private String driverClassName;
private ApplicationContext applicationContext;
#Autowired
public Config(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
#Bean
public static PropertySourcesPlaceholderConfigurer properties() {
return new PropertySourcesPlaceholderConfigurer();
}
#Bean
public SpringResourceTemplateResolver templateResolver() {
SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
templateResolver.setApplicationContext(applicationContext);
templateResolver.setPrefix("classpath:/templates/");
templateResolver.setSuffix(".html");
return templateResolver;
}
#Bean
public SpringResourceTemplateResolver templateCssResolver() {
SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
templateResolver.setApplicationContext(applicationContext);
templateResolver.setPrefix("classpath:/static/css");
templateResolver.setSuffix(".css");
return templateResolver;
}
#Bean
public SpringResourceTemplateResolver templateJsResolver() {
SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
templateResolver.setApplicationContext(applicationContext);
templateResolver.setPrefix("classpath:/static/js");
templateResolver.setSuffix(".js");
return templateResolver;
}
#Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/css/**")
.addResourceLocations("classpath:/static/css/");
registry.addResourceHandler("/js/")
.addResourceLocations("/static/js/");
}
#Bean
public SpringTemplateEngine templateEngine() {
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setTemplateResolver(templateResolver());
templateEngine.setEnableSpringELCompiler(true);
return templateEngine;
}
#Override
public void configureViewResolvers(ViewResolverRegistry resolverRegistry) {
ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
viewResolver.setTemplateEngine(templateEngine());
resolverRegistry.viewResolver(viewResolver);
}
#Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
em.setPackagesToScan("Lesson1");
JpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
em.setJpaVendorAdapter(adapter);
return em;
}
#Bean
public DriverManagerDataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(driverClassName);
dataSource.setUrl(dbUrl);
dataSource.setUsername(username);
dataSource.setPassword(password);
return dataSource;
}
#Bean
public PersistenceExceptionTranslationPostProcessor translationPostProcessor() {
return new PersistenceExceptionTranslationPostProcessor();
}
#Bean
public PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(emf);
return transactionManager;
}
}
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.socnetw</groupId>
<artifactId>socnetw</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>socnetw</name>
<description>Simple Social Network On Spring</description>
<properties>
<java.version>12</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
homeController
#Controller
public class HomeController {
#GetMapping
#RequestMapping({"/", "", "index.html", "index"})
public String homePage() {
return "index";
}
#GetMapping
#RequestMapping("/registration")
public String getRegistrationPage() {
return "user/registration";
}
#GetMapping
#RequestMapping("/login")
public String getLoginPage() {
return "user/login";
}
}
Logs:
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
26-Sep-2019 10:24:06.069 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/9.0.21
26-Sep-2019 10:24:06.070 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jun 4 2019 20:19:36 UTC
26-Sep-2019 10:24:06.070 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.21.0
26-Sep-2019 10:24:06.071 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10
26-Sep-2019 10:24:06.071 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.0
26-Sep-2019 10:24:06.071 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
26-Sep-2019 10:24:06.071 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk-12.0.1
26-Sep-2019 10:24:06.076 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 12.0.1+12
26-Sep-2019 10:24:06.077 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
26-Sep-2019 10:24:06.077 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\le2ta\.IntelliJIdea2019.2\system\tomcat\Unnamed_socnetw_3
26-Sep-2019 10:24:06.078 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Users\le2ta\OneDrive\Desktop\Programming\Server\apache-tomcat-9.0.21
26-Sep-2019 10:24:06.079 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
26-Sep-2019 10:24:06.079 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
26-Sep-2019 10:24:06.079 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
26-Sep-2019 10:24:06.079 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\le2ta\.IntelliJIdea2019.2\system\tomcat\Unnamed_socnetw_3\conf\logging.properties
26-Sep-2019 10:24:06.080 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
26-Sep-2019 10:24:06.080 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
26-Sep-2019 10:24:06.080 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
26-Sep-2019 10:24:06.080 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
26-Sep-2019 10:24:06.080 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.password.file=C:\Users\le2ta\.IntelliJIdea2019.2\system\tomcat\Unnamed_socnetw_3\jmxremote.password
26-Sep-2019 10:24:06.080 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.access.file=C:\Users\le2ta\.IntelliJIdea2019.2\system\tomcat\Unnamed_socnetw_3\jmxremote.access
26-Sep-2019 10:24:06.080 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
26-Sep-2019 10:24:06.080 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
26-Sep-2019 10:24:06.080 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
26-Sep-2019 10:24:06.080 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
26-Sep-2019 10:24:06.080 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\le2ta\.IntelliJIdea2019.2\system\tomcat\Unnamed_socnetw_3
26-Sep-2019 10:24:06.081 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Users\le2ta\OneDrive\Desktop\Programming\Server\apache-tomcat-9.0.21
26-Sep-2019 10:24:06.081 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Users\le2ta\OneDrive\Desktop\Programming\Server\apache-tomcat-9.0.21\temp
26-Sep-2019 10:24:06.081 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\jdk-12.0.1\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.3\jbr\\bin;C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.3\jbr\\bin\server;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Git\cmd;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\nodejs\;C:\Users\le2ta\AppData\Local\Microsoft\WindowsApps;;C:\Users\le2ta\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\le2ta\AppData\Roaming\npm;.]
26-Sep-2019 10:24:06.205 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
26-Sep-2019 10:24:06.226 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
26-Sep-2019 10:24:06.228 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [319] milliseconds
26-Sep-2019 10:24:06.264 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
26-Sep-2019 10:24:06.264 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.21]
26-Sep-2019 10:24:06.274 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
26-Sep-2019 10:24:06.282 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
26-Sep-2019 10:24:06.286 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [57] milliseconds
Connected to server
[2019-09-26 10:24:06,462] Artifact socnetw:war: Artifact is being deployed, please wait...
26-Sep-2019 10:24:15.770 INFO [RMI TCP Connection(3)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
10:24:15.779 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
10:24:15.790 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.springframework.web.context.support.AnnotationConfigWebApplicationContext - Refreshing Root WebApplicationContext
10:24:15.912 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.springframework.web.context.support.AnnotationConfigWebApplicationContext - No annotated classes found for specified class/package [<NONE>]
10:24:15.951 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'
10:24:16.008 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.event.internalEventListenerProcessor'
10:24:16.012 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.event.internalEventListenerFactory'
10:24:16.014 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
10:24:16.017 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalCommonAnnotationProcessor'
10:24:16.022 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalPersistenceAnnotationProcessor'
10:24:16.032 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.springframework.ui.context.support.UiApplicationContextUtils - Unable to locate ThemeSource with name 'themeSource': using default [org.springframework.ui.context.support.ResourceBundleThemeSource#389d44df]
10:24:16.050 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/spring.liveBeansView.mbeanDomain]
10:24:16.052 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.springframework.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/spring.liveBeansView.mbeanDomain] not found - trying original name [spring.liveBeansView.mbeanDomain]. javax.naming.NameNotFoundException: Name [spring.liveBeansView.mbeanDomain] is not bound in this Context. Unable to find [spring.liveBeansView.mbeanDomain].
10:24:16.052 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [spring.liveBeansView.mbeanDomain]
10:24:16.052 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.springframework.jndi.JndiPropertySource - JNDI lookup for name [spring.liveBeansView.mbeanDomain] threw NamingException with message: Name [spring.liveBeansView.mbeanDomain] is not bound in this Context. Unable to find [spring.liveBeansView.mbeanDomain].. Returning null.
10:24:16.067 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext initialized in 283 ms
10:24:16.135 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.servlet.DispatcherServlet - Initializing Servlet 'dispatcher'
26-Sep-2019 10:24:16.277 INFO [Catalina-utility-2] org.apache.catalina.startup.HostConfig.deployDirectory Установка веб приложения в папку [C:\Users\le2ta\OneDrive\Desktop\Programming\Server\apache-tomcat-9.0.21\webapps\manager]
26-Sep-2019 10:24:16.333 INFO [Catalina-utility-2] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\le2ta\OneDrive\Desktop\Programming\Server\apache-tomcat-9.0.21\webapps\manager] has finished in [56] ms
10:24:16.698 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter - ControllerAdvice beans: none
10:24:16.774 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver - ControllerAdvice beans: none
10:24:16.807 [RMI TCP Connection(3)-127.0.0.1] DEBUG org.springframework.web.servlet.DispatcherServlet - enableLoggingRequestDetails='false': request parameters and headers will be masked to prevent unsafe logging of potentially sensitive data
10:24:16.807 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.servlet.DispatcherServlet - Completed initialization in 672 ms
[2019-09-26 10:24:16,818] Artifact socnetw:war: Artifact is deployed successfully
[2019-09-26 10:24:16,818] Artifact socnetw:war: Deploy took 10,356 milliseconds
10:24:17.047 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet - GET "/", parameters={}
10:24:17.051 [http-nio-8080-exec-1] WARN org.springframework.web.servlet.PageNotFound - No mapping for GET /
10:24:17.053 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet - Completed 404 NOT_FOUND
10:24:17.060 [http-nio-8080-exec-2] DEBUG org.springframework.web.servlet.DispatcherServlet - GET "/", parameters={}
10:24:17.060 [http-nio-8080-exec-2] WARN org.springframework.web.servlet.PageNotFound - No mapping for GET /
10:24:17.060 [http-nio-8080-exec-2] DEBUG org.springframework.web.servlet.DispatcherServlet - Completed 404 NOT_FOUND
10:24:17.158 [http-nio-8080-exec-3] DEBUG org.springframework.web.servlet.DispatcherServlet - GET "/", parameters={}
10:24:17.158 [http-nio-8080-exec-3] WARN org.springframework.web.servlet.PageNotFound - No mapping for GET /
10:24:17.159 [http-nio-8080-exec-3] DEBUG org.springframework.web.servlet.DispatcherServlet - Completed 404 NOT_FOUND

War exploded: Error during artifact deployment. Tomcat 8.5+IDEA

I'm trying to configure Tomcat 8.5 on Intellij Idea Ultimate.
I installed it in /opt/tomcat/apache-tomcat-8.5.11. I'm using Ubuntu.
When I run the project I have these output:
`/opt/tomcat/apache-tomcat-8.5.11/bin/catalina.sh run
[2017-02-05 02:40:12,566] Artifact Spring1:war exploded: Server is not connected. Deploy is not available.
05-Feb-2017 14:40:13.144 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.5.11
05-Feb-2017 14:40:13.146 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jan 10 2017 21:02:52 UTC
05-Feb-2017 14:40:13.147 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.5.11.0
05-Feb-2017 14:40:13.147 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
05-Feb-2017 14:40:13.147 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 4.4.0-62-generic
05-Feb-2017 14:40:13.147 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
05-Feb-2017 14:40:13.147 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/lib/jvm/java-8-oracle/jre
05-Feb-2017 14:40:13.147 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_121-b13
05-Feb-2017 14:40:13.147 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
05-Feb-2017 14:40:13.147 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /home/marcel/.IntelliJIdea2016.3/system/tomcat/Unnamed_Spring1
05-Feb-2017 14:40:13.147 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /opt/tomcat/apache-tomcat-8.5.11
05-Feb-2017 14:40:13.147 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/home/marcel/.IntelliJIdea2016.3/system/tomcat/Unnamed_Spring1/conf/logging.properties
05-Feb-2017 14:40:13.148 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
05-Feb-2017 14:40:13.148 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
05-Feb-2017 14:40:13.148 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
05-Feb-2017 14:40:13.148 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
05-Feb-2017 14:40:13.148 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
05-Feb-2017 14:40:13.148 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
05-Feb-2017 14:40:13.150 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
05-Feb-2017 14:40:13.151 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
05-Feb-2017 14:40:13.151 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/home/marcel/.IntelliJIdea2016.3/system/tomcat/Unnamed_Spring1
05-Feb-2017 14:40:13.151 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/opt/tomcat/apache-tomcat-8.5.11
05-Feb-2017 14:40:13.151 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/opt/tomcat/apache-tomcat-8.5.11/temp
05-Feb-2017 14:40:13.151 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: /home/marcel/.local/share/umake/ide/idea-ultimate/bin::/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
05-Feb-2017 14:40:13.270 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
05-Feb-2017 14:40:13.284 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
05-Feb-2017 14:40:13.286 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
05-Feb-2017 14:40:13.287 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
05-Feb-2017 14:40:13.287 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 415 ms
05-Feb-2017 14:40:13.321 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
05-Feb-2017 14:40:13.321 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.11
05-Feb-2017 14:40:13.328 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [http-nio-8080]
05-Feb-2017 14:40:13.333 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [ajp-nio-8009]
05-Feb-2017 14:40:13.334 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 46 ms
Connected to server
[2017-02-05 02:40:13,677] Artifact Spring1:war exploded: Artifact is being deployed, please wait...
05-Feb-2017 14:40:13.940 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
05-Feb-2017 14:40:13.950 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
[2017-02-05 02:40:13,964] Artifact Spring1:war exploded: Error during artifact deployment. See server log for details.
05-Feb-2017 14:40:23.329 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/tomcat/apache-tomcat-8.5.11/webapps/host-manager
05-Feb-2017 14:40:23.388 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/tomcat/apache-tomcat-8.5.11/webapps/host-manager has finished in 58 ms
05-Feb-2017 14:40:23.388 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/tomcat/apache-tomcat-8.5.11/webapps/examples
05-Feb-2017 14:40:23.609 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/tomcat/apache-tomcat-8.5.11/webapps/examples has finished in 221 ms
05-Feb-2017 14:40:23.610 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/tomcat/apache-tomcat-8.5.11/webapps/docs
05-Feb-2017 14:40:23.624 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/tomcat/apache-tomcat-8.5.11/webapps/docs has finished in 15 ms
05-Feb-2017 14:40:23.624 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/tomcat/apache-tomcat-8.5.11/webapps/manager
05-Feb-2017 14:40:23.641 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/tomcat/apache-tomcat-8.5.11/webapps/manager has finished in 17 ms
`
I'm using the following configuration in IDEA :
http://imgur.com/nYT2i7T
http://imgur.com/PgGfmh2
I tried to follow Tomcat in Idea. war exploded: Server is not connected. Deploy is not available but Tomcat 8.5 bin there's no setenv.sh .
Thanks for help.

Leaking Tomcat JDBC MySQL driver in a Spring environment

At the moment I am writing a Spring and JDBC based web-application that interacts with a MySQL database on a Windows Server 2012 x64. The MySQL database driver is registered by Tomcat and not by the servlet itself (As so many people do).
Although I close all connection/prepared statements/result sets, Tomcat logs a possible memory leak during a restart and I don't know why. Additionally the server crashes (Read: times out) after a few days, maybe because the leaks.
$APACHE_DIR/conf/context.xml:
<?xml version='1.0' encoding='utf-8'?>
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<Resource name="jdbc/testservlet"
global="jdbc/testservlet"
type="javax.sql.DataSource"
username="root"
password="123456aA"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/testservlet"
maxTotal="10"
maxIdle="10"
maxWaitMillis="10000"
removeAbandonedTimeout="300"
defaultAutoCommit="true" />
</Context>
$APACHE_DIR/webapps/testservlet/META-INF/context.xml:
<?xml version='1.0' encoding='utf-8'?>
<Context>
<ResourceLink name="jdbc/testservlet" global="jdbc/testservlet" type="javax.sql.DataSource" />
</Context>
$PROJECT_DIR/DatabaseConfiguration.java
package com.example.testservlet.configuration;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
#Configuration
public class DatabaseConfiguration
{
#Bean
public DataSource getDataSource() throws Exception
{
Context initialContext = new InitialContext();
Context environmentContext = (Context) initialContext.lookup("java:comp/env");
DataSource dataSource = (DataSource) environmentContext.lookup("jdbc/testservlet");
return dataSource;
}
}
$PROJECT_DIR/HomeController.java
package com.example.testservlet.controller;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
#Controller
public class HomeController
{
#Autowired
DataSource datasource;
#ResponseBody
#RequestMapping(value = "/", method = RequestMethod.GET)
public void home() throws Exception
{
Connection connection = null;
ResultSet resultset = null;
try
{
connection = datasource.getConnection();
DatabaseMetaData metadata = connection.getMetaData();
resultset = metadata.getTables(null, null, "%", null);
while(resultset.next())
{
System.out.println("Table: " + resultset.getString(3));
}
}
finally
{
System.out.println("Final block start");
try{ connection.close(); } catch(Exception exception) { throw new Exception("Database error"); }
try{ resultset.close(); } catch(Exception exception) { throw new Exception("Database error"); }
System.out.println("Final block end");
}
}
}
$PROJECT_ROOT/pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>testservlet</artifactId>
<packaging>war</packaging>
<version>0.1.0-SNAPSHOT</version>
<name>testservlet</name>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<finalName>testservlet</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
<webResources>
<resource>
<directory>${project.basedir}/src/main/resources
</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</project>
The MySQL driver is installed as "mysql-connector-java.jar" (Version 5.1.38) inside the Tomcat lib directory also the database configuration is called by the Spring framework. A HTTP request to localhost:8080/testservlet + a Tomcat restarts results in the following log:
25-Jan-2016 19:11:28.006 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.0.30
25-Jan-2016 19:11:28.037 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Dec 1 2015 22:30:46 UTC
25-Jan-2016 19:11:28.037 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.0.30.0
25-Jan-2016 19:11:28.037 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows Server 2012 R2
25-Jan-2016 19:11:28.037 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 6.3
25-Jan-2016 19:11:28.037 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
25-Jan-2016 19:11:28.037 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk1.8.0_66\jre
25-Jan-2016 19:11:28.037 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_66-b18
25-Jan-2016 19:11:28.037 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
25-Jan-2016 19:11:28.037 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\simonwaechter\Downloads\apache-tomcat-8.0.30-windows-x64
25-Jan-2016 19:11:28.037 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Users\simonwaechter\Downloads\apache-tomcat-8.0.30-windows-x64
25-Jan-2016 19:11:28.037 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\simonwaechter\Downloads\apache-tomcat-8.0.30-windows-x64\conf\logging.properties
25-Jan-2016 19:11:28.037 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
25-Jan-2016 19:11:28.037 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=C:\Users\simonwaechter\Downloads\apache-tomcat-8.0.30-windows-x64\endorsed
25-Jan-2016 19:11:28.037 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\simonwaechter\Downloads\apache-tomcat-8.0.30-windows-x64
25-Jan-2016 19:11:28.037 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Users\simonwaechter\Downloads\apache-tomcat-8.0.30-windows-x64
25-Jan-2016 19:11:28.037 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Users\simonwaechter\Downloads\apache-tomcat-8.0.30-windows-x64\temp
25-Jan-2016 19:11:28.037 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.1.33 using APR version 1.5.1.
25-Jan-2016 19:11:28.037 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
25-Jan-2016 19:11:28.617 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.0.1m 19 Mar 2015)
25-Jan-2016 19:11:28.866 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-apr-8080"]
25-Jan-2016 19:11:28.881 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-apr-8009"]
25-Jan-2016 19:11:28.881 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1407 ms
25-Jan-2016 19:11:28.929 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
25-Jan-2016 19:11:28.929 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.30
25-Jan-2016 19:11:29.006 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive C:\Users\simonwaechter\Downloads\apache-tomcat-8.0.30-windows-x64\webapps\testservlet.war
25-Jan-2016 19:11:30.901 INFO [localhost-startStop-1] org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory.getObjectInstance Name = testservlet Ignoring unknown property: value of "JCG Example MySQL database." for "description" property
25-Jan-2016 19:11:30.901 INFO [localhost-startStop-1] org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory.getObjectInstance Name = testservlet Ignoring unknown property: value of "jdbc/testservlet" for "global" property
25-Jan-2016 19:11:31.010 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
25-Jan-2016 19:11:31.213 INFO [localhost-startStop-1] org.springframework.web.context.ContextLoader.initWebApplicationContext Root WebApplicationContext: initialization started
25-Jan-2016 19:11:31.213 INFO [localhost-startStop-1] org.springframework.web.context.support.AnnotationConfigWebApplicationContext.prepareRefresh Refreshing Root WebApplicationContext: startup date [Mon Jan 25 19:11:31 CET 2016]; root of context hierarchy
25-Jan-2016 19:11:31.369 INFO [localhost-startStop-1] org.springframework.web.context.support.AnnotationConfigWebApplicationContext.loadBeanDefinitions Found 2 annotated classes in package [com.example.testservlet.configuration]
25-Jan-2016 19:11:32.141 INFO [localhost-startStop-1] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.registerHandlerMethod Mapped "{[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public void com.example.testservlet.controller.HomeController.home() throws java.lang.Exception
25-Jan-2016 19:11:32.187 INFO [localhost-startStop-1] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.registerHandler Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler]
25-Jan-2016 19:11:32.437 INFO [localhost-startStop-1] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.initControllerAdviceCache Looking for #ControllerAdvice: Root WebApplicationContext: startup date [Mon Jan 25 19:11:31 CET 2016]; root of context hierarchy
25-Jan-2016 19:11:32.671 INFO [localhost-startStop-1] org.springframework.web.context.ContextLoader.initWebApplicationContext Root WebApplicationContext: initialization completed in 1458 ms
25-Jan-2016 19:11:32.749 INFO [localhost-startStop-1] org.springframework.web.servlet.DispatcherServlet.initServletBean FrameworkServlet 'DispatcherServlet': initialization started
25-Jan-2016 19:11:32.781 INFO [localhost-startStop-1] org.springframework.web.servlet.DispatcherServlet.initServletBean FrameworkServlet 'DispatcherServlet': initialization completed in 32 ms
25-Jan-2016 19:11:32.829 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive C:\Users\simonwaechter\Downloads\apache-tomcat-8.0.30-windows-x64\webapps\testservlet.war has finished in 3,807 ms
25-Jan-2016 19:11:32.829 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
25-Jan-2016 19:11:32.843 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8009"]
25-Jan-2016 19:11:32.843 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 3959 ms
25-Jan-2016 19:11:45.074 INFO [main] org.apache.catalina.core.StandardServer.await A valid shutdown command was received via the shutdown port. Stopping the Server instance.
25-Jan-2016 19:11:45.074 INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-apr-8080"]
25-Jan-2016 19:11:45.137 INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-apr-8009"]
25-Jan-2016 19:11:45.199 INFO [main] org.apache.catalina.core.StandardService.stopInternal Stopping service Catalina
25-Jan-2016 19:11:45.199 INFO [localhost-startStop-2] org.springframework.web.context.support.AnnotationConfigWebApplicationContext.doClose Closing Root WebApplicationContext: startup date [Mon Jan 25 19:11:31 CET 2016]; root of context hierarchy
25-Jan-2016 19:11:45.199 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [testservlet] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:43)
25-Jan-2016 19:11:45.215 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-apr-8080"]
25-Jan-2016 19:11:45.309 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-apr-8009"]
25-Jan-2016 19:11:45.371 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-apr-8080"]
25-Jan-2016 19:11:45.371 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-apr-8009"]
I have no idea why this leak happens. There are many answers like deregistering the JDBC driver, but few of them handle the driver in a shared/hosted Tomcat environment where other servlets might access the same JDBC driver.
We ended up with the answer from Guillaume and use the listener.
I still don't know what caused the sporadic crashes, but an update of the Oracle MySQL server solved the problem.

One or more listeners failed to start - tomcat8

i am trying to deploy my war file to tomcat 8..
i get this error..
Configuring Spring Security Core ...
... finished configuring Spring Security Core
27-Nov-2015 12:05:30.872 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
27-Nov-2015 12:05:30.899 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
27-Nov-2015 12:05:31.950 SEVERE [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [org.grails.web.converters.configuration.ConvertersConfigurationHolder$2] (value [org.grails.web.converters.configuration.ConvertersConfigurationHolder$2#3452ee75]) and a value of type [java.util.HashMap] (value [{}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
27-Nov-2015 12:05:31.955 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive /root/apache-tomcat-8.0.28/webapps/ROOT.war has finished in 95,296 ms
27-Nov-2015 12:05:31.958 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-80"]
27-Nov-2015 12:05:31.964 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
27-Nov-2015 12:05:31.968 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 95506 ms
i am using java 1.7.0_75, tomcat 8.0.28
this is my setenv.sh
CATALINA_OPTS="-server -d64 -Xms512m -Xmx512m -XX:PermSize=1024m -XX:MaxPermSize=1024m -XX:-UseGCOverheadLimit -XX:-PrintGCDetails -Djava.awt.headless=true -Dfile.encoding=UTF-8"
export CATALINA_OPTS
anyone know why i get this error?
i build a war with grails 3.0.9
================================================================
when i start tomcat.. i just get this log in /logs/catalina.out
27-Nov-2015 12:03:55.984 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.0.28
27-Nov-2015 12:03:55.994 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Oct 7 2015 18:25:21 UTC
27-Nov-2015 12:03:55.994 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.0.28.0
27-Nov-2015 12:03:55.994 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
27-Nov-2015 12:03:55.995 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 3.7.2-042stab092.2
27-Nov-2015 12:03:55.995 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
27-Nov-2015 12:03:55.995 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/java/jdk1.7.0_79/jre
27-Nov-2015 12:03:55.996 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.7.0_79-b15
27-Nov-2015 12:03:55.996 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
27-Nov-2015 12:03:55.996 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /root/apache-tomcat-8.0.28
27-Nov-2015 12:03:55.996 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /root/apache-tomcat-8.0.28
27-Nov-2015 12:03:55.997 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/root/apache-tomcat-8.0.28/conf/logging.properties
27-Nov-2015 12:03:55.998 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
27-Nov-2015 12:03:55.998 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms1024m
27-Nov-2015 12:03:55.998 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx1024m
27-Nov-2015 12:03:55.998 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:PermSize=1024m
27-Nov-2015 12:03:55.999 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:MaxPermSize=1024m
27-Nov-2015 12:03:55.999 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms780m
27-Nov-2015 12:03:56.003 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx780m
27-Nov-2015 12:03:56.003 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:PermSize=1024m
27-Nov-2015 12:03:56.004 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:MaxPermSize=1024m
27-Nov-2015 12:03:56.004 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:-UseGCOverheadLimit
27-Nov-2015 12:03:56.004 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:-PrintGCDetails
27-Nov-2015 12:03:56.004 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.awt.headless=true
27-Nov-2015 12:03:56.005 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dfile.encoding=UTF-8
27-Nov-2015 12:03:56.005 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=/root/apache-tomcat-8.0.28/endorsed
27-Nov-2015 12:03:56.005 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/root/apache-tomcat-8.0.28
27-Nov-2015 12:03:56.005 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/root/apache-tomcat-8.0.28
27-Nov-2015 12:03:56.006 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/root/apache-tomcat-8.0.28/temp
27-Nov-2015 12:03:56.006 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: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
27-Nov-2015 12:03:56.372 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-80"]
27-Nov-2015 12:03:56.438 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
27-Nov-2015 12:03:56.452 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
27-Nov-2015 12:03:56.455 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
27-Nov-2015 12:03:56.461 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1767 ms
27-Nov-2015 12:03:56.550 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
27-Nov-2015 12:03:56.550 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.28
27-Nov-2015 12:03:56.659 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /root/apache-tomcat-8.0.28/webapps/ROOT.war
27-Nov-2015 12:04:07.850 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Configuring Spring Security Core ...
... finished configuring Spring Security Core
anc
Environment.current = PRODUCTION
Environment.DEVELOPMENT = DEVELOPMENT
Environment.current = PRODUCTION
Environment.DEVELOPMENT = DEVELOPMENT
27-Nov-2015 12:05:30.872 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
27-Nov-2015 12:05:30.899 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
27-Nov-2015 12:05:31.950 SEVERE [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [org.grails.web.converters.configuration.ConvertersConfigurationHolder$2] (value [org.grails.web.converters.configuration.ConvertersConfigurationHolder$2#3452ee75]) and a value of type [java.util.HashMap] (value [{}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
27-Nov-2015 12:05:31.955 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive /root/apache-tomcat-8.0.28/webapps/ROOT.war has finished in 95,296 ms
27-Nov-2015 12:05:31.958 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-80"]
27-Nov-2015 12:05:31.964 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
27-Nov-2015 12:05:31.968 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 95506 ms
after i check...tomcat 8 was failed to run this code
public void contextInitialized(ServletContextEvent event) {
ServletContext servletContext = event.servletContext
final ServerContainer serverContainer = servletContext.getAttribute("javax.websocket.server.ServerContainer")
try {
println "Environment.current = "+Environment.current
if (Environment.current == Environment.PRODUCTION) {
serverContainer.addEndpoint(ServerEndPointDemo) //<<<< this code
println "run 123"
}
println "--- we have a connection"
int defaultMaxSessionIdleTimeout = 900000 //config.timeout ?: 0
serverContainer.defaultMaxSessionIdleTimeout = defaultMaxSessionIdleTimeout
}
catch (IOException e) {
log.error e.message, e
println "e = "+e
}
}
serverContainer.addEndpoint(ServerEndPointDemo) this code was the problem

Categories

Resources