javax.persistence.TransactionRequiredException: no transaction is in progress
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.checkTransactionNeeded(AbstractEntityManagerImpl.java:1171)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:1332)
at sun.reflect.GeneratedMethodAccessor71.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:342)
at com.sun.proxy.$Proxy72.flush(Unknown Source)
@RunWith(Cucumber.class)
@CucumberOptions(features = {"src/test/java/tests/cucumber/test.feature"},
glue = { "tests.cucumber",
"cucumber.runtime.java.spring.hooks"})
public class MyCucumberTest {
}@ContextConfiguration("classpath:cucumber.xml")
public class MyCucumberSteps {
@Inject
MyService myService;
@Given
...
@When
...
@Then
...
}Hi,I'm currently upgrading from Cucumber v1.0.2 to v1.1.6 and can't get the JPA transactions to work. After upgrading the beans are still injected to the step object but the tests fail with:javax.persistence.TransactionRequiredException: no transaction is in progress
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.checkTransactionNeeded(AbstractEntityManagerImpl.java:1171)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:1332)
at sun.reflect.GeneratedMethodAccessor71.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:342)
at com.sun.proxy.$Proxy72.flush(Unknown Source)Example:@RunWith(Cucumber.class)
@CucumberOptions(features = {"src/test/java/tests/cucumber/test.feature"},
glue = { "tests.cucumber",
"cucumber.runtime.java.spring.hooks"})
public class MyCucumberTest {
}
glue = { "tests.cucumber",
"cucumber.api.spring"})Per Segersten wrote:Hi,I'm currently upgrading from Cucumber v1.0.2 to v1.1.6 and can't get the JPA transactions to work. After upgrading the beans are still injected to the step object but the tests fail with:javax.persistence.TransactionRequiredException: no transaction is in progress
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.checkTransactionNeeded(AbstractEntityManagerImpl.java:1171)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:1332)
at sun.reflect.GeneratedMethodAccessor71.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:342)
at com.sun.proxy.$Proxy72.flush(Unknown Source)Example:@RunWith(Cucumber.class)
@CucumberOptions(features = {"src/test/java/tests/cucumber/test.feature"},
glue = { "tests.cucumber",
"cucumber.runtime.java.spring.hooks"})
public class MyCucumberTest {
}Hi,
The SpringTransactionHook class has been moved to the package cucumber.api.spring so the glue parameter need to be changed to:
glue = { "tests.cucumber",
"cucumber.api.spring"})
However there are unresolved issues with Spring in the newest versions Cucumber-JVM; v1.1.4?, v1.1.5 and v1.1.6. So it may be hard to get transactions with Spring to work on those versions (AFAIK, I'm not using Spring myself), see #569, #637, #644 and #649.
Best Regards
Björn
I'm usung the same spring configuration as before:@ContextConfiguration("classpath:cucumber.xml")
public class MyCucumberSteps {
@Inject
MyService myService;
@Given
...
@When
...
@Then
...
}What is needed to create transactions in v1,1.6?RegardsPer
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<import resource="classpath:/cucumber/runtime/java/spring/cucumber-glue.xml"/>
<bean class="cucumber.api.spring.SpringTransactionHooks"/>
@Autowired
private SpringTransactionHooks springTransactionHooks;
@Before(value = {"@txn"}, order = 100)
public void startTransaction() {
springTransactionHooks.startTransaction();
}
@After(value = {"@txn"}, order = 100)
public void rollBackTransaction() {
springTransactionHooks.rollBackTransaction();
}