You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@openwebbeans.apache.org by Dennis Kieselhorst <de...@apache.org> on 2018/02/03 19:16:10 UTC

[meecrowave] run JSF MyFaces application

Hi,

is it possible to run meecrowave with a JSF MyFaces application? I always get a DuplicateDefinitionException.

[ERROR][           main][rBase.[Tomcat].[localhost].[/]] Exception sending context initialized event to listener instance of class [org.apache.webbeans.servlet.WebBeansConfigurationListener]
org.apache.webbeans.exception.DuplicateDefinitionException: PassivationCapable bean id is not unique: SERVLET_CONTEXT#interface javax.servlet.ServletContext#@javax.enterprise.inject.Default(),@javax.enterprise.inject.Any(), bean:ServletContext, WebBeansType:SERVLET_CONTEXT, Name:null, API Types:[java.lang.Object,javax.servlet.ServletContext], Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any]
	at org.apache.webbeans.container.BeanManagerImpl.addPassivationInfo(BeanManagerImpl.java:410) ~[openwebbeans-impl-2.0.3.jar:2.0.3]
	at org.apache.webbeans.container.BeanManagerImpl.addInternalBean(BeanManagerImpl.java:364) ~[openwebbeans-impl-2.0.3.jar:2.0.3]
	at org.apache.webbeans.web.lifecycle.WebContainerLifecycle.startApplication(WebContainerLifecycle.java:90) ~[openwebbeans-web-2.0.3.jar:2.0.3]
	at org.apache.webbeans.servlet.WebBeansConfigurationListener.contextInitialized(WebBeansConfigurationListener.java:85) ~[openwebbeans-web-2.0.3.jar:2.0.3]

Reproducible with https://github.com/apache/myfaces-tobago/tree/master/tobago-example/tobago-example-demo by running mvn clean package meecrowave:run -Djsf=myfaces-2.2

If I simplify the example and try it without Tobago with plain MyFaces it results in:
Caused by: org.apache.webbeans.exception.DuplicateDefinitionException: PassivationCapable bean id is not unique: PRODUCERMETHOD#class javax.faces.flow.builder.FlowBuilder#@javax.faces.flow.builder.Flow
BuilderParameter(),@javax.enterprise.inject.Any(),#public javax.faces.flow.builder.FlowBuilder org.apache.myfaces.flow.cdi.FlowBuilderFactoryBean.createFlowBuilderInstance() bean:FlowBuilder, WebBeansT
ype:PRODUCERMETHOD, Name:null, API Types:[javax.faces.flow.builder.FlowBuilder,java.lang.Object], Qualifiers:[javax.faces.flow.builder.FlowBuilderParameter,javax.enterprise.inject.Any], Producer Method
: public javax.faces.flow.builder.FlowBuilder org.apache.myfaces.flow.cdi.FlowBuilderFactoryBean.createFlowBuilderInstance()
        at org.apache.webbeans.container.BeanManagerImpl.addPassivationInfo(BeanManagerImpl.java:410) ~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.container.BeanManagerImpl.addInternalBean(BeanManagerImpl.java:364) ~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.container.BeanManagerImpl.addBean(BeanManagerImpl.java:351) ~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.config.BeansDeployer.defineManagedBean(BeansDeployer.java:2058) ~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.config.BeansDeployer.deploySingleAnnotatedType(BeansDeployer.java:1548) ~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.config.BeansDeployer.deployFromBeanAttributes(BeansDeployer.java:1504) ~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:313) ~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.lifecycle.AbstractLifeCycle.bootstrapApplication(AbstractLifeCycle.java:137) ~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(AbstractLifeCycle.java:103) ~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.web.lifecycle.WebContainerLifecycle.startApplication(WebContainerLifecycle.java:98) ~[openwebbeans-web-2.0.3.jar:2.0.3]
        at org.apache.webbeans.servlet.WebBeansConfigurationListener.contextInitialized(WebBeansConfigurationListener.java:85) ~[openwebbeans-web-2.0.3.jar:2.0.3]
        at org.apache.meecrowave.openwebbeans.OWBAutoSetup$EagerBootListener.doContextInitialized(OWBAutoSetup.java:80) ~[meecrowave-core-1.2.0.jar:1.2.0] 

Any hint greatly appreciated...

Cheers
Dennis

Re: [meecrowave] run JSF MyFaces application

Posted by Mark Struberg <st...@yahoo.de>.
Hi Dennis!

Gonna look at it this afternoon.
Just keep pinging me if I don't deliver - pretty busy right now :/

LieGrue,
strub

> Am 08.03.2018 um 09:08 schrieb Dennis Kieselhorst <de...@apache.org>:
> 
> Hi Mark!
> 
>> Don't want to push it to MyFaces directly for now as it breaks the enforcer-plugin due to the mw-snapshot.
> 
> Now that 1.2.1 is out can you please push your changes or open a PR?
> 
> Cheers
> Dennis


