Problem with Vaadin/Spring (SprintIntegration plugin), and Transactional DB

Hi Folks,

I’m tring to put a simple Vaadin/Spring/JPA example together using H2 db.

I have a problem when I try to do a transactional insert on the database, and I’ve spent a long time trying to get to the issue. I’m hoping someone can help.

I have a simple MainUI → Service → DAO call to persist a simple entity.
If I include the @Transactional annotation on the persist method in Service or DAO, I get the exception at the bottom of this email. (the exception starts with Caused by: java.lang.NoSuchMethodError: org.springframework.transaction.aspectj.AbstractTransactionAspect.invokeWithinTransaction). If I exclude @Transcational, then all seems to go OK.

Has anybody done this successfully? If so, what am I missing?

I’m using the SpringIntegration plugin, and I think web.xml is as expected, and works OK.

For brevity, I’ve given bare bones of source below (project does compile and work when @Transaction is omited). I’m happy to provide more detail if necessary

My ‘hunch’ is that this could be a scope issue between Vaadin and Spring/JPA/Hibernate transactions - apart from that I’m stuck

I really appreciate any help here.

Kind Regards
Ian Hunter


  1. spring context XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<context:spring-configured />

<context:component-scan base-package=“com.orchardsoftware” />



<tx:annotation-driven transaction-manager=“txManager” proxy-target-class=“true” />

-------------------------------------------------------------------------------------------------------------------------------------
  1. MainUI.java

@Theme(“runo”)
@Component
@Scope(“prototype”)
public class MainUI extends UI {

@Autowired
private MyDao dao;

@SuppressWarnings("serial")
@Override
protected void init(VaadinRequest request) {
	setSizeFull();

	Long id = dao.persist(new Entity("Name1", "xxxx", "RESULT", 22, "")); // Exception thrown here
	LOGGER.info("Persisted " + id);

}

}


  1. Dao.java

@Repository
@Transactional(readOnly = true)
public class MyDaoImpl extends GenericDaoImpl implements MyDao {

public MyDaoImpl() {
	super();
}

public MyDaoImpl(EntityManager em) {
	super();
}

@Override
//@Transactional() // Comment out and it works, comment in and exception thrown
public T persist(final T t) {
	this.entityManager.persist(t);
	return t;
}

}

  1. persistence.xml
<?xml version="1.0" encoding="UTF-8"?>

<persistence-unit name="pname" transaction-type="RESOURCE_LOCAL">
	<provider>org.hibernate.ejb.HibernatePersistence</provider>
	<class>com.orchardsoftware.domain.Rule</class>
	
	<exclude-unlisted-classes>false</exclude-unlisted-classes>
	
	
	<properties>
		<property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
		<property name="javax.persistence.jdbc.url" value="jdbc:h2:˜/riskneth2db" />
		<property name="javax.persistence.jdbc.user" value="sa" />
		<property name="javax.persistence.jdbc.password" value="sa" />
		<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"></property>
		<property name="hibernate.connection.driver_class" value="org.h2.Driver" />

		<property name="hibernate.hbm2ddl.auto" value="create-drop" />

	</properties>
</persistence-unit>
-------------------------------------------------------------------------------------------------------------------------------------

EXCEPTION…
Caused by: java.lang.NoSuchMethodError: org.springframework.transaction.aspectj.AbstractTransactionAspect.invokeWithinTransaction(Ljava/lang/reflect/Method;Ljava/lang/Class;Lorg/springframework/transaction/interceptor/TransactionAspectSupport$InvocationCallback;)Ljava/lang/Object;
at org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96c(AbstractTransactionAspect.aj:63)
at com.orchardsoftware.risknet.business.RuleManagerImpl.createRule(RuleManagerImpl.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy22.createRule(Unknown Source)
at com.orchardsoftware.risknet.gui.MainUI.init(MainUI.java:63)
at com.vaadin.ui.UI.doInit(UI.java:610)
at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:223)
at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:73)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:37)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1371)
… 25 more