MyFaces CODI and Weld 1.0.1

2011-03-09 Thread Christian Kaltepoth
Hey all,

we are currently developing an application based on Weld 1.0.1 and
MyFaces CODI. Unfortunately we have some strange problems regarding
CODI's @Transactional not always being applied correctly. It seems to
be completely ignored in some situations.

I've reproduced this problem with Matthias' Modern-EE-JSF2.0 example
application. I did just two modifications:

1. Weld doesn't support to inject the EntityManager via
@PersistenceContext. So I created a class named EntityManagerProducer
to create request scoped EntityManager instances. Then I replaced
@PersistenceContext in the DAO with @Inject. This works fine with
OpenWebBeans.

2. Then I removed OpenWebBeans and added Weld 1.0.1 to the
dependencies. After that @Transactional immediately stopped working.
It seems like the TransactionalInterceptor doesn't get invoked at all.
No transactions are started and changes to the database aren't
persisted any more.

You can get the example application here:

https://github.com/chkal/modern-ee-app20

Here are the modifications I made to the application:

https://github.com/chkal/modern-ee-app20/commits/master

Does anyone have an idea what is causing this? I'm not really sure if
it is a CODI or a Weld issue.

Thanks

Christian


-- 
Christian Kaltepoth
Blog: http://chkal.blogspot.com/
Twitter: http://twitter.com/chkal


Re: MyFaces CODI and Weld 1.0.1

2011-03-09 Thread Mark Struberg
Hi Christian!

The major difference between Weld and OpenWebBeans in the interceptor area is 
that Weld strictly follows the Bean Definition Archive (BDA) part of the 
spec. This got added pretty late (in the last few weeks before the spec went 
final and imo is complete crap [1] ;)

In Weld you have to add the interceptors section to ALL jars as well as to 
the WAR you like to use the interceptor in. Whereas in OWB it is enough to just 
have it enabled in 1 of the beans.xml files.

So please try adding those section to all your beans.xml files and plz report 
back if that worked out.

LieGrue,
strub


[1] https://issues.jboss.org/browse/CDI-18
--- On Wed, 3/9/11, Christian Kaltepoth christ...@kaltepoth.de wrote:

 From: Christian Kaltepoth christ...@kaltepoth.de
 Subject: MyFaces CODI and Weld 1.0.1
 To: MyFaces Discussion users@myfaces.apache.org
 Date: Wednesday, March 9, 2011, 12:31 PM
 Hey all,
 
 we are currently developing an application based on Weld
 1.0.1 and
 MyFaces CODI. Unfortunately we have some strange problems
 regarding
 CODI's @Transactional not always being applied correctly.
 It seems to
 be completely ignored in some situations.
 
 I've reproduced this problem with Matthias'
 Modern-EE-JSF2.0 example
 application. I did just two modifications:
 
 1. Weld doesn't support to inject the EntityManager via
 @PersistenceContext. So I created a class named
 EntityManagerProducer
 to create request scoped EntityManager instances. Then I
 replaced
 @PersistenceContext in the DAO with @Inject. This works
 fine with
 OpenWebBeans.
 
 2. Then I removed OpenWebBeans and added Weld 1.0.1 to the
 dependencies. After that @Transactional immediately stopped
 working.
 It seems like the TransactionalInterceptor doesn't get
 invoked at all.
 No transactions are started and changes to the database
 aren't
 persisted any more.
 
 You can get the example application here:
 
 https://github.com/chkal/modern-ee-app20
 
 Here are the modifications I made to the application:
 
 https://github.com/chkal/modern-ee-app20/commits/master
 
 Does anyone have an idea what is causing this? I'm not
 really sure if
 it is a CODI or a Weld issue.
 
 Thanks
 
 Christian
 
 
 -- 
 Christian Kaltepoth
 Blog: http://chkal.blogspot.com/
 Twitter: http://twitter.com/chkal
 


  


Re: MyFaces CODI and Weld 1.0.1

2011-03-09 Thread Matthias Wessendorf
Try to unzip the jar into web-inf/classes and add its beans.xml content to
the one in web-inf.

This was suggested to my by the glassfish team... :-)

