You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by hwaastad <he...@waastad.org> on 2014/10/03 16:58:12 UTC

ContainerManagedTransactionStrategy

Hi,
i was wondering if there is any doc on the usage of
ContainerManagedTransactionStrategy?

I've been trying to add this in beans.xml, but I only get a:

javax.persistence.PersistenceException: java.lang.NullPointerException
	at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getIdentifier(EntityManagerFactoryDelegate.java:719)
	at
org.apache.deltaspike.data.impl.handler.CdiQueryInvocationContext.isNew(CdiQueryInvocationContext.java:93)
.
.
.

Caused by: java.lang.NullPointerException
	at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getIdentifier(EntityManagerFactoryImpl.java:85)
	at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getIdentifier(EntityManagerFactoryDelegate.java:715)

br hw



--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/ContainerManagedTransactionStrategy-tp4659084.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: ContainerManagedTransactionStrategy

Posted by hwaastad <he...@waastad.org>.
Hi,
those two are just for enabling result query cache by default on
namedqueries and flush on commit (needed for using lookups in custom
validators, if not setting flushmode on entitymanager, that is...)

br hw



--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/ContainerManagedTransactionStrategy-tp4659084p4659104.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: ContainerManagedTransactionStrategy

Posted by Karl Kildén <ka...@gmail.com>.
I use TomEE with Eclipselink and have no issues. I do not recognize nor use
the eclipselink properties you have in persistence.xml. Otherwise we have
very similar configuration.



On 5 October 2014 16:58, hwaastad <he...@waastad.org> wrote:

> Hi TH,
> and thanks for answering.
>
> I'm running JTA datasource and running repository within an EJB
> transaction.
>
> However, what I found out is that I need the entoitymanagerconfig with
> resolver or else this error occurs.
>
> I've made a simple test project
> (https://github.com/hwaastad/TomeeDsValidation.git)
>
> So if you remove the
> @EntityManagerConfig(entityManagerResolver =
> CrmEntityManagerResolver.class,flushMode = FlushModeType.COMMIT)
>
> Then this error will occure.
> Any idea why?
>
>
> br hw
>
>
>
> --
> View this message in context:
> http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/ContainerManagedTransactionStrategy-tp4659084p4659102.html
> Sent from the Apache DeltaSpike Incubator Discussions mailing list archive
> at Nabble.com.
>

Re: ContainerManagedTransactionStrategy

Posted by hwaastad <he...@waastad.org>.
Hi TH,
and thanks for answering.

I'm running JTA datasource and running repository within an EJB transaction.

However, what I found out is that I need the entoitymanagerconfig with
resolver or else this error occurs.

I've made a simple test project
(https://github.com/hwaastad/TomeeDsValidation.git)

So if you remove the
@EntityManagerConfig(entityManagerResolver =
CrmEntityManagerResolver.class,flushMode = FlushModeType.COMMIT)

Then this error will occure.
Any idea why?


br hw



--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/ContainerManagedTransactionStrategy-tp4659084p4659102.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: ContainerManagedTransactionStrategy

Posted by hwaastad <he...@waastad.org>.
Hi,
no, the same error happens.

br hw


-----

Producing entitymanager.....
SEVERE - EjbTransactionUtil.handleSystemException:
java.lang.NullPointerException
javax.persistence.PersistenceException: java.lang.NullPointerException
	at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getIdentifier(EntityManagerFactoryDelegate.java:719)
	at
org.apache.deltaspike.data.impl.handler.CdiQueryInvocationContext.isNew(CdiQueryInvocationContext.java:93)
	at
org.apache.deltaspike.data.impl.handler.EntityRepositoryHandler.save(EntityRepositoryHandler.java:66)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at
org.apache.deltaspike.data.impl.builder.DelegateQueryBuilder.invoke(DelegateQueryBuilder.java:117)
	at
org.apache.deltaspike.data.impl.builder.DelegateQueryBuilder.invoke(DelegateQueryBuilder.java:97)
	at
org.apache.deltaspike.data.impl.builder.DelegateQueryBuilder.execute(DelegateQueryBuilder.java:57)
	at
org.apache.deltaspike.data.impl.builder.QueryBuilder.executeQuery(QueryBuilder.java:57)
	at
org.apache.deltaspike.data.impl.tx.TransactionalQueryRunner$1.proceed(TransactionalQueryRunner.java:77)
	at
org.apache.deltaspike.jpa.impl.transaction.ContainerManagedTransactionStrategy.execute(ContainerManagedTransactionStrategy.java:40)
	at
org.apache.deltaspike.data.impl.tx.TransactionalQueryRunner.executeTransactional(TransactionalQueryRunner.java:72)
	at
org.apache.deltaspike.data.impl.tx.TransactionalQueryRunner.executeQuery(TransactionalQueryRunner.java:54)
	at
org.apache.deltaspike.data.impl.handler.QueryHandler.invoke(QueryHandler.java:79)
	at
org.apache.deltaspike.partialbean.impl.PartialBeanAbstractMethodHandler.invoke(PartialBeanAbstractMethodHandler.java:44)
	at
org.apache.deltaspike.partialbean.impl.MethodHandlerProxy.invoke(MethodHandlerProxy.java:35)
	at com.sun.proxy.$Proxy112.invoke(Unknown Source)
	at
org.waastad.tomeedsvalidation.repository.CustomerRepository_$$_javassist_1.save(CustomerRepository_$$_javassist_1.java)
	at
org.waastad.tomeedsvalidation.ejb.BusinessBean.save(BusinessBean.java:24)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at
org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
	at
org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
	at
org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:181)
	at
org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:100)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at
org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
	at
