users@glassfish.java.net

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

From: Tang Yong <tangyong_at_cn.fujitsu.com>
Date: Mon, 26 Nov 2012 12:16:48 +0900

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