users@glassfish.java.net

Re: _at_Named CDI Bean of a WAB is not available in a jsf page

From: Tang Yong <tangyong_at_cn.fujitsu.com>
Date: Tue, 27 Nov 2012 10:17:39 +0900

Hi Siva, Sahoo,

Thanks your comments very much.

> What were the contents of your faces-config.xml?
<application>
    <view-handler>
      org.jboss.weld.jsf.ConversationAwareViewHandler
    </view-handler>
</application>

<lifecycle>
     <phase-listener>
       org.jboss.weld.jsf.WeldPhaseListener
     </phase-listener>
</lifecycle>

<factory>
     <application-factory>
        org.glassfish.weld.jsf.WeldApplicationFactory
     </application-factory>
</factory>

> The weld-integration module by default enables a custom faces-config.xml
> (through a FacesConfigProvider) that adds in Weld PhaseListener and
> application factory. In the WAB scenario we may not be doing this.

According to my above contents of faces-config.xml and siva's comment,
there is a big possibility that in WAB scenario, Weld PhaseListener and
application factory have not been added.

Thanks.
--Tang

Sivakumar Thyagarajan wrote:
> Hi Tang
> [removing the dev alias]
>
> On Monday 26 November 2012 11:23 AM, Tang Yong wrote:
>> Hi sahoo, siva,
>>
>> I have confirmed that if I put a faces-config.xml into META-INF, then,
>> after redeploying the WAB and accessing
>> http://localhost:8080/module3/faces/index.xhtml, the result is right.
>
> What were the contents of your faces-config.xml?
>
>> However, I do not know why needing to put faces-config.xml in WAB scene,
>> in common WAR scene, we need not put it.
>
> The weld-integration module by default enables a custom faces-config.xml
> (through a FacesConfigProvider) that adds in Weld PhaseListener and
> application factory. In the WAB scenario we may not be doing this.
>
> Thanks
> --Siva.
>
>>
>> Thanks.
>> --Tang
>>
>> Tang Yong wrote:
>>> FYI: the bug directly caused GLASSFISH-17155 can not work
>>> normally.(GLASSFISH-17155's sample also has many problems, however,
>>> while I modified it and executed the last step, the bug was triggered).
>>>
>>> Thanks.
>>>
>>> Tang Yong wrote:
>>>> Hi sahoo, siva,
>>>>
>>>> I found a big bug in a hybrid javaee application(WAB).
>>>>
>>>> [Bug Scene]
>>>>
>>>> I have a WAB using CDI and define a simple cdi bean according to [1],
>>>>
>>>> [1]:
>>>> http://www.andygibson.net/blog/tutorial/getting-started-with-jsf-2-0-and-cdi-in-jee-6-part-1/
>>>>
>>>>
>>>> @Named
>>>> public class MessageServerBean {
>>>>
>>>> public String getMessage() {
>>>> return "Hello World!";
>>>> }
>>>> }
>>>>
>>>> And, I apply the cdi bean in a simple jsf page as following,
>>>> ...
>>>> <body>
>>>> This page is rendering from Module 3.
>>>> Message is : #{messageServerBean.message}<br/>
>>>> Message Server Bean is : #{messageServerBean}
>>>> </body>
>>>> ...
>>>>
>>>> Then, I wrap the cdi bean and jsp page into a WAB in which
>>>> Web-ContextPath is /module3. Then, using the following command is to
>>>> deploy the WAB.
>>>>
>>>> asadmin deploy --type=osgi module3.war
>>>>
>>>> While I access http://localhost:8080/module3/faces/index.xhtml, the
>>>> following result happened,
>>>>
>>>> This page is rendering from Module 3. Message is :
>>>> Message Server Bean is :
>>>>
>>>> Apparently, the cdi bean has been not resolved.
>>>>
>>>> Then, I used the following command to deploy the war(rather than WAB),
>>>>
>>>> asadmin deploy module3.war
>>>>
>>>> While I access http://localhost:8080/module3/faces/index.xhtml again,
>>>> the right result happened.
>>>>
>>>> This page is rendering from Module 3. Message is : Hello World!
>>>> Message Server Bean is :
>>>> ranophoenix.osgijee.module1.impl.MessageServerBean_at_5fffe
>>>>
>>>> So, I think that this should be a big bug from WAB, and wish sahoo and
>>>> siva confirm the above.
>>>>
>>>> Thanks.
>>>> --Tang
>>>>
>>>>
>>>
>>>
>
>