Re: [meecrowave] run JSF MyFaces application

Posted by Dennis Kieselhorst <de...@apache.org>.
Hi Mark!

> Don't want to push it to MyFaces directly for now as it breaks the enforcer-plugin due to the mw-snapshot.
 
Now that 1.2.1 is out can you please push your changes or open a PR?

Cheers
Dennis

Re: [meecrowave] run JSF MyFaces application

Posted by Mark Struberg <st...@yahoo.de>.
 
got it running and pushed it to my github repo https://github.com/struberg/myfaces-tobago

Don't want to push it to MyFaces directly for now as it breaks the enforcer-plugin due to the mw-snapshot.
@Dennis, Udo
please review it. I can push it to Tobago once it works well enough.
LieGrue,strub
    On Tuesday, 6 February 2018, 15:18:31 CET, Romain Manni-Bucau <rm...@gmail.com> wrote:  
 
 

2018-02-06 15:15 GMT+01:00 Mark Struberg <st...@yahoo.de>:

 
Well, Dennis' code uses the following fqcn: org.apache.myfaces.tobago. example.demo.info.ActivityList
And since it starts with 'org.apache.myfaces' it is thrown away. Which imo should not be the case
If we would make the included and excluded class filter configurable via openwebbeans.properties then we could at least add org.apache.myfaces.tobago. example to the 'included' list. And all would work fine. Wdyt?


Actually it should be configurable through scanning package options (include/exclude). 

LieGrue,strub
    On Tuesday, 6 February 2018, 14:20:56 CET, Romain Manni-Bucau <rm...@gmail.com> wrote:  
 
 yes, the exclusion is intended since the MF extension registers the beans already so no need to pay the scanning time.

Romain Manni-Bucau
@rmannibucau |  Blog | Old Blog | Github | LinkedIn | Book
2018-02-06 14:09 GMT+01:00 Thomas Andraschko <an...@gmail.com>:

I mean that it should not fail because of duplicate beans therefore.

Am Dienstag, 6. Februar 2018 schrieb Thomas Andraschko :

AFAIR MyFaces should not be scannend and all beans are registered via a extension?! Also AFAIR it doenst even has a beans.xml.
Am Dienstag, 6. Februar 2018 schrieb Mark Struberg :

Hi folks!
I've debugged the example and it falls into the category 'bad luck' ;)
Meecrowave has a specialised Filter KnowClassesFilter which by default excludes some packages which are well known to not contain any CDI beans. This is done to improve the startup time.
There is kind of a positive/negative lookup logic.https://github.com/apache/meec rowave/blob/trunk/meecrowave-c ore/src/main/java/org/apache/m eecrowave/openwebbeans/KnowCla ssesFilter.java#L41

We have the 'included': if some class starts with any of those package names, then we add it If the class package does not show up in the included list then we look into the 'excluded'.And if we find it there, then we skip the whole class.
Sadly 'org.apache.myfaces' is in this very 'excluded' list ...And this is why Dennis' sample beans are not found. Any other project will work perfectly fine.

Do we like to make this configurable?
Actually I think we do not even need this. It should only be used if you create a single-jar packaging (uberjar).Otherwise the 'bad' jars in question are already filtered out as a whole anyway by the!


A quick hack would be to add a Filter and register it in openwebbeans.properties. That will of course trash the portability of your sample...

LieGrue,strub
 

    On Tuesday, 6 February 2018, 09:24:15 CET, Romain Manni-Bucau <rm...@gmail.com> wrote:  
 
 Hi Dennis,
can you check this diff https://gist.github.com/r mannibucau/c63afe1326ca9e74097 35b3f5911ea45 ?
I'm not sure why the bean is not found, is it a bad JSF setup?
About the duplicate, it seems myfaces adds twice the same bean if you scan it: once by scanning, once in the extension org.apache.myfaces.f low.cdi.FlowBuilderCDIExtensio n#beforeBeanDiscovery. So long story short org.apache.webbeans.conf ig.BeansDeployer#addAdditional AnnotatedTypes ends up adding again the same beans. We can surely filter it in OWB but also guess you should be able to make it working without scanning myfaces at all, no?


Romain Manni-Bucau
@rmannibucau |  Blog | Old Blog | Github | LinkedIn | Book
2018-02-06 8:04 GMT+01:00 Dennis Kieselhorst <de...@apache.org>:

Hi Romain,

thanks for your feedback. Let's leave out Tobago, the demo needs to run in several setups and is somehow complex.

We are about to release MyFaces 2.3.0 and I'd like to create an archetype for plain MyFaces and Meecrowave. Tried with a simple hello world sample but still getting DuplicateDefinitionException.

Can you please take a look? https://github.com/deki/ myfaces-meecrowave-sample

Cheers
Dennis



  



  

  

Re: [meecrowave] run JSF MyFaces application

