AppComposer is designed to be 100% programmatic. @Default could activate it
however bit not other mode to allow to not set it.
Le 17 nov. 2015 04:58, "Yann BLAZART" <[email protected]>
a écrit :

> Thanks, it's working.
>
> Counterintuitive but it's working.
>
> I really have to write blog post on TomEE and Appcomposer as soon as
> possible.
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:[email protected]]
> Sent: lundi 16 novembre 2015 18:02
> To: [email protected]
> Subject: Re: TomEE 7.0.0-SNAPSHOT , ApplicationComposer, CDI,
> @Transactional
>
> try adding RequiredNewInterceptor in cdiInterceptors :p
>
> Romain Manni-Bucau
> @rmannibucau |  Blog | Github | LinkedIn | Tomitriber
>
>
> 2015-11-16 8:58 GMT-08:00 Yann BLAZART <
> [email protected]>:
> > Normally, as I read the code this should work, as @Priority is specified
> on interceptor :
> >
> > @Interceptor
> > @Transactional(Transactional.TxType.REQUIRES_NEW)
> > @Priority(200)
> > public class RequiredNewInterceptor extends InterceptorBase {
> >
> >
> >
> > From: Yann BLAZART
> > Sent: lundi 16 novembre 2015 17:47
> > To: [email protected]
> > Subject: TomEE 7.0.0-SNAPSHOT , ApplicationComposer, CDI,
> > @Transactional
> >
> > Hello,
> >
> > It seems that there is a problem with ApplicationComposer and CDI
> @Transactional service.
> >
> > The test class:
> >
> > @EnableServices("jaxrs")
> > @RunWith(ApplicationComposer.class)
> > @Classes(cdi = true, innerClassesAsBean = true,
> >         value = {
> >                 LoggerProducer.class,
> >                 RawService.class,
> >                 FeedsPUEntityManagerProducer.class
> >         }
> > )
> > public class RawServiceTest extends AbstractApplicationComposerHelper
> > {
> >
> >     @Resource(name = "feedsDS")
> >     private DataSource dataSource;
> >
> >     @Inject
> >     private RawService rawService;
> >
> >     @Test
> >     public void extractTest() throws Exception {
> >         Table tableFeedsFlows = new Table(dataSource,"FDS_FLOWS");
> >
> >         assertThatDB(tableFeedsFlows).hasNumberOfRows(0);
> >
> >         Long extractId = rawService.createExtractId();
> >
> >         assertThat(extractId).isNotNull();
> >         tableFeedsFlows = new Table(dataSource,"FDS_FLOWS");
> >         assertThatDB(tableFeedsFlows).hasNumberOfRows(1);
> >     }
> >
> >     @Module
> >     @PersistenceRootUrl(value = "") // must use value="" (BUG)
> >     public Persistence generatePU() throws Exception {
> >         return super.createPersistenceFromFile(FeedsFlows.class);
> >     }
> >
> >     @Configuration
> >     public Properties config() {
> >         Properties properties = new Properties();
> >         this.addDataSourceInProperties(properties, "feedsDS");
> >         this.overridePersistenceUnitProperties("feedsPU", properties,
> >                 PersistenceUnitXmlProperties.SCHEMA_GEN_DATABASE_ACTION,
> "drop-and-create");
> >         return properties;
> >     }
> > }
> >
> >
> >
> >
> > This seem to not work :
> >
> > With EJB it's ok.
> >
> > @Stateless
> > @TransactionManagement(TransactionManagementType.CONTAINER)
> > @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
> > public class RawService {
> >
> >     @Inject
> >     @FeedsPU
> >     private EntityManager entityManager;
> >
> >
> >     private Gson gson=  new Gson();
> >
> >     public Long createExtractId() {
> >         FeedsFlows extract = FeedsFlows.builder()
> >                 .startDate(new Date())
> >                 .flowType(FeedsFlowType.EXTRACT)
> >                 .rawCount(0L)
> >                 .rawBatchCount(0L)
> >                 .build();
> >         entityManager.persist(extract);
> >         return extract.getId();
> >     }
> >
> >
> > But with CDI @Transactionnal :
> >
> >
> > @Dependent
> > @Transactional(Transactional.TxType.REQUIRES_NEW)
> > //@Stateless
> > //@TransactionManagement(TransactionManagementType.CONTAINER)<mailto:/
> > /@TransactionManagement(TransactionManagementType.CONTAINER)>
> > //@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)<mailto:
> > //@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)>
> > public class RawService {
> >
> >     @Inject
> >     @FeedsPU
> >     private EntityManager entityManager;
> >
> >
> >     private Gson gson=  new Gson();
> >
> >     public Long createExtractId() {
> >         FeedsFlows extract = FeedsFlows.builder()
> >                 .startDate(new Date())
> >                 .flowType(FeedsFlowType.EXTRACT)
> >                 .rawCount(0L)
> >                 .rawBatchCount(0L)
> >                 .build();
> >         entityManager.persist(extract);
> >         return extract.getId();
> >     }
> >
> >
> >
> > javax.persistence.TransactionRequiredException
> >                 at
> org.apache.openejb.persistence.JtaEntityManager.assertTransactionActive(JtaEntityManager.java:159)
> >                 at
> org.apache.openejb.persistence.JtaEntityManager.persist(JtaEntityManager.java:189)
> >                 at
> com.bnpparibas.eqd.feeds.core.srccomp.services.RawService.createExtractId(RawService.java:48)
> >                 at
> com.bnpparibas.eqd.feeds.core.srccomp.services.RawServiceTest.extractTest(RawServiceTest.java:73)
> >                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> >                 at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> >                 at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >                 at java.lang.reflect.Method.invoke(Method.java:483)
> >                 at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> >                 at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> >                 at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> >                 at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> >                 at
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
> >                 at
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
> >                 at
> org.apache.openejb.junit.DeployApplication$1.call(DeployApplication.java:44)
> >                 at
> org.apache.openejb.junit.DeployApplication$1.call(DeployApplication.java:40)
> >                 at
> org.apache.openejb.testing.ApplicationComposers.evaluate(ApplicationComposers.java:1011)
> >                 at
> org.apache.openejb.junit.DeployApplication.evaluate(DeployApplication.java:40)
> >                 at
> org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> >                 at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
> >                 at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
> >                 at
> org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> >                 at
> org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
> >                 at
> org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
> >                 at
> org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
> >                 at
> org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
> >                 at
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
> >                 at
> org.junit.runners.ParentRunner.run(ParentRunner.java:363)
> >                 at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
> >                 at
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
> >                 at
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
> >                 at
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
> >                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> >                 at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> >                 at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >                 at java.lang.reflect.Method.invoke(Method.java:483)
> >                 at
> > com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
> >
> >
> > Do I miss something ?
> > Regards.
> >
> >
> >
> >
> >
> > This message and any attachments (the "message") is intended solely
> > for the intended addressees and is confidential.
> > If you receive this message in error,or are not the intended
> > recipient(s), please delete it and any copies from your systems and
> > immediately notify the sender. Any unauthorized view, use that does
> > not comply with its purpose, dissemination or disclosure, either whole
> > or partial, is prohibited. Since the internet cannot guarantee the
> > integrity of this message which may not be reliable, BNP PARIBAS (and
> its subsidiaries) shall not be liable for the message if modified, changed
> or falsified.
> > Do not print this message unless it is necessary,consider the
> environment.
> >
> > ----------------------------------------------------------------------
> > ------------------------------------------------------------
> >
> > Ce message et toutes les pieces jointes (ci-apres le "message") sont
> > etablis a l'intention exclusive de ses destinataires et sont
> confidentiels.
> > Si vous recevez ce message par erreur ou s'il ne vous est pas destine,
> > merci de le detruire ainsi que toute copie de votre systeme et d'en
> > avertir immediatement l'expediteur. Toute lecture non autorisee, toute
> > utilisation de ce message qui n'est pas conforme a sa destination,
> > toute diffusion ou toute publication, totale ou partielle, est
> > interdite. L'Internet ne permettant pas d'assurer l'integrite de ce
> > message electronique susceptible d'alteration, BNP Paribas (et ses
> > filiales) decline(nt) toute responsabilite au titre de ce message dans
> l'hypothese ou il aurait ete modifie, deforme ou falsifie.
> > N'imprimez ce message que si necessaire, pensez a l'environnement.
>

Reply via email to