Issue
Getting this error while hitting PUT and POST API's. Tried multiple solutions but no luck. Can you please Help me with it.
nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.NoSuchMethodError: org.springframework.orm.jpa.JpaTransactionManager$JpaTransactionObject.setReadOnly(Z)V] with root cause
java.lang.NoSuchMethodError: org.springframework.orm.jpa.JpaTransactionManager$JpaTransactionObject.setReadOnly(Z)V at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:405) ~[spring-orm-5.2.3.RELEASE.jar:5.2.3.RELEASE]
Solution
This issue is basically because of version mis-match. It mostly occurs when you update your spring version. When the updated spring version does not match with your other versions like spring-orm, spring-jdbc, etc, this issue occurs. In my case there were two jars present for spring-jdbc(one was provided by spring started and other was externally added.) please check and try to use the latest version(you can get the version of jar's here ) or the one which was used by many people and has no vulnerability. If the latest one is not working, then please check with the other one. you have to find out which one is suitable for your spring version based on trial and error method only.
Answered By - Jeeva D
Answer Checked By - David Marino (JavaFixing Volunteer)