Posted by Romain Manni-Bucau <rm...@gmail.com>.
2018-02-06 15:15 GMT+01:00 Mark Struberg <st...@yahoo.de>:

>
> Well, Dennis' code uses the following fqcn: org.apache.myfaces.tobago.
> example.demo.info.ActivityList
>
> And since it starts with 'org.apache.myfaces' it is thrown away.
> Which imo should not be the case
>
> If we would make the included and excluded class filter configurable via
> openwebbeans.properties then we could at least add
> org.apache.myfaces.tobago.example to the 'included' list. And all would
> work fine. Wdyt?
>

Actually it should be configurable through scanning package options
(include/exclude).


>
> LieGrue,
> strub
> On Tuesday, 6 February 2018, 14:20:56 CET, Romain Manni-Bucau <
> rmannibucau@gmail.com> wrote:
>
>
> yes, the exclusion is intended since the MF extension registers the beans
> already so no need to pay the scanning time.
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://rmannibucau.metawerx.net/> | Old Blog
> <http://rmannibucau.wordpress.com> | Github
> <https://github.com/rmannibucau> | LinkedIn
> <https://www.linkedin.com/in/rmannibucau> | Book
> <https://www.packtpub.com/application-development/java-ee-8-high-performance>
>
> 2018-02-06 14:09 GMT+01:00 Thomas Andraschko <an...@gmail.com>
> :
>
> I mean that it should not fail because of duplicate beans therefore.
>
>
> Am Dienstag, 6. Februar 2018 schrieb Thomas Andraschko :
>
> AFAIR MyFaces should not be scannend and all beans are registered via a
> extension?! Also AFAIR it doenst even has a beans.xml.
>
> Am Dienstag, 6. Februar 2018 schrieb Mark Struberg :
>
> Hi folks!
>
> I've debugged the example and it falls into the category 'bad luck' ;)
>
> Meecrowave has a specialised Filter KnowClassesFilter which by default
> excludes some packages which are well known to not contain any CDI beans.
> This is done to improve the startup time.
>
> There is kind of a positive/negative lookup logic.
> https://github.com/apache/meec rowave/blob/trunk/meecrowave-c
> ore/src/main/java/org/apache/m eecrowave/openwebbeans/KnowCla
> ssesFilter.java#L41
> <https://github.com/apache/meecrowave/blob/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/KnowClassesFilter.java#L41>
>
> We have the 'included': if some class starts with any of those package
> names, then we add it
> If the class package does not show up in the included list then we look
> into the 'excluded'.
> And if we find it there, then we skip the whole class.
>
> Sadly 'org.apache.myfaces' is in this very 'excluded' list ...
> And this is why Dennis' sample beans are not found. Any other project will
> work perfectly fine.
>
> Do we like to make this configurable?
>
> Actually I think we do not even need this. It should only be used if you
> create a single-jar packaging (uberjar).
> Otherwise the 'bad' jars in question are already filtered out as a whole
> anyway by the!
>
>
> A quick hack would be to add a Filter and register it in
> openwebbeans.properties.
> That will of course trash the portability of your sample...
>
> LieGrue,
> strub
>
>
> On Tuesday, 6 February 2018, 09:24:15 CET, Romain Manni-Bucau <
> rmannibucau@gmail.com> wrote:
>
>
> Hi Dennis,
>
> can you check this diff https://gist.github.com/r
> mannibucau/c63afe1326ca9e74097 35b3f5911ea45
> <https://gist.github.com/rmannibucau/c63afe1326ca9e7409735b3f5911ea45> ?
>
> I'm not sure why the bean is not found, is it a bad JSF setup?
>
> About the duplicate, it seems myfaces adds twice the same bean if you scan
> it: once by scanning, once in the extension org.apache.myfaces.f
> low.cdi.FlowBuilderCDIExtensio n#beforeBeanDiscovery. So long story
> short org.apache.webbeans.conf ig.BeansDeployer#addAdditional
> AnnotatedTypes ends up adding again the same beans. We can surely filter it
> in OWB but also guess you should be able to make it working without
> scanning myfaces at all, no?
>
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://rmannibucau.metawerx.net/> | Old Blog
> <http://rmannibucau.wordpress.com> | Github
> <https://github.com/rmannibucau> | LinkedIn
> <https://www.linkedin.com/in/rmannibucau> | Book
> <https://www.packtpub.com/application-development/java-ee-8-high-performance>
>
> 2018-02-06 8:04 GMT+01:00 Dennis Kieselhorst <de...@apache.org>:
>
> Hi Romain,
>
> thanks for your feedback. Let's leave out Tobago, the demo needs to run in
> several setups and is somehow complex.
>
> We are about to release MyFaces 2.3.0 and I'd like to create an archetype
> for plain MyFaces and Meecrowave. Tried with a simple hello world sample
> but still getting DuplicateDefinitionException.
>
> Can you please take a look? https://github.com/deki/
> myfaces-meecrowave-sample
> <https://github.com/deki/myfaces-meecrowave-sample>
>
> Cheers
> Dennis
>
>
>
>

Re: [meecrowave] run JSF MyFaces application

Posted by Mark Struberg <st...@yahoo.de>.
 
Well, Dennis' code uses the following fqcn: org.apache.myfaces.tobago.example.demo.info.ActivityList
And since it starts with 'org.apache.myfaces' it is thrown away. Which imo should not be the case
If we would make the included and excluded class filter configurable via openwebbeans.properties then we could at least add org.apache.myfaces.tobago.example to the 'included' list. And all would work fine. Wdyt?

LieGrue,strub
    On Tuesday, 6 February 2018, 14:20:56 CET, Romain Manni-Bucau <rm...@gmail.com> wrote:  
 
 yes, the exclusion is intended since the MF extension registers the beans already so no need to pay the scanning time.

Romain Manni-Bucau
@rmannibucau |  Blog | Old Blog | Github | LinkedIn | Book
2018-02-06 14:09 GMT+01:00 Thomas Andraschko <an...@gmail.com>:

I mean that it should not fail because of duplicate beans therefore.

Am Dienstag, 6. Februar 2018 schrieb Thomas Andraschko :

AFAIR MyFaces should not be scannend and all beans are registered via a extension?! Also AFAIR it doenst even has a beans.xml.
Am Dienstag, 6. Februar 2018 schrieb Mark Struberg :

Hi folks!
I've debugged the example and it falls into the category 'bad luck' ;)
Meecrowave has a specialised Filter KnowClassesFilter which by default excludes some packages which are well known to not contain any CDI beans. This is done to improve the startup time.
There is kind of a positive/negative lookup logic.https://github.com/apache/meec rowave/blob/trunk/meecrowave-c ore/src/main/java/org/apache/m eecrowave/openwebbeans/KnowCla ssesFilter.java#L41

We have the 'included': if some class starts with any of those package names, then we add it If the class package does not show up in the included list then we look into the 'excluded'.And if we find it there, then we skip the whole class.
Sadly 'org.apache.myfaces' is in this very 'excluded' list ...And this is why Dennis' sample beans are not found. Any other project will work perfectly fine.

Do we like to make this configurable?
Actually I think we do not even need this. It should only be used if you create a single-jar packaging (uberjar).Otherwise the 'bad' jars in question are already filtered out as a whole anyway by the!


A quick hack would be to add a Filter and register it in openwebbeans.properties. That will of course trash the portability of your sample...

LieGrue,strub
 

    On Tuesday, 6 February 2018, 09:24:15 CET, Romain Manni-Bucau <rm...@gmail.com> wrote:  
 
 Hi Dennis,
can you check this diff https://gist.github.com/r mannibucau/c63afe1326ca9e74097 35b3f5911ea45 ?
I'm not sure why the bean is not found, is it a bad JSF setup?
About the duplicate, it seems myfaces adds twice the same bean if you scan it: once by scanning, once in the extension org.apache.myfaces.f low.cdi.FlowBuilderCDIExtensio n#beforeBeanDiscovery. So long story short org.apache.webbeans.conf ig.BeansDeployer#addAdditional AnnotatedTypes ends up adding again the same beans. We can surely filter it in OWB but also guess you should be able to make it working without scanning myfaces at all, no?


Romain Manni-Bucau
@rmannibucau |  Blog | Old Blog | Github | LinkedIn | Book
2018-02-06 8:04 GMT+01:00 Dennis Kieselhorst <de...@apache.org>:

Hi Romain,

thanks for your feedback. Let's leave out Tobago, the demo needs to run in several setups and is somehow complex.

We are about to release MyFaces 2.3.0 and I'd like to create an archetype for plain MyFaces and Meecrowave. Tried with a simple hello world sample but still getting DuplicateDefinitionException.

Can you please take a look? https://github.com/deki/ myfaces-meecrowave-sample

Cheers
Dennis



  



  

Re: [meecrowave] run JSF MyFaces application

Posted by Romain Manni-Bucau <rm...@gmail.com>.
yes, the exclusion is intended since the MF extension registers the beans
already so no need to pay the scanning time.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>

2018-02-06 14:09 GMT+01:00 Thomas Andraschko <an...@gmail.com>:

