Problems with DataSource on a tomcat server 8

2

I have a web project on a Tomcat server (Windows 2008) with a MariaDB 10.0 database, for the connection we use the mysql driver "mysql-connector-java-5.1.36-bin.jar".

I have made a migration from TOMCAT from version 6 to 8. Apparently everything worked fine, I made the login correctly, but after a while (in about 15 min) I realized that the application did not login, it is waiting for a response from the server because the login accesses the database, while if I access a page of the application without a connection to the database, it solves it correctly.

Even if that application does not work, others that access the database work correctly.

I have been investigating the code of my servlet, making debug I have discovered that when the login starts to fail it is because the application waits for the context to give it a connection from the pool.

Here is my java code:

Context ctx = new InitialContext();
fuenteDatos = (DataSource) ctx.lookup("java:comp/env/jdbc/dataBase1");

Here you have the code of the context.xml:

<Resource name="jdbc/dataBase1" global="jdbc/dataBase1"
            auth="Container"
            type="javax.sql.DataSource"
            maxActive="100" 
            maxIdle="10" 
            maxWait="-1"
            removeAbandoned="true" 
            removeAbandonedTimeout="10"
            logAbandoned="false" 
            username="ares" 
            password="ares" 
            driverClassName="com.mysql.jdbc.Driver"
            LogSql="true"
            url="jdbc:mysql://localhost:3306/dataBase1?zeroDateTimeBehavior=convertToNull&amp;useUnicode=true&amp;characterEncoding=UTF8">  <property name="Pool.PingQuery" value="select 1"/>
<property name="Pool.PingEnabled" value="true"/>
<property name="Pool.PingConnectionsOlderThan" value="3600000"/> <!-- 1 hr -->
<property name="Pool.PingConnectionsNotUsedFor" value="10000"/> <!-- ping db 10 sec -->     

Here I attach the code of my web.xml that refers to the connection pool:

<resource-ref>
    <description>DB Connection</description>
    <res-ref-name>jdbc/dataBase1</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

And here some MariaDB connection variables:

Thanks in advance!

    
asked by Eux 24.08.2016 в 15:38
source

1 answer

1

I have already found the solution to the problem. The problem was in the context.xml the maxActive attribute in tomcat 8 does not exist. The substitute is maxTotal and when I did not find the attribute, I set the default value which is 8 and that caused the application to collapse.

    
answered by 29.08.2016 / 13:13
source