I finally found out the solution myself. The problem was that I had to extend BasicDataSourceFactory from org.apache.tomcat.dbcp.dbcp2 insted of extending BasicDataSourceFactory from org.apache.commons.dbcp2. Apparently, the both classes hace a few differences and do not manage authentication the same way. Hope it helps.