sent from my Android phone
On Mar 9, 2011 1:31 PM, Christian Kaltepoth christ...@kaltepoth.de
wrote:
 Hey all,

 we are currently developing an application based on Weld 1.0.1 and
 MyFaces CODI. Unfortunately we have some strange problems regarding
 CODI's @Transactional not always being applied correctly. It seems to
 be completely ignored in some situations.

 I've reproduced this problem with Matthias' Modern-EE-JSF2.0 example
 application. I did just two modifications:

 1. Weld doesn't support to inject the EntityManager via
 @PersistenceContext. So I created a class named EntityManagerProducer
 to create request scoped EntityManager instances. Then I replaced
 @PersistenceContext in the DAO with @Inject. This works fine with
 OpenWebBeans.

 2. Then I removed OpenWebBeans and added Weld 1.0.1 to the
 dependencies. After that @Transactional immediately stopped working.
 It seems like the TransactionalInterceptor doesn't get invoked at all.
 No transactions are started and changes to the database aren't
 persisted any more.

 You can get the example application here:

 https://github.com/chkal/modern-ee-app20

 Here are the modifications I made to the application:

 https://github.com/chkal/modern-ee-app20/commits/master

 Does anyone have an idea what is causing this? I'm not really sure if
 it is a CODI or a Weld issue.

 Thanks

 Christian


 --
 Christian Kaltepoth
 Blog: http://chkal.blogspot.com/
 Twitter: http://twitter.com/chkal


Re: MyFaces CODI and Weld 1.0.1

2011-03-09 Thread Christian Kaltepoth
Hi Mark,

thank you very much for your response. I've tried your suggestion and
it worked great. I didn't knew about the BDA part in the spec and
assumed that CODI's beans.xml would globally enable the interceptor.
You are right! This BDA stuff is crap! :-)

@Matthias: Nice workaround! ;)

Thanks

Christian



2011/3/9 Mark Struberg strub...@yahoo.de:
 Hi Christian!

 The major difference between Weld and OpenWebBeans in the interceptor area is 
 that Weld strictly follows the Bean Definition Archive (BDA) part of the 
 spec. This got added pretty late (in the last few weeks before the spec went 
 final and imo is complete crap [1] ;)

 In Weld you have to add the interceptors section to ALL jars as well as to 
 the WAR you like to use the interceptor in. Whereas in OWB it is enough to 
 just have it enabled in 1 of the beans.xml files.

 So please try adding those section to all your beans.xml files and plz report 
 back if that worked out.

 LieGrue,
 strub


 [1] https://issues.jboss.org/browse/CDI-18
 --- On Wed, 3/9/11, Christian Kaltepoth christ...@kaltepoth.de wrote:

 From: Christian Kaltepoth christ...@kaltepoth.de
 Subject: MyFaces CODI and Weld 1.0.1
 To: MyFaces Discussion users@myfaces.apache.org
 Date: Wednesday, March 9, 2011, 12:31 PM
 Hey all,

 we are currently developing an application based on Weld
 1.0.1 and
 MyFaces CODI. Unfortunately we have some strange problems
 regarding
 CODI's @Transactional not always being applied correctly.
 It seems to
 be completely ignored in some situations.

 I've reproduced this problem with Matthias'
 Modern-EE-JSF2.0 example
 application. I did just two modifications:

 1. Weld doesn't support to inject the EntityManager via
 @PersistenceContext. So I created a class named
 EntityManagerProducer
 to create request scoped EntityManager instances. Then I
 replaced
 @PersistenceContext in the DAO with @Inject. This works
 fine with
 OpenWebBeans.

 2. Then I removed OpenWebBeans and added Weld 1.0.1 to the
 dependencies. After that @Transactional immediately stopped
 working.
 It seems like the TransactionalInterceptor doesn't get
 invoked at all.
 No transactions are started and changes to the database
 aren't
 persisted any more.

 You can get the example application here:

 https://github.com/chkal/modern-ee-app20

 Here are the modifications I made to the application:

 https://github.com/chkal/modern-ee-app20/commits/master

 Does anyone have an idea what is causing this? I'm not
 really sure if
 it is a CODI or a Weld issue.

 Thanks

 Christian


 --
 Christian Kaltepoth
 Blog: http://chkal.blogspot.com/
 Twitter: http://twitter.com/chkal








-- 
Christian Kaltepoth
Blog: http://chkal.blogspot.com/
Twitter: http://twitter.com/chkal