[
https://issues.jboss.org/browse/ARQ-1150?page=com.atlassian.jira.plugin.s...
]
Bartosz Majsak closed ARQ-1150.
-------------------------------
@Transactional javax.persistence.TransactionRequiredException:
EntityManager must be access within a transaction
-----------------------------------------------------------------------------------------------------------------
Key: ARQ-1150
URL:
https://issues.jboss.org/browse/ARQ-1150
Project: Arquillian
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: Extension - Persistence
Affects Versions: persistence_1.0.0.Alpha5
Environment: Linux Ubuntu 12.04.1 LTS jdk64/jdk1.6.0_29 JBossAS 6.1.0.Final
managed Ant Ivy JUnit
Reporter: Matti Linnanvuori
Assignee: Bartosz Majsak
Using @Transactional does not avoid getting an error at em.persist.
[junit] EntityManager must be access within a transaction
[junit] javax.persistence.TransactionRequiredException: EntityManager must be access
within a transaction
[junit] at
org.jboss.jpa.deployment.ManagedEntityManagerFactory.verifyInTx(ManagedEntityManagerFactory.java:157)
[junit] at
org.jboss.jpa.deployment.PersistenceUnitDeployment.verifyInTx(PersistenceUnitDeployment.java:318)
[junit] at
org.jboss.jpa.impl.tx.TransactionScopedEntityManager.verifyInTx(TransactionScopedEntityManager.java:105)
[junit] at
org.jboss.jpa.impl.tx.TransactionScopedEntityManager.persist(TransactionScopedEntityManager.java:205)
[junit] at
com.ecolane.test.unit.TripRestTest.testLockRunsForTrips(TripRestTest.java:132)
[junit] at org.jboss.arquillian.junit.Arquillian$6$1.invoke(Arquillian.java:270)
[junit] at
org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60)
[junit] at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
[junit] at
org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
[junit] at
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
[junit] at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
[junit] at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
[junit] at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
[junit] at
org.jboss.arquillian.container.test.impl.execution.ContainerTestExecuter.execute(ContainerTestExecuter.java:38)
[junit] at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
[junit] at
org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
[junit] at
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
[junit] at
org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89)
[junit] at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
[junit] at
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
[junit] at
org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)
[junit] at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
[junit] at
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
[junit] at
org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
[junit] at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
[junit] at
org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
[junit] at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
[junit] at
org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111)
[junit] at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:263)
[junit] at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:226)
[junit] at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)
[junit] at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)
[junit] at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:240)
[junit] at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:185)
[junit] at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)
[junit] at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)
[junit] at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)
[junit] at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)
[junit] at
org.jboss.arquillian.junit.container.JUnitTestRunner.execute(JUnitTestRunner.java:65)
[junit] at
org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:160)
[junit] at
org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:126)
[junit] at
org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:90)
[junit] at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
[junit] at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
[junit] at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324)
[junit] at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)
[junit] at
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)
[junit] at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274)
[junit] at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)
[junit] at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
[junit] at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
[junit] at
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181)
[junit] at
org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285)
[junit] at
org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261)
[junit] at
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88)
[junit] at
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100)
[junit] at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159)
[junit] at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
[junit] at
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
[junit] at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
[junit] at
org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53)
[junit] at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
[junit] at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
[junit] at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654)
[junit] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)
[junit] at java.lang.Thread.run(Thread.java:662)
@Test
@Transactional
public void testLockRunsForTrips() throws java.text.ParseException,
java.io.IOException, org.xml.sax.SAXException {
final Trip trip = new Trip(0);
final MetaRoute metaRoute = new MetaRoute(0);
trip.setMetaRoute(metaRoute);
final Run run = new RealRun(new RunPK(0));
metaRoute.setRun(run);
final Route route = new Route(0);
route.setMetaRoute(metaRoute);
final Stop stop = new Stop();
stop.setStopType(DatabaseConstants.STOP_TYPE_AVAILABILITY_START);
stop.setRoute(route);
final String DATE = "2012-09-27";
final Calendar time = DatatypeConverter.parseDate(DATE);
final Calendar startTime = (Calendar) time.clone();
startTime.add(Calendar.HOUR, 8);
metaRoute.setStartTime(startTime.getTime());
startTime.add(Calendar.MINUTE, 15);
trip.setPromisedPickup(startTime.getTime());
em.persist(trip);
<dependency org="org.jboss.arquillian.container"
name="arquillian-jbossas-managed-6" rev="1.0.0.Final-SNAPSHOT" />
<dependency org="org.jboss.arquillian.extension"
name="arquillian-persistence-impl" rev="1.0.0.Alpha5"/>
<dependency org="org.jboss.arquillian.extension"
name="arquillian-transaction-api" rev="1.0.0.Final-SNAPSHOT"/>
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira