When you turn on and off tomcat`a sometimes this error occurs
24-Aug-2016 21: 58: 01.947 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] registered JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. The driver has been forcibly unregistered.
24-Aug-2016 21: 58: 01.948 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] seems 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)
In the tomcat8/lib folder, the jdbc connector was thrown up, it did not help. I use 5.1.38
UPDATE: For example, as I get the user, I will give snippets of code
Service
@Transactional @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { User user = userDao.getByUsername(username); DAO
@Override public User getByUsername(String username) { Criteria criteria = getSession().createCriteria(User.class); criteria.add(Restrictions.eq("username", username)); return (User)criteria.uniqueResult(); } According to the idea I should not close getSession Hibernate
xml
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="packagesToScan"> <list> <value>ru.erp.models</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">false</prop> <prop key="hibernate.connection.charSet">UTF-8</prop> <prop key="hibernate.enable_lazy_load_no_trans">true</prop> </props> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="${db.url}"/> <property name="username" value="${db.username}"/> <property name="password" value="${db.password}"/> <property name="initialSize" value="10" /> <property name="maxActive" value="500" /> <property name="maxIdle" value="40" /> <property name="minIdle" value="1" /> <property name="maxWait" value="5000" /> <property name="removeAbandoned" value="true" /> <property name="validationQuery" value="SELECT 1"/> <property name="testOnBorrow" value="true"/> </bean>