> I mean that it should not fail because of duplicate beans therefore.
>
>
> Am Dienstag, 6. Februar 2018 schrieb Thomas Andraschko :
>
>> AFAIR MyFaces should not be scannend and all beans are registered via a
>> extension?! Also AFAIR it doenst even has a beans.xml.
>>
>> Am Dienstag, 6. Februar 2018 schrieb Mark Struberg :
>>
>>> Hi folks!
>>>
>>> I've debugged the example and it falls into the category 'bad luck' ;)
>>>
>>> Meecrowave has a specialised Filter KnowClassesFilter which by default
>>> excludes some packages which are well known to not contain any CDI beans.
>>> This is done to improve the startup time.
>>>
>>> There is kind of a positive/negative lookup logic.
>>> https://github.com/apache/meecrowave/blob/trunk/meecrowave-c
>>> ore/src/main/java/org/apache/meecrowave/openwebbeans/KnowCla
>>> ssesFilter.java#L41
>>>
>>> We have the 'included': if some class starts with any of those package
>>> names, then we add it
>>> If the class package does not show up in the included list then we look
>>> into the 'excluded'.
>>> And if we find it there, then we skip the whole class.
>>>
>>> Sadly 'org.apache.myfaces' is in this very 'excluded' list ...
>>> And this is why Dennis' sample beans are not found. Any other project
>>> will work perfectly fine.
>>>
>>> Do we like to make this configurable?
>>>
>>> Actually I think we do not even need this. It should only be used if you
>>> create a single-jar packaging (uberjar).
>>> Otherwise the 'bad' jars in question are already filtered out as a whole
>>> anyway by the!
>>>
>>>
>>> A quick hack would be to add a Filter and register it in
>>> openwebbeans.properties.
>>> That will of course trash the portability of your sample...
>>>
>>> LieGrue,
>>> strub
>>>
>>>
>>> On Tuesday, 6 February 2018, 09:24:15 CET, Romain Manni-Bucau <
>>> rmannibucau@gmail.com> wrote:
>>>
>>>
>>> Hi Dennis,
>>>
>>> can you check this diff https://gist.github.com/r
>>> mannibucau/c63afe1326ca9e7409735b3f5911ea45 ?
>>>
>>> I'm not sure why the bean is not found, is it a bad JSF setup?
>>>
>>> About the duplicate, it seems myfaces adds twice the same bean if you
>>> scan it: once by scanning, once in the extension org.apache.myfaces.f
>>> low.cdi.FlowBuilderCDIExtension#beforeBeanDiscovery. So long story
>>> short org.apache.webbeans.config.BeansDeployer#addAdditionalAnnotatedTypes
>>> ends up adding again the same beans. We can surely filter it in OWB but
>>> also guess you should be able to make it working without scanning myfaces
>>> at all, no?
>>>
>>>
>>>
>>> Romain Manni-Bucau
>>> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>>> <https://rmannibucau.metawerx.net/> | Old Blog
>>> <http://rmannibucau.wordpress.com> | Github
>>> <https://github.com/rmannibucau> | LinkedIn
>>> <https://www.linkedin.com/in/rmannibucau> | Book
>>> <https://www.packtpub.com/application-development/java-ee-8-high-performance>
>>>
>>> 2018-02-06 8:04 GMT+01:00 Dennis Kieselhorst <de...@apache.org>:
>>>
>>> Hi Romain,
>>>
>>> thanks for your feedback. Let's leave out Tobago, the demo needs to run
>>> in several setups and is somehow complex.
>>>
>>> We are about to release MyFaces 2.3.0 and I'd like to create an
>>> archetype for plain MyFaces and Meecrowave. Tried with a simple hello world
>>> sample but still getting DuplicateDefinitionException.
>>>
>>> Can you please take a look? https://github.com/deki/
>>> myfaces-meecrowave-sample
>>> <https://github.com/deki/myfaces-meecrowave-sample>
>>>
>>> Cheers
>>> Dennis
>>>
>>>
>>>

Re: [meecrowave] run JSF MyFaces application

Posted by Thomas Andraschko <an...@gmail.com>.
I mean that it should not fail because of duplicate beans therefore.

Am Dienstag, 6. Februar 2018 schrieb Thomas Andraschko :

