Hi,
Again, another noob question - doubly embarassing as I gave up on my other problem (trying to get a JTA under Tomcat - it worked in JBoss, but I was trying to get something that started quicker). Given I am only using one resource, I probably do not need JTA anyway and so perhaps its a configuration issue.
We have another process that uses Spring/JPA/Hibernate for DB access. This is currently a standalone JVM app - not in JBoss/a container. Perhaps the solution is to move it into JBoss...
The problem is that the EntityManager instance is not being initialised. Its largely using the same spring config/classes as we use in the webapp via JBoss.
In particular here are the relevant bits of the config:
The service classes (which are the same for both processes) are marked like this:Code:<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" > <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean> <tx:annotation-driven/> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="dataSource"/> <!-- <property name="loadTimeWeaver"> <bean class="org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver"/> </property> --> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <!--<property name="showSql" value="true"/>--> </bean> </property> </bean> <bean id="dataSource" class="oracle.jdbc.pool.OracleConnectionPoolDataSource"> <property name="user" value="???"/> <property name="password" value="???"/> <property name="URL" value="jdbc:oracle:thin:@zsts490705:9501:SOPHI2DV"/> </bean>
and the DAOs like this:Code:@Transactional(readOnly = true) public class TemplateManager {
I don't get any specific errors, just that the entityManager stays null.Code:@PersistenceContext private EntityManager entityManager;
Its like there is some further bootstrapping missing that I need to do. Perhaps something gets done in a webapp through default bean wiring and I am missing in the non-webapp version.
I have tried adding a transaction interceptor, but that was based on a fairly old blog and is possibly the wrong route:
So, any tips on where I am going wrong?Code:<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"> <property name="transactionManager" ref="transactionManager" /> <property name="transactionAttributeSource"> <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource" /> </property> </bean> <bean id="templateDaoTarget" class="com.rabobank.mithrasweb.dao.template.impl.TemplateDaoJdbc"> </bean> <bean id="templateDao" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"> <value>com.rabobank.mithrasweb.dao.template.TemplateDao</value> </property> <property name="interceptorNames"> <list> <idref local="transactionInterceptor" /> <idref local="templateDaoTarget" /> </list> </property> </bean>


Reply With Quote
