0

I am upgrading my Spring 3 to Spring 4, and was facing issue reported in OpenEntityManagerInViewInterceptor- No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call

Now to resolve it I am putting @Transactional in my controller entry method and when I do so I am getting below exception at deployment:

Caused by: java.lang.IllegalStateException: Cannot convert value of type 'com.sun.proxy.$Proxy47 implementing com.krawler.spring.accounting.payment.accPaymentDAO,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised,org.springframework.core.DecoratingProxy' to required type 'com.krawler.spring.accounting.payment.accPaymentImpl' for property 'accPaymentDAOobj': no matching editors or conversion strategy found

This class only has messageSource entry for bean injection. And it is separate class from the controller. When I remove the @Transactional from Controller method, I dont see this error. Please let me know what can be done.

kapil gupta
  • 335
  • 3
  • 19
  • `@Transactional` should be on the service layer not your controllers. Also it appears as if you are programming to concrete classes instead of interfaces. – M. Deinum Nov 01 '18 at 11:29
  • @M.Deinum - I know the @ Transactional should be on service but my application has lot of code inside controller, so please let me know what can be done with controller. And please elaborate your statement "programming to concrete classes instead of interfaces" – kapil gupta Nov 01 '18 at 12:17
  • @M.Deinum - I got your point, actually we are using interfaces only but for few classes which we have made as a thread are used as classes, and those are throwing error – kapil gupta Nov 02 '18 at 04:39
  • They will if you also implement an interface as a JDK Dynamic Proxy (interface based) will be created. However do you really need a thread? Wouldn't it be better to implement `Runnable` and let a `TaskExecutor` execute them. Generally you shouldn't be messing around with Threads yourself. – M. Deinum Nov 05 '18 at 06:55

0 Answers0