> AFAIR MyFaces should not be scannend and all beans are registered via a
> extension?! Also AFAIR it doenst even has a beans.xml.
>
> Am Dienstag, 6. Februar 2018 schrieb Mark Struberg :
>
>> Hi folks!
>>
>> I've debugged the example and it falls into the category 'bad luck' ;)
>>
>> Meecrowave has a specialised Filter KnowClassesFilter which by default
>> excludes some packages which are well known to not contain any CDI beans.
>> This is done to improve the startup time.
>>
>> There is kind of a positive/negative lookup logic.
>> https://github.com/apache/meecrowave/blob/trunk/meecrowave-
>> core/src/main/java/org/apache/meecrowave/openwebbeans/KnowCl
>> assesFilter.java#L41
>>
>> We have the 'included': if some class starts with any of those package
>> names, then we add it
>> If the class package does not show up in the included list then we look
>> into the 'excluded'.
>> And if we find it there, then we skip the whole class.
>>
>> Sadly 'org.apache.myfaces' is in this very 'excluded' list ...
>> And this is why Dennis' sample beans are not found. Any other project
>> will work perfectly fine.
>>
>> Do we like to make this configurable?
>>
>> Actually I think we do not even need this. It should only be used if you
>> create a single-jar packaging (uberjar).
>> Otherwise the 'bad' jars in question are already filtered out as a whole
>> anyway by the!
>>
>>
>> A quick hack would be to add a Filter and register it in
>> openwebbeans.properties.
>> That will of course trash the portability of your sample...
>>
>> LieGrue,
>> strub
>>
>>
>> On Tuesday, 6 February 2018, 09:24:15 CET, Romain Manni-Bucau <
>> rmannibucau@gmail.com> wrote:
>>
>>
>> Hi Dennis,
>>
>> can you check this diff https://gist.github.com/r
>> mannibucau/c63afe1326ca9e7409735b3f5911ea45 ?
>>
>> I'm not sure why the bean is not found, is it a bad JSF setup?
>>
>> About the duplicate, it seems myfaces adds twice the same bean if you
>> scan it: once by scanning, once in the extension org.apache.myfaces.f
>> low.cdi.FlowBuilderCDIExtension#beforeBeanDiscovery. So long story
>> short org.apache.webbeans.config.BeansDeployer#addAdditionalAnnotatedTypes
>> ends up adding again the same beans. We can surely filter it in OWB but
>> also guess you should be able to make it working without scanning myfaces
>> at all, no?
>>
>>
>>
>> Romain Manni-Bucau
>> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>> <https://rmannibucau.metawerx.net/> | Old Blog
>> <http://rmannibucau.wordpress.com> | Github
>> <https://github.com/rmannibucau> | LinkedIn
>> <https://www.linkedin.com/in/rmannibucau> | Book
>> <https://www.packtpub.com/application-development/java-ee-8-high-performance>
>>
>> 2018-02-06 8:04 GMT+01:00 Dennis Kieselhorst <de...@apache.org>:
>>
>> Hi Romain,
>>
>> thanks for your feedback. Let's leave out Tobago, the demo needs to run
>> in several setups and is somehow complex.
>>
>> We are about to release MyFaces 2.3.0 and I'd like to create an archetype
>> for plain MyFaces and Meecrowave. Tried with a simple hello world sample
>> but still getting DuplicateDefinitionException.
>>
>> Can you please take a look? https://github.com/deki/
>> myfaces-meecrowave-sample
>> <https://github.com/deki/myfaces-meecrowave-sample>
>>
>> Cheers
>> Dennis
>>
>>
>>

Re: [meecrowave] run JSF MyFaces application

Posted by Thomas Andraschko <an...@gmail.com>.
AFAIR MyFaces should not be scannend and all beans are registered via a
extension?! Also AFAIR it doenst even has a beans.xml.

Am Dienstag, 6. Februar 2018 schrieb Mark Struberg :

> Hi folks!
>
> I've debugged the example and it falls into the category 'bad luck' ;)
>
> Meecrowave has a specialised Filter KnowClassesFilter which by default
> excludes some packages which are well known to not contain any CDI beans.
> This is done to improve the startup time.
>
> There is kind of a positive/negative lookup logic.
> https://github.com/apache/meecrowave/blob/trunk/
> meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/
> KnowClassesFilter.java#L41
>
> We have the 'included': if some class starts with any of those package
> names, then we add it
> If the class package does not show up in the included list then we look
> into the 'excluded'.
> And if we find it there, then we skip the whole class.
>
> Sadly 'org.apache.myfaces' is in this very 'excluded' list ...
> And this is why Dennis' sample beans are not found. Any other project will
> work perfectly fine.
>
> Do we like to make this configurable?
>
> Actually I think we do not even need this. It should only be used if you
> create a single-jar packaging (uberjar).
> Otherwise the 'bad' jars in question are already filtered out as a whole
> anyway by the!
>
>
> A quick hack would be to add a Filter and register it in
> openwebbeans.properties.
> That will of course trash the portability of your sample...
>
> LieGrue,
> strub
>
>
> On Tuesday, 6 February 2018, 09:24:15 CET, Romain Manni-Bucau <
> rmannibucau@gmail.com> wrote:
>
>
> Hi Dennis,
>
> can you check this diff https://gist.github.com/rmannibucau/
> c63afe1326ca9e7409735b3f5911ea45 ?
>
> I'm not sure why the bean is not found, is it a bad JSF setup?
>
> About the duplicate, it seems myfaces adds twice the same bean if you scan
> it: once by scanning, once in the extension org.apache.myfaces.flow.cdi.
> FlowBuilderCDIExtension#beforeBeanDiscovery. So long story
> short org.apache.webbeans.config.BeansDeployer#addAdditionalAnnotatedTypes
> ends up adding again the same beans. We can surely filter it in OWB but
> also guess you should be able to make it working without scanning myfaces
> at all, no?
>
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://rmannibucau.metawerx.net/> | Old Blog
> <http://rmannibucau.wordpress.com> | Github
> <https://github.com/rmannibucau> | LinkedIn
> <https://www.linkedin.com/in/rmannibucau> | Book
> <https://www.packtpub.com/application-development/java-ee-8-high-performance>
>
> 2018-02-06 8:04 GMT+01:00 Dennis Kieselhorst <de...@apache.org>:
>
> Hi Romain,
>
> thanks for your feedback. Let's leave out Tobago, the demo needs to run in
> several setups and is somehow complex.
>
> We are about to release MyFaces 2.3.0 and I'd like to create an archetype
> for plain MyFaces and Meecrowave. Tried with a simple hello world sample
> but still getting DuplicateDefinitionException.
>
> Can you please take a look? https://github.com/deki/
> myfaces-meecrowave-sample
> <https://github.com/deki/myfaces-meecrowave-sample>
>
> Cheers
> Dennis
>
>
>