org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
	at
org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:85)
	at
org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:227)
	at
org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:194)
	at
org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:308)
	at
org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:303)
	at
org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:92)
	at
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:308)
	at
org.waastad.tomeedsvalidation.ejb.BusinessBean$$LocalBeanProxy.save(org/waastad/tomeedsvalidation/ejb/BusinessBean.java)
	at
org.waastad.tomeedsvalidation.entity.CustomerTest.test12(CustomerTest.java:81)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at
org.apache.openejb.junit.jee.statement.InjectStatement.evaluate(InjectStatement.java:77)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at
org.apache.openejb.junit.jee.statement.DecoratingStatement.evaluate(DecoratingStatement.java:32)
	at
org.apache.openejb.junit.jee.statement.DecoratingStatement.evaluate(DecoratingStatement.java:32)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
	at
org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
	at
org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at
org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
	at
org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
	at
org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
	at
org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
Caused by: java.lang.NullPointerException
	at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getIdentifier(EntityManagerFactoryImpl.java:85)
	at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getIdentifier(EntityManagerFactoryDelegate.java:715)
	... 77 more




--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/ContainerManagedTransactionStrategy-tp4659084p4659108.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: ContainerManagedTransactionStrategy

Posted by Thomas Hug <th...@gmail.com>.
Can you remove the ApplicationScoped on the EMProducer and see if that
helps?

On Sun, Oct 5, 2014 at 4:58 PM, hwaastad <he...@waastad.org> wrote:

> Hi TH,
> and thanks for answering.
>
> I'm running JTA datasource and running repository within an EJB
> transaction.
>
> However, what I found out is that I need the entoitymanagerconfig with
> resolver or else this error occurs.
>
> I've made a simple test project
> (https://github.com/hwaastad/TomeeDsValidation.git)
>
> So if you remove the
> @EntityManagerConfig(entityManagerResolver =
> CrmEntityManagerResolver.class,flushMode = FlushModeType.COMMIT)
>
> Then this error will occure.
> Any idea why?
>
>
> br hw
>
>
>
> --
> View this message in context:
> http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/ContainerManagedTransactionStrategy-tp4659084p4659102.html
> Sent from the Apache DeltaSpike Incubator Discussions mailing list archive
> at Nabble.com.
>