Hello!
I'm implementing an example program using a plain JDO DAO (like the one in the Spring Reference Manual). Unfortunately, I get an IllegalStateException: "No JDO PersistenceManager bound to thread, and configuration does not allow creation of non-transactional one here"
The example is a simple command-line app:
The DAO code looks like this:Code:public static void main(String[] args) { ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml"); MyDao myDao = (MyDao) ctx.getBean("myDao"); myDao.doSomething(); }
And this is my configuration:Code:public class MyDao { private PersistenceManagerFactory pmf; public MyDao(PersistenceManagerFactory pmf) { this.pmf = pmf; } public void doSomething() { PersistenceManager pm = pmf.getPersistenceManager(); //PersistenceManager pm = PersistenceManagerFactoryUtils.getPersistenceManager(pmf, false); } }
The Exception occurs regardless if I use "pmf.getPersistenceMangager()" or "PersistenceManagerFactoryUtils.getPersistenceMana ger(pmf, false)".Code:<bean id="pmf" class="com.signsoft.ibo.client.PersistenceManagerFactoryImpl" destroy-method="close"> </bean> <bean id="pmfProxy" class="org.springframework.orm.jdo.TransactionAwarePersistenceManagerFactoryProxy"> <property name="targetPersistenceManagerFactory" ref="pmf"/> <property name="allowCreate" value="false"/> </bean> <bean id="myDao" class="MyDao"> <constructor-arg ref="pmfProxy"/> </bean> <bean id="transactionManager" class="org.springframework.orm.jdo.JdoTransactionManager"> <property name="persistenceManagerFactory" ref="pmfProxy"/> </bean> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="*" propagation="REQUIRED"/> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="serviceMethods" expression="execution(* MyDao.*(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethods"/> </aop:config>
I would prefer a DAO that does not have any Spring dependencies, though.


Reply With Quote