I was writing a simple Database Configuration application using SpringMVC, Hibernate, Maven, with MySQL database.
I was using Eclipse IDE and Tomcat 8.5 in local.
This Same code works fine in local (PC). So I tried Deploying it in OpenShift, There, these are the Errors I'm facing, my container is crashing frequently (have no idea why?. I've been bumped with these Errors for more than a week now). Shed Light on it Please, This might be usefull to many like me. Thanks Already! :)
Deployment Log in OpenShift:
Running jboss-webserver-3/webserver30-tomcat8-openshift image, version 1.1-7
I> No access restrictor found, access to all MBean is allowed
Jolokia: Agent started with URL http://127.0.0.1:8778/jolokia/
2018-03-19 14:14:02,260 [main] INFO org.apache.catalina.startup.Catalina- Cluster RuleSet not found due to [java.lang.ClassNotFoundException: org.apache.catalina.ha.ClusterRuleSet]. Cluster configuration disabled.
2018-03-19 14:14:02,261 [main] INFO org.apache.catalina.startup.Catalina- Cluster RuleSet not found due to [java.lang.ClassNotFoundException: org.apache.catalina.ha.ClusterRuleSet]. Cluster configuration disabled.
2018-03-19 14:14:03,159 [main] INFO org.apache.catalina.startup.VersionLoggerListener- Server version: Apache Tomcat/8.0.18
2018-03-19 14:14:03,159 [main] INFO org.apache.catalina.startup.VersionLoggerListener- Server built: Aug 11 2015 14:53:16 UTC
2018-03-19 14:14:03,159 [main] INFO org.apache.catalina.startup.VersionLoggerListener- Server number: 8.0.18-25_patch_00.ep7.el7.-patch-00
2018-03-19 14:14:03,159 [main] INFO org.apache.catalina.startup.VersionLoggerListener- OS Name: Linux
2018-03-19 14:14:03,160 [main] INFO org.apache.catalina.startup.VersionLoggerListener- OS Version: 3.10.0-693.15.2.el7.x86_64
2018-03-19 14:14:03,160 [main] INFO org.apache.catalina.startup.VersionLoggerListener- Architecture: amd64
2018-03-19 14:14:03,160 [main] INFO org.apache.catalina.startup.VersionLoggerListener- Java Home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.51-1.b16.el7_1.x86_64/jre
2018-03-19 14:14:03,160 [main] INFO org.apache.catalina.startup.VersionLoggerListener- JVM Version: 1.8.0_51-b16
2018-03-19 14:14:03,160 [main] INFO org.apache.catalina.startup.VersionLoggerListener- JVM Vendor: Oracle Corporation
2018-03-19 14:14:03,160 [main] INFO org.apache.catalina.startup.VersionLoggerListener- CATALINA_BASE: /opt/webserver
2018-03-19 14:14:03,160 [main] INFO org.apache.catalina.startup.VersionLoggerListener- CATALINA_HOME: /opt/webserver
2018-03-19 14:14:03,160 [main] INFO org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Dnop
2018-03-19 14:14:03,160 [main] INFO org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
2018-03-19 14:14:03,160 [main] INFO org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Djava.library.path=/opt/webserver/lib
2018-03-19 14:14:03,160 [main] INFO org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Djava.security.egd=file:/dev/./urandom
2018-03-19 14:14:03,160 [main] INFO org.apache.catalina.startup.VersionLoggerListener- Command line argument: -javaagent:/opt/webserver/lib/jolokia.jar=port=8778,host=127.0.0.1,discoveryEnabled=false
2018-03-19 14:14:03,161 [main] INFO org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Djava.endorsed.dirs=/opt/webserver/endorsed
2018-03-19 14:14:03,161 [main] INFO org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Dcatalina.base=/opt/webserver
2018-03-19 14:14:03,161 [main] INFO org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Dcatalina.home=/opt/webserver
2018-03-19 14:14:03,161 [main] INFO org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Djava.io.tmpdir=/opt/webserver/temp
2018-03-19 14:14:03,161 [main] INFO org.apache.catalina.core.AprLifecycleListener- Loaded APR based Apache Tomcat Native library 1.1.32 using APR version 1.4.8.
2018-03-19 14:14:03,161 [main] INFO org.apache.catalina.core.AprLifecycleListener- APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2018-03-19 14:14:03,188 [main] INFO org.apache.catalina.core.AprLifecycleListener- OpenSSL successfully initialized (OpenSSL 1.0.1e 11 Feb 2013)
2018-03-19 14:14:03,344 [main] INFO org.apache.coyote.http11.Http11AprProtocol- Initializing ProtocolHandler ["http-apr-8080"]
2018-03-19 14:14:03,355 [main] INFO org.apache.catalina.startup.Catalina- Initialization processed in 1137 ms
2018-03-19 14:14:03,374 [main] INFO org.apache.catalina.core.StandardService- Starting service Catalina
2018-03-19 14:14:03,374 [main] INFO org.apache.catalina.core.StandardEngine- Starting Servlet Engine: Apache Tomcat/8.0.18
2018-03-19 14:14:03,401 [localhost-startStop-1] INFO org.apache.catalina.startup.HostConfig- Deploying web application archive /deployments/ROOT.war
2018-03-19 14:14:08,856 [localhost-startStop-1] INFO org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]- No Spring WebApplicationInitializer types detected on classpath
2018-03-19 14:14:08,947 [localhost-startStop-1] INFO org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]- Initializing Spring root WebApplicationContext
2018-03-19 14:14:08,947 [localhost-startStop-1] INFO org.springframework.web.context.ContextLoader- Root WebApplicationContext: initialization started
2018-03-19 14:14:09,061 [localhost-startStop-1] INFO org.springframework.web.context.support.XmlWebApplicationContext- Refreshing Root WebApplicationContext: startup date [Mon Mar 19 14:14:09 EDT 2018]; root of context hierarchy
2018-03-19 14:14:09,253 [localhost-startStop-1] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader- Loading XML bean definitions from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
2018-03-19 14:14:10,942 [localhost-startStop-1] INFO org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor- JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-03-19 14:14:13,458 [localhost-startStop-1] INFO org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping- Mapped "{[/ || /home],methods=[GET]}" onto public org.springframework.web.servlet.ModelAndView com.redhat.api.controller.ControllerClass.goHome()
2018-03-19 14:14:13,459 [localhost-startStop-1] INFO org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping- Mapped "{[/check],methods=[GET]}" onto public org.springframework.web.servlet.ModelAndView com.redhat.api.controller.ControllerClass.goCheck()
2018-03-19 14:14:13,857 [localhost-startStop-1] INFO org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter- Looking for @ControllerAdvice: Root WebApplicationContext: startup date [Mon Mar 19 14:14:09 EDT 2018]; root of context hierarchy
2018-03-19 14:14:14,143 [localhost-startStop-1] INFO org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter- Looking for @ControllerAdvice: Root WebApplicationContext: startup date [Mon Mar 19 14:14:09 EDT 2018]; root of context hierarchy
2018-03-19 14:14:14,654 [localhost-startStop-1] INFO org.springframework.web.servlet.handler.SimpleUrlHandlerMapping- Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
2018-03-19 14:14:14,854 [localhost-startStop-1] INFO org.springframework.jdbc.datasource.DriverManagerDataSource- Loaded JDBC driver: com.mysql.jdbc.Driver
DataBase Connection Established
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
2018-03-19 14:14:15,462 [localhost-startStop-1] INFO org.hibernate.Version- HHH000412: Hibernate Core {5.2.5.Final}
2018-03-19 14:14:15,464 [localhost-startStop-1] INFO org.hibernate.cfg.Environment- HHH000206: hibernate.properties not found
2018-03-19 14:14:15,746 [localhost-startStop-1] INFO org.hibernate.annotations.common.Version- HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
Mon Mar 19 14:14:16 EDT 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2018-03-19 14:14:17,958 [localhost-startStop-1] INFO org.hibernate.dialect.Dialect- HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
Mon Mar 19 14:14:20 EDT 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Session Factory Block Crossed
2018-03-19 14:14:20,662 [localhost-startStop-1] INFO org.springframework.orm.hibernate5.HibernateTransactionManager- Using DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@65868c29] of Hibernate SessionFactory for HibernateTransactionManager
Transaction Done
2018-03-19 14:14:20,944 [localhost-startStop-1] INFO org.springframework.web.context.ContextLoader- Root WebApplicationContext: initialization completed in 11997 ms
2018-03-19 14:14:20,962 [localhost-startStop-1] INFO org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]- Initializing Spring FrameworkServlet 'dispatcher'
2018-03-19 14:14:20,962 [localhost-startStop-1] INFO org.springframework.web.servlet.DispatcherServlet- FrameworkServlet 'dispatcher': initialization started
2018-03-19 14:14:20,964 [localhost-startStop-1] INFO org.springframework.web.context.support.XmlWebApplicationContext- Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Mon Mar 19 14:14:20 EDT 2018]; parent: Root WebApplicationContext
2018-03-19 14:14:20,964 [localhost-startStop-1] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader- Loading XML bean definitions from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
2018-03-19 14:14:21,344 [localhost-startStop-1] INFO org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor- JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-03-19 14:14:21,540 [localhost-startStop-1] INFO org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping- Mapped "{[/ || /home],methods=[GET]}" onto public org.springframework.web.servlet.ModelAndView com.redhat.api.controller.ControllerClass.goHome()
2018-03-19 14:14:21,541 [localhost-startStop-1] INFO org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping- Mapped "{[/check],methods=[GET]}" onto public org.springframework.web.servlet.ModelAndView com.redhat.api.controller.ControllerClass.goCheck()
2018-03-19 14:14:21,645 [localhost-startStop-1] INFO org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter- Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date [Mon Mar 19 14:14:20 EDT 2018]; parent: Root WebApplicationContext
2018-03-19 14:14:21,657 [localhost-startStop-1] INFO org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter- Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date [Mon Mar 19 14:14:20 EDT 2018]; parent: Root WebApplicationContext
2018-03-19 14:14:21,863 [localhost-startStop-1] INFO org.springframework.web.servlet.handler.SimpleUrlHandlerMapping- Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
2018-03-19 14:14:21,945 [localhost-startStop-1] INFO org.springframework.jdbc.datasource.DriverManagerDataSource- Loaded JDBC driver: com.mysql.jdbc.Driver
DataBase Connection Established
Mon Mar 19 14:14:22 EDT 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2018-03-19 14:14:22,144 [localhost-startStop-1] INFO org.hibernate.dialect.Dialect- HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
Mon Mar 19 14:14:22 EDT 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Session Factory Block Crossed
2018-03-19 14:14:22,448 [localhost-startStop-1] INFO org.springframework.orm.hibernate5.HibernateTransactionManager- Using DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@5b82fb3a] of Hibernate SessionFactory for HibernateTransactionManager
Transaction Done
2018-03-19 14:14:22,640 [localhost-startStop-1] INFO org.springframework.web.servlet.DispatcherServlet- FrameworkServlet 'dispatcher': initialization completed in 1678 ms
2018-03-19 14:14:22,654 [localhost-startStop-1] INFO org.apache.catalina.startup.HostConfig- Deployment of web application archive /deployments/ROOT.war has finished in 19,251 ms
2018-03-19 14:14:22,655 [localhost-startStop-1] INFO org.apache.catalina.startup.HostConfig- Deploying web application directory /deployments/manager
2018-03-19 14:14:23,746 [localhost-startStop-1] INFO org.apache.jasper.servlet.TldScanner- 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.
2018-03-19 14:14:23,751 [localhost-startStop-1] INFO org.apache.catalina.startup.HostConfig- Deployment of web application directory /deployments/manager has finished in 1,096 ms
2018-03-19 14:14:23,751 [localhost-startStop-1] INFO org.apache.catalina.startup.HostConfig- Deploying web application directory /deployments/docs
2018-03-19 14:14:24,449 [localhost-startStop-1] INFO org.apache.jasper.servlet.TldScanner- 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.
2018-03-19 14:14:24,451 [localhost-startStop-1] INFO org.apache.catalina.startup.HostConfig- Deployment of web application directory /deployments/docs has finished in 700 ms
2018-03-19 14:14:24,451 [localhost-startStop-1] INFO org.apache.catalina.startup.HostConfig- Deploying web application directory /deployments/examples
OpenShift Container Crash Image
My .java Config File
package com.redhat.api.config;
/* Username: userCWJ Password: TGYMNnYI6iohkPfF Database Name: sampledb Connection URL: mysql://mysql:3306/*/
import java.util.Properties;
import javax.sql.DataSource;
import org.hibernate.SessionFactory;
import org.springframework.beans.BeanInstantiationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.hibernate5.HibernateTransactionManager;
import org.springframework.orm.hibernate5.LocalSessionFactoryBuilder;
import org.springframework.stereotype.Component;
import com.redhat.api.entity.EntityClass;
@Component
@ComponentScan
@Configuration
public class ConfigClass{
@Autowired
@Bean(name = "dataSource")
public DataSource getMySQLDataSource() throws BeanInstantiationException, BeanDefinitionParsingException {
DriverManagerDataSource driverMgrDataSource = new DriverManagerDataSource();
driverMgrDataSource.setDriverClassName("com.mysql.jdbc.Driver");
driverMgrDataSource.setUrl("jdbc:mysql://mysql:3306/sampledb");
driverMgrDataSource.setUsername("userCWJ");
driverMgrDataSource.setPassword("TGYMNnYI6iohkPfF");
System.out.println("DataBase Connection Established");
return driverMgrDataSource;
}
@Autowired
@Bean(name = "sessionFactory")
public SessionFactory getSessionFactory() {
Properties hibernateProperties = new Properties();
hibernateProperties.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
hibernateProperties.setProperty("hibernate.show_sql", "true");
hibernateProperties.setProperty("hibernate.format_sql", "true");
hibernateProperties.setProperty("hibernate.hbm2ddl.auto", "update");
LocalSessionFactoryBuilder localSessionFacBuilder = new LocalSessionFactoryBuilder(getMySQLDataSource());
localSessionFacBuilder.addProperties(hibernateProperties);
localSessionFacBuilder.addAnnotatedClass(EntityClass.class);
try {
SessionFactory sessionFactory = localSessionFacBuilder.buildSessionFactory();
return sessionFactory;
}
catch (ExceptionInInitializerError ex) {
System.out.println(ex.getMessage());
}
finally {
System.out.println("Session Factory Block Crossed");
}
System.out.println("SessionFactory Created");
return null;
}
@Autowired
@Bean(name = "transactionManager")
public HibernateTransactionManager getHibernateTransactionManager(SessionFactory sessionFactory)
throws BeanInstantiationException, BeanDefinitionParsingException {
HibernateTransactionManager hibernateTranMgr = new HibernateTransactionManager(sessionFactory);
System.out.println("Transaction Done");
return hibernateTranMgr;
}}
My Pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.redhat</groupId>
<artifactId>api</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>api Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.12.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.12.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.12.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.3.12.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.5.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>4.3.11.Final</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<build>
<finalName>ROOT</finalName>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
As far my knoledge I guess, The error should cause because of some Dependencies in pom.xml, but i coudnt resolve.