java - Vaadin and JPARepository: transaction errors -


i'm having troubles in integrating vaadin , spring-data (jparepositories in particular).

after following guidance of vaadin's team last webinar managed configure application using spring starter (spring boot), adding vaadin, jpa , postgresql database. using method straightforward , loading entities table works out of box having this

@autowired private projectdao projects;  // other code here ... grid.setcontainerdatasource(new beanitemcontainer<project>(project.class, projects.findall())); 

my repository just

@repository public class projectdao implements jparepository<project, long> {  } 

and, said, works flawlessly. problem when try save something: when trying save project via button click, example

btnsave.addclicklistener(e -> savecurrent());  private void savecurrent() { // ... here filesystem operations, nothing requires db connection     setmodified(); }  public void setmodified() {     project.setlastaccess(new date());     projects.saveandflush(project); } 

i exception:

org.springframework.dao.invaliddataaccessapiusageexception: no transaction in progress; nested exception javax.persistence.transactionrequiredexception: no transaction in progress. 

i've tried many different things, such marking setmodified method @transactional, or encapsulating setmodified service class, throws exception.

i find rather strange doesn't work "out of box", , i'd rather not work transactions myself, since there instruments that.

any appreciated

edit 12/05/2015

it seems problem appears when using external server, not embedded 1 provided spring-boot. test purposes can manage use built-in, have deploy application on existing server, issue be? tomcat's configuration?

if needs answer i'll leave here found out after few days of breaking head on it.

before deploying application changed configurations on main class generated spring initializr (the application one) , made extend springbootservletinitializer because following guide found in the official spring blog. turns out in fact not necessary because set "war" in spring initializr beginning, application had class extending one, , result when deploying on tomcat, web application started twice, application configured twice , 2 persistence units instantiated. error, because after reverting changes made application worked fine.

tl;dr: if use spring initializr create war application don't touch anything.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -