Re: JPA doc related to EM Producer

2014-10-03 Thread hwaastad
Hi,
maybe a little late on this but I've been testing differet scenarios using
tomee and deltaspike and using JTA these are the ones I found out working:

@Produces
@ApplicationScoped
public EntityManagerFactory createEntityManagerFactory() {
System.out.println(Producing EMF..);
return Persistence.createEntityManagerFactory(ValidationPU);
}

@Produces
public EntityManager createEntityManager(EntityManagerFactory
entityManagerFactory) {
System.out.println(Producing entitymanager.);
return entityManagerFactory.createEntityManager();
}

with a little help from @romain i realized that my em's were resource_local
using the producer shown in the DS docs.

br hw



--
View this message in context: 
http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/JPA-doc-related-to-EM-Producer-tp4658999p4659077.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at 
Nabble.com.


Re: JPA doc related to EM Producer

2014-10-03 Thread Karl Kildén
Can you try this?

@PersistenceContext(unitName = APP_NAME)
private EntityManager entityManager;

@Produces
@RequestScoped
protected EntityManager createEntityManager() {
return this.entityManager;
}

On 3 October 2014 08:02, hwaastad he...@waastad.org wrote:

 Hi,
 maybe a little late on this but I've been testing differet scenarios using
 tomee and deltaspike and using JTA these are the ones I found out working:

 @Produces
 @ApplicationScoped
 public EntityManagerFactory createEntityManagerFactory() {
 System.out.println(Producing EMF..);
 return Persistence.createEntityManagerFactory(ValidationPU);
 }

 @Produces
 public EntityManager createEntityManager(EntityManagerFactory
 entityManagerFactory) {
 System.out.println(Producing entitymanager.);
 return entityManagerFactory.createEntityManager();
 }

 with a little help from @romain i realized that my em's were resource_local
 using the producer shown in the DS docs.

 br hw



 --
 View this message in context:
 http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/JPA-doc-related-to-EM-Producer-tp4658999p4659077.html
 Sent from the Apache DeltaSpike Incubator Discussions mailing list archive
 at Nabble.com.



Re: JPA doc related to EM Producer

2014-10-03 Thread hwaastad
Hi,
I've tried but realized an issue when using deltaspike and cdi injection in
custom validators.

the entity is flushed before validation is run and hence will fail.

I made a test project on github
(https://github.com/hwaastad/TomeeDsValidation.git) and u'll see that
validation fails if the entitymanager is produced like this.

br hw



--
View this message in context: 
http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/JPA-doc-related-to-EM-Producer-tp4658999p4659079.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at 
Nabble.com.


Re: JPA doc related to EM Producer

2014-10-03 Thread Romain Manni-Bucau
IIRC with deltaspike you need a custom transaction strategy for JTA
(DS is really designed for resource local *by default*)


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-10-03 8:36 GMT+02:00 hwaastad he...@waastad.org:
 Hi,
 I've tried but realized an issue when using deltaspike and cdi injection in
 custom validators.

 the entity is flushed before validation is run and hence will fail.

 I made a test project on github
 (https://github.com/hwaastad/TomeeDsValidation.git) and u'll see that
 validation fails if the entitymanager is produced like this.

 br hw



 --
 View this message in context: 
 http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/JPA-doc-related-to-EM-Producer-tp4658999p4659079.html
 Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at 
 Nabble.com.


Re: JPA doc related to EM Producer

2014-10-03 Thread hwaastad
Hi, DS doc specifies the use of BeanManagedUserTransactionStrategy in
beans.xml.

Should'nt that be enough?

..or containermanaged strategy?

br hw




--
View this message in context: 
http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/JPA-doc-related-to-EM-Producer-tp4658999p4659081.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at 
Nabble.com.


[jira] [Created] (DELTASPIKE-736) MockAwareInjectionTargetWrapper breaks interceptors in unit tests

2014-10-03 Thread Ronald Steininger (JIRA)
Ronald Steininger created DELTASPIKE-736:


 Summary: MockAwareInjectionTargetWrapper breaks interceptors in 
unit tests
 Key: DELTASPIKE-736
 URL: https://issues.apache.org/jira/browse/DELTASPIKE-736
 Project: DeltaSpike
  Issue Type: Bug
  Components: TestControl
Affects Versions: 1.0.3
 Environment: OpenWebBeans 1.2.6
Reporter: Ronald Steininger


The automatic usage of MockAwareInjectionTargetWrapper breaks method-level 
interceptors under OWB:

org.apache.webbeans.config.BeansDeployer#validate creates the interceptor stack 
of all beans while validating the deployment (Line 474). This code depends on 
owbBean.getProducer() returning an AbstractProducer (Line 462).

TestControl replaces that AbstractProducer in some circumstances with an 
instance of MockAwareInjectionTargetWrapper, completely deactivating the 
if-branch which would active the interceptors.

It seems that, depending where the interceptor binding is defined on the 
intercepted bean, interceptors work or don't work: using the annotation on the 
class level results in getProducer returning a AbstractProducer - interceptors 
work. Defining interceptors only on methods shows the broken behaviour 
described here.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Created] (DELTASPIKE-737) MockExtension can't be deactivated

2014-10-03 Thread Ronald Steininger (JIRA)
Ronald Steininger created DELTASPIKE-737:


 Summary: MockExtension can't be deactivated
 Key: DELTASPIKE-737
 URL: https://issues.apache.org/jira/browse/DELTASPIKE-737
 Project: DeltaSpike
  Issue Type: Bug
  Components: TestControl
Affects Versions: 1.0.3
 Environment: OpenWebBeans 1.2.6
Reporter: Ronald Steininger


Using an ClassDeactivator to deactivate the MockExtension (like described in 
http://deltaspike.apache.org/documentation/test-control.html#_liquibase) leads 
to a StackOverflowError:

{code}
java.lang.StackOverflowError
at 
org.apache.webbeans.container.BeanCacheKey.getQualifierHashCode(BeanCacheKey.java:184)
at 
org.apache.webbeans.container.BeanCacheKey.computeHashCode(BeanCacheKey.java:167)
at 
org.apache.webbeans.container.BeanCacheKey.init(BeanCacheKey.java:67)
at 
org.apache.webbeans.container.InjectionResolver.implResolveByType(InjectionResolver.java:485)
at 
org.apache.webbeans.container.InjectionResolver.implResolveByType(InjectionResolver.java:435)
at 
org.apache.webbeans.container.BeanManagerImpl.getBeans(BeanManagerImpl.java:578)
at 
org.apache.webbeans.container.InjectableBeanManager.getBeans(InjectableBeanManager.java:117)
at 
org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference(BeanProvider.java:141)
at 
org.apache.deltaspike.testcontrol.impl.mock.MockAwareInjectionTargetWrapper.produce(MockAwareInjectionTargetWrapper.java:54)
at 
org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:121)
at org.apache.webbeans.component.ManagedBean.create(ManagedBean.java:55)
at 
org.apache.webbeans.context.creational.BeanInstanceBag.create(BeanInstanceBag.java:76)
at 
org.apache.webbeans.context.AbstractContext.getInstance(AbstractContext.java:160)
at 
org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
at 
org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:100)
at 
org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:70)
at 
org.apache.deltaspike.testcontrol.impl.mock.SimpleMockManager$$OwbNormalScopeProxy0.getMock(org/apache/deltaspike/testcontrol/impl/mock/SimpleMockManager.java)
at 
org.apache.deltaspike.testcontrol.impl.mock.MockAwareInjectionTargetWrapper.produce(MockAwareInjectionTargetWrapper.java:59)
at 
org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:121)
at org.apache.webbeans.component.ManagedBean.create(ManagedBean.java:55)
at 
org.apache.webbeans.context.creational.BeanInstanceBag.create(BeanInstanceBag.java:76)
at 
org.apache.webbeans.context.AbstractContext.getInstance(AbstractContext.java:160)
at 
org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


ContainerManagedTransactionStrategy

2014-10-03 Thread hwaastad
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.


[jira] [Commented] (DELTASPIKE-736) MockAwareInjectionTargetWrapper breaks interceptors in unit tests

2014-10-03 Thread Gerhard Petracek (JIRA)

[ 
https://issues.apache.org/jira/browse/DELTASPIKE-736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14158531#comment-14158531
 ] 

Gerhard Petracek commented on DELTASPIKE-736:
-

please test it with weld or provide a demo-application which illustrates that 
issue (so we can test it with weld).
if it's just an issue with owb, we might need to fix it there.

 MockAwareInjectionTargetWrapper breaks interceptors in unit tests
 -

 Key: DELTASPIKE-736
 URL: https://issues.apache.org/jira/browse/DELTASPIKE-736
 Project: DeltaSpike
  Issue Type: Bug
  Components: TestControl
Affects Versions: 1.0.3
 Environment: OpenWebBeans 1.2.6
Reporter: Ronald Steininger

 The automatic usage of MockAwareInjectionTargetWrapper breaks method-level 
 interceptors under OWB:
 org.apache.webbeans.config.BeansDeployer#validate creates the interceptor 
 stack of all beans while validating the deployment (Line 474). This code 
 depends on owbBean.getProducer() returning an AbstractProducer (Line 462).
 TestControl replaces that AbstractProducer in some circumstances with an 
 instance of MockAwareInjectionTargetWrapper, completely deactivating the 
 if-branch which would active the interceptors.
 It seems that, depending where the interceptor binding is defined on the 
 intercepted bean, interceptors work or don't work: using the annotation on 
 the class level results in getProducer returning a AbstractProducer - 
 interceptors work. Defining interceptors only on methods shows the broken 
 behaviour described here.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Resolved] (DELTASPIKE-737) MockExtension can't be deactivated

2014-10-03 Thread Gerhard Petracek (JIRA)

 [ 
https://issues.apache.org/jira/browse/DELTASPIKE-737?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gerhard Petracek resolved DELTASPIKE-737.
-
Resolution: Cannot Reproduce

i tested it with https://github.com/os890/javase-cdi-ds-project-template and 
there it works.

please reopen this ticket, if you have a demo-application which illustrates the 
issue.

 MockExtension can't be deactivated
 --

 Key: DELTASPIKE-737
 URL: https://issues.apache.org/jira/browse/DELTASPIKE-737
 Project: DeltaSpike
  Issue Type: Bug
  Components: TestControl
Affects Versions: 1.0.3
 Environment: OpenWebBeans 1.2.6
Reporter: Ronald Steininger

 Using an ClassDeactivator to deactivate the MockExtension (like described in 
 http://deltaspike.apache.org/documentation/test-control.html#_liquibase) 
 leads to a StackOverflowError:
 {code}
 java.lang.StackOverflowError
   at 
 org.apache.webbeans.container.BeanCacheKey.getQualifierHashCode(BeanCacheKey.java:184)
   at 
 org.apache.webbeans.container.BeanCacheKey.computeHashCode(BeanCacheKey.java:167)
   at 
 org.apache.webbeans.container.BeanCacheKey.init(BeanCacheKey.java:67)
   at 
 org.apache.webbeans.container.InjectionResolver.implResolveByType(InjectionResolver.java:485)
   at 
 org.apache.webbeans.container.InjectionResolver.implResolveByType(InjectionResolver.java:435)
   at 
 org.apache.webbeans.container.BeanManagerImpl.getBeans(BeanManagerImpl.java:578)
   at 
 org.apache.webbeans.container.InjectableBeanManager.getBeans(InjectableBeanManager.java:117)
   at 
 org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference(BeanProvider.java:141)
   at 
 org.apache.deltaspike.testcontrol.impl.mock.MockAwareInjectionTargetWrapper.produce(MockAwareInjectionTargetWrapper.java:54)
   at 
 org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:121)
   at org.apache.webbeans.component.ManagedBean.create(ManagedBean.java:55)
   at 
 org.apache.webbeans.context.creational.BeanInstanceBag.create(BeanInstanceBag.java:76)
   at 
 org.apache.webbeans.context.AbstractContext.getInstance(AbstractContext.java:160)
   at 
 org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
   at 
 org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:100)
   at 
 org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:70)
   at 
 org.apache.deltaspike.testcontrol.impl.mock.SimpleMockManager$$OwbNormalScopeProxy0.getMock(org/apache/deltaspike/testcontrol/impl/mock/SimpleMockManager.java)
   at 
 org.apache.deltaspike.testcontrol.impl.mock.MockAwareInjectionTargetWrapper.produce(MockAwareInjectionTargetWrapper.java:59)
   at 
 org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.java:121)
   at org.apache.webbeans.component.ManagedBean.create(ManagedBean.java:55)
   at 
 org.apache.webbeans.context.creational.BeanInstanceBag.create(BeanInstanceBag.java:76)
   at 
 org.apache.webbeans.context.AbstractContext.getInstance(AbstractContext.java:160)
   at 
 org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
 {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)