Skip to main content

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

7 replies [Last post]
codeprince
Offline
Joined: 2007-05-10
Points: 0

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...
>
> @Named
> public class MessageServerBean {
>
> public String getMessage() {
> return "Hello World!";
> }
> }
>
> And, I apply the cdi bean in a simple jsf page as following,
> ...
>
> This page is rendering from Module 3.
> Message is : #{messageServerBean.message}
> Message Server Bean is : #{messageServerBean}
>
> ...
>
> 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@5fffe
>
> So, I think that this should be a big bug from WAB, and wish sahoo and
> siva confirm the above.
>
> Thanks.
> --Tang
>
>

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
codeprince
Offline
Joined: 2007-05-10
Points: 0

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.

However, I do not know why needing to put faces-config.xml in WAB scene,
in common WAR scene, we need not put it.

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...
>>
>> @Named
>> public class MessageServerBean {
>>
>> public String getMessage() {
>> return "Hello World!";
>> }
>> }
>>
>> And, I apply the cdi bean in a simple jsf page as following,
>> ...
>>
>> This page is rendering from Module 3.
>> Message is : #{messageServerBean.message}
>> Message Server Bean is : #{messageServerBean}
>>
>> ...
>>
>> 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@5fffe
>>
>> So, I think that this should be a big bug from WAB, and wish sahoo and
>> siva confirm the above.
>>
>> Thanks.
>> --Tang
>>
>>
>
>

Sivakumar Thyag...
Offline
Joined: 2012-01-04
Points: 0

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...
>>>
>>> @Named
>>> public class MessageServerBean {
>>>
>>> public String getMessage() {
>>> return "Hello World!";
>>> }
>>> }
>>>
>>> And, I apply the cdi bean in a simple jsf page as following,
>>> ...
>>>
>>> This page is rendering from Module 3.
>>> Message is : #{messageServerBean.message}
>>> Message Server Bean is : #{messageServerBean}
>>>
>>> ...
>>>
>>> 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@5fffe
>>>
>>> So, I think that this should be a big bug from WAB, and wish sahoo and
>>> siva confirm the above.
>>>
>>> Thanks.
>>> --Tang
>>>
>>>
>>
>>

codeprince
Offline
Joined: 2007-05-10
Points: 0

Hi Siva, Sahoo,

Thanks your comments very much.

> What were the contents of your faces-config.xml?

org.jboss.weld.jsf.ConversationAwareViewHandler

org.jboss.weld.jsf.WeldPhaseListener

org.glassfish.weld.jsf.WeldApplicationFactory

> 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...
>>>>
>>>>
>>>> @Named
>>>> public class MessageServerBean {
>>>>
>>>> public String getMessage() {
>>>> return "Hello World!";
>>>> }
>>>> }
>>>>
>>>> And, I apply the cdi bean in a simple jsf page as following,
>>>> ...
>>>>
>>>> This page is rendering from Module 3.
>>>> Message is : #{messageServerBean.message}
>>>> Message Server Bean is : #{messageServerBean}
>>>>
>>>> ...
>>>>
>>>> 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@5fffe
>>>>
>>>> So, I think that this should be a big bug from WAB, and wish sahoo and
>>>> siva confirm the above.
>>>>
>>>> Thanks.
>>>> --Tang
>>>>
>>>>
>>>
>>>
>
>

ss141213
Offline
Joined: 2005-03-30
Points: 0

On Monday 26 November 2012 10:22 PM, 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.
>
Siva,

Your response reminded me of an earlier issue like this that both of us
had investigated in the past.

Tang,

See if the work around [1] mentioned in issue GLASSFISH-15225 fixes your
issue or not.

Thanks,
Sahoo

[1]
http://java.net/jira/browse/GLASSFISH-15225?focusedCommentId=149138&page...

codeprince
Offline
Joined: 2007-05-10
Points: 0

Hi sahoo, siva,

I have seen GLASSFISH-15225 and should be the same with my issue.
And I just used the same faces-config.xml to resolve the issue.

I think that we should raise the Priority of 15225 and fix it.

Thanks.
--Tang

Sahoo wrote:
> On Monday 26 November 2012 10:22 PM, 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.
>>
> Siva,
>
> Your response reminded me of an earlier issue like this that both of us
> had investigated in the past.
>
> Tang,
>
> See if the work around [1] mentioned in issue GLASSFISH-15225 fixes your
> issue or not.
>
> Thanks,
> Sahoo
>
> [1]
> http://java.net/jira/browse/GLASSFISH-15225?focusedCommentId=149138&page...
>
>

codeprince
Offline
Joined: 2007-05-10
Points: 0

Hi sahoo,

Thanks your link and I will confirm it.

Thanks.
--Tang

Sahoo wrote:
> On Monday 26 November 2012 10:22 PM, 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.
>>
> Siva,
>
> Your response reminded me of an earlier issue like this that both of us
> had investigated in the past.
>
> Tang,
>
> See if the work around [1] mentioned in issue GLASSFISH-15225 fixes your
> issue or not.
>
> Thanks,
> Sahoo
>
> [1]
> http://java.net/jira/browse/GLASSFISH-15225?focusedCommentId=149138&page...
>
>

codeprince
Offline
Joined: 2007-05-10
Points: 0

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...

@Named
public class MessageServerBean {

public String getMessage() {
return "Hello World!";
}
}

And, I apply the cdi bean in a simple jsf page as following,
...

This page is rendering from Module 3.
Message is : #{messageServerBean.message}
Message Server Bean is : #{messageServerBean}

...

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@5fffe

So, I think that this should be a big bug from WAB, and wish sahoo and
siva confirm the above.

Thanks.
--Tang