Found it.
There was a tests JAR in Infinispan Hibernate dependency that contained hibernate.properties file that got loaded.
Domanda
Here's the configuration:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${connection.driverclass}"/>
<property name="url" value="${connection.url}/${connection.database}"/>
<property name="username" value="${connection.username}"/>
<property name="password" value="${connection.password}"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingLocations">
<list>
<value>classpath:path/to/hibernate/mappings/*.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=${hibernate.dialect}
</value>
</property>
</bean>
Everything works as expected when I deploy in-place using IDE (IntelliJ IDEA), but when I deploy to stand-alone Tomcat 7, BasicDataSource throws UnsuportedOperationException.
Debugging showed that the exception is thrown because the BasicDataSource:getConnection is called with username 'sa', further showing that LocalSessionFactoryBean is getting instantiated with that username. I'm completely baffled by this since I can't find where the username gets injected.
I'm using MariaDB.
Soluzione
Found it.
There was a tests JAR in Infinispan Hibernate dependency that contained hibernate.properties file that got loaded.