Re: [meecrowave] run JSF MyFaces application

Posted by Mark Struberg <st...@yahoo.de>.
Hi folks!
I've debugged the example and it falls into the category 'bad luck' ;)
Meecrowave has a specialised Filter KnowClassesFilter which by default excludes some packages which are well known to not contain any CDI beans. This is done to improve the startup time.
There is kind of a positive/negative lookup logic.https://github.com/apache/meecrowave/blob/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/openwebbeans/KnowClassesFilter.java#L41

We have the 'included': if some class starts with any of those package names, then we add it If the class package does not show up in the included list then we look into the 'excluded'.And if we find it there, then we skip the whole class.
Sadly 'org.apache.myfaces' is in this very 'excluded' list ...And this is why Dennis' sample beans are not found. Any other project will work perfectly fine.

Do we like to make this configurable?
Actually I think we do not even need this. It should only be used if you create a single-jar packaging (uberjar).Otherwise the 'bad' jars in question are already filtered out as a whole anyway by the!


A quick hack would be to add a Filter and register it in openwebbeans.properties. That will of course trash the portability of your sample...

LieGrue,strub
 

    On Tuesday, 6 February 2018, 09:24:15 CET, Romain Manni-Bucau <rm...@gmail.com> wrote:  
 
 Hi Dennis,
can you check this diff https://gist.github.com/rmannibucau/c63afe1326ca9e7409735b3f5911ea45 ?
I'm not sure why the bean is not found, is it a bad JSF setup?
About the duplicate, it seems myfaces adds twice the same bean if you scan it: once by scanning, once in the extension org.apache.myfaces.flow.cdi.FlowBuilderCDIExtension#beforeBeanDiscovery. So long story short org.apache.webbeans.config.BeansDeployer#addAdditionalAnnotatedTypes ends up adding again the same beans. We can surely filter it in OWB but also guess you should be able to make it working without scanning myfaces at all, no?


Romain Manni-Bucau
@rmannibucau |  Blog | Old Blog | Github | LinkedIn | Book
2018-02-06 8:04 GMT+01:00 Dennis Kieselhorst <de...@apache.org>:

Hi Romain,

thanks for your feedback. Let's leave out Tobago, the demo needs to run in several setups and is somehow complex.

We are about to release MyFaces 2.3.0 and I'd like to create an archetype for plain MyFaces and Meecrowave. Tried with a simple hello world sample but still getting DuplicateDefinitionException.

Can you please take a look? https://github.com/deki/ myfaces-meecrowave-sample

Cheers
Dennis



  

Re: [meecrowave] run JSF MyFaces application

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi Dennis,

can you check this diff
https://gist.github.com/rmannibucau/c63afe1326ca9e7409735b3f5911ea45 ?

I'm not sure why the bean is not found, is it a bad JSF setup?

About the duplicate, it seems myfaces adds twice the same bean if you scan
it: once by scanning, once in the
extension org.apache.myfaces.flow.cdi.FlowBuilderCDIExtension#beforeBeanDiscovery.
So long story
short org.apache.webbeans.config.BeansDeployer#addAdditionalAnnotatedTypes
ends up adding again the same beans. We can surely filter it in OWB but
also guess you should be able to make it working without scanning myfaces
at all, no?



Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>

2018-02-06 8:04 GMT+01:00 Dennis Kieselhorst <de...@apache.org>:

> Hi Romain,
>
> thanks for your feedback. Let's leave out Tobago, the demo needs to run in
> several setups and is somehow complex.
>
> We are about to release MyFaces 2.3.0 and I'd like to create an archetype
> for plain MyFaces and Meecrowave. Tried with a simple hello world sample
> but still getting DuplicateDefinitionException.
>
> Can you please take a look? https://github.com/deki/
> myfaces-meecrowave-sample
>
> Cheers
> Dennis
>
>

Re: [meecrowave] run JSF MyFaces application

Posted by Dennis Kieselhorst <de...@apache.org>.
Hi Romain,

thanks for your feedback. Let's leave out Tobago, the demo needs to run in several setups and is somehow complex.

We are about to release MyFaces 2.3.0 and I'd like to create an archetype for plain MyFaces and Meecrowave. Tried with a simple hello world sample but still getting DuplicateDefinitionException.

