I have an app created using Hibernate 4.1.4.Final and Spring 3.1.2.RELEASE. I created it using SpringSource Tool Suite 2.9.2.RELEASE.
The issue is that the app works fine when deployed to the vFabric tc Server v2.7 included in STS, but when I deploy it to a standalone Tomcat server (v7.0.29) the app runs fine, but writes to the database (MySQL) don't happen. Reads from the database work fine. The odd bit is that none of the logs show any exceptions or any issues creating the datasource, entity manager, etc.. I am not using a JNDI datasource. This is my spring datasource definition:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close"
p:driverClassName="com.mysql.jdbc.Driver"
p:url="jdbc:mysql://tomcat.shire.net:3306/weather"
p:username="mysql"
p:password="ms8yt9"/>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:dataSource-ref="dataSource"/>
<context:component-scan base-package="com.bryant.weather.dao" />
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory"/>
<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager" />
</beans>
The entity manager is injected into my code by Spring:
Code:
@PersistenceContext
public void setEntityManager(EntityManager entityManager)
{
this.entityManager = entityManager;
}
I suspect that it has something to do with the MySQL setup and the granting of privileges to a user based on the host, but I have tried every combination of "grant all on dbname.*..." that I can think of.
Generally, if there are exceptions thrown somewhere I can puzzle through these kind of issues, but in this case I am stumped. I don't see any exceptions, but writes to the DB just don't work.
The thought just occurred to me that maybe it is a transaction problem somehow? Do I need to change the Tomcat config somehow to support transactions?
Any thoughts would be appreciated. I can post any additional info that is needed to help debug the issue.
Thanks,
Adam