Can you please take a look? https://github.com/deki/myfaces-meecrowave-sample

Cheers
Dennis


Re: [meecrowave] run JSF MyFaces application

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

Yes it works but you must not start twice openwebbeans (1. meecrowave, 2.
in your web.xml
with org.apache.webbeans.servlet.WebBeansConfigurationListener). Also drop
OWB from your app and the API jars which are alsoready provided (should
never be in a container by spec even if we tolerate it.
You will also need to
declare org.apache.myfaces.webapp.StartupServletContextListener.

I don't know tobago enough to help more but it should enable you to get
started I hope.


Le 3 févr. 2018 20:16, "Dennis Kieselhorst" <de...@apache.org> a écrit :

Hi,

is it possible to run meecrowave with a JSF MyFaces application? I always
get a DuplicateDefinitionException.

[ERROR][           main][rBase.[Tomcat].[localhost].[/]] Exception sending
context initialized event to listener instance of class
[org.apache.webbeans.servlet.WebBeansConfigurationListener]
org.apache.webbeans.exception.DuplicateDefinitionException:
PassivationCapable bean id is not unique: SERVLET_CONTEXT#interface
javax.servlet.ServletContext#@javax.enterprise.inject.Defaul
t(),@javax.enterprise.inject.Any(), bean:ServletContext,
WebBeansType:SERVLET_CONTEXT, Name:null, API
Types:[java.lang.Object,javax.servlet.ServletContext],
Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any]
        at org.apache.webbeans.container.BeanManagerImpl.addPassivationInfo(BeanManagerImpl.java:410)
~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.container.BeanManagerImpl.addInternalBean(BeanManagerImpl.java:364)
~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.web.lifecycle.WebContainerLifecycle.star
tApplication(WebContainerLifecycle.java:90) ~[openwebbeans-web-2.0.3.jar:2
.0.3]
        at org.apache.webbeans.servlet.WebBeansConfigurationListener.co
ntextInitialized(WebBeansConfigurationListener.java:85)
~[openwebbeans-web-2.0.3.jar:2.0.3]

Reproducible with https://github.com/apache/myfa
ces-tobago/tree/master/tobago-example/tobago-example-demo by running mvn
clean package meecrowave:run -Djsf=myfaces-2.2

If I simplify the example and try it without Tobago with plain MyFaces it
results in:
Caused by: org.apache.webbeans.exception.DuplicateDefinitionException:
PassivationCapable bean id is not unique: PRODUCERMETHOD#class
javax.faces.flow.builder.FlowBuilder#@javax.faces.flow.builder.Flow
BuilderParameter(),@javax.enterprise.inject.Any(),#public
javax.faces.flow.builder.FlowBuilder org.apache.myfaces.flow.cdi.Fl
owBuilderFactoryBean.createFlowBuilderInstance() bean:FlowBuilder, WebBeansT
ype:PRODUCERMETHOD, Name:null, API Types:[javax.faces.flow.builde
r.FlowBuilder,java.lang.Object], Qualifiers:[javax.faces.flow.b
uilder.FlowBuilderParameter,javax.enterprise.inject.Any], Producer Method
: public javax.faces.flow.builder.FlowBuilder org.apache.myfaces.flow.cdi.Fl
owBuilderFactoryBean.createFlowBuilderInstance()
        at org.apache.webbeans.container.BeanManagerImpl.addPassivationInfo(BeanManagerImpl.java:410)
~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.container.BeanManagerImpl.addInternalBean(BeanManagerImpl.java:364)
~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.container.BeanManagerImpl.addBean(BeanManagerImpl.java:351)
~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.config.BeansDeployer.defineManagedBean(BeansDeployer.java:2058)
~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.config.BeansDeployer.deploySingleAnnotat
edType(BeansDeployer.java:1548) ~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.config.BeansDeployer.deployFromBeanAttributes(BeansDeployer.java:1504)
~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:313)
~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.lifecycle.AbstractLifeCycle.bootstrapApp
lication(AbstractLifeCycle.java:137) ~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplica
tion(AbstractLifeCycle.java:103) ~[openwebbeans-impl-2.0.3.jar:2.0.3]
        at org.apache.webbeans.web.lifecycle.WebContainerLifecycle.star
tApplication(WebContainerLifecycle.java:98) ~[openwebbeans-web-2.0.3.jar:2
.0.3]
        at org.apache.webbeans.servlet.WebBeansConfigurationListener.co
ntextInitialized(WebBeansConfigurationListener.java:85)
~[openwebbeans-web-2.0.3.jar:2.0.3]
        at org.apache.meecrowave.openwebbeans.OWBAutoSetup$EagerBootLis
tener.doContextInitialized(OWBAutoSetup.java:80)
~[meecrowave-core-1.2.0.jar:1.2.0]

Any hint greatly appreciated...

Cheers
Dennis