<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Reference managed beans in other module
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/faustodelatog">Fausto De La Torre</a> in <i>JBoss AS 7 Development</i> - <a href="https://community.jboss.org/message/763043#763043">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hi, </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I have a portal.war wich contains a few jsf pages and one (ManagedBean) Bean annotated @Named, in this war there is a file  WEB-INF/beans.xml, I can reference managed bean in jsf pages throw EL, everything works fine in this application. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Now, I have a another.war which depends of portal.war, the file another.war/META-INF/MANIFEST.MF contains the dependency (Dependencies: deployment.portal.war) and contains too WEB-INF/beans.xml, in this another.war I have a few jsf pages and a few ManagedBeans (Beans annotated @Named), in jsf pages I can reference managed beans which are in another.war throw EL whitout problems, however I want to reference the portal.war managed bean in my another.war jsf pages but I can not.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><table border="1" cellpadding="3" cellspacing="0" class="jiveBorder" style="width: 100%; border: 1px solid #000000;"><tbody><tr><th align="center" style="border:1px solid black;border: 1px solid #000000;background-color: #6690bc;" valign="middle"><span style="color: #ffffff;"><strong>portal.war<br/></strong></span></th><th align="center" style="border:1px solid black;border: 1px solid #000000;background-color: #6690bc;" valign="middle"><span style="color: #ffffff;"><strong><br/></strong></span></th><th align="center" style="border:1px solid black;border: 1px solid #000000;background-color: #6690bc;" valign="middle"><span style="color: #ffffff;"><strong>another.war<br/></strong></span></th><th align="center" style="border:1px solid black;border: 1px solid #000000;background-color: #6690bc;" valign="middle"><span style="color: #ffffff;"><strong><br/></strong></span></th></tr><tr><td style="border:1px solid black;border: 1px solid #000000;">WEB-INF/beans.xml</td><td style="border:1px solid black;border: 1px solid #000000;">ok</td><td style="border:1px solid black;border: 1px solid #000000;"><p>WEB-INF/beans.xml</p></td><td style="border:1px solid black;border: 1px solid #000000;">ok</td></tr><tr><td style="border:1px solid black;border: 1px solid #000000;"><p>com.test.portal</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>@Named public class PortalManagedBean {...</p></td><td style="border:1px solid black;border: 1px solid #000000;">ok</td><td style="border:1px solid black;border: 1px solid #000000;"><p>META-INF/MANIFEST.MF</p><p>   ...</p><p>   Dependencies: deployment.portal.war</p><p>   ...</p></td><td style="border:1px solid black;border: 1px solid #000000;">ok</td></tr><tr><td style="border:1px solid black;border: 1px solid #000000;"><br/></td><td style="border:1px solid black;border: 1px solid #000000;"><br/></td><td style="border:1px solid black;border: 1px solid #000000;"><p>com.test.another</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>@Named public class AnotherManagedBean {...</p></td><td style="border:1px solid black;border: 1px solid #000000;">ok</td></tr><tr><td style="border:1px solid black;border: 1px solid #000000;"><p>portalHome.xhtml </p><p>   ...</p><p>   <h:outputText value=#{portalManagedBean.text} /></p><p>   ...</p></td><td style="border:1px solid black;border: 1px solid #000000;">ok</td><td style="border:1px solid black;border: 1px solid #000000;"><p>anotherHome.xhtml </p><p>   ...</p><p>   <h:outputText value=#{anotherManagedBean.text} /></p><p>   ...</p></td><td style="border:1px solid black;border: 1px solid #000000;">ok</td></tr><tr><td style="border:1px solid black;border: 1px solid #000000;"><br/></td><td style="border:1px solid black;border: 1px solid #000000;"><br/></td><td style="border:1px solid black;border: 1px solid #000000;"><p><strong style="color: #ff0000;">anotherHome.xhtml </strong></p><p><strong style="color: #ff0000;">   ...</strong></p><p><strong style="color: #ff0000;">   <h:outputText value=#{portalManagedBean.text} /></strong></p><p><strong style="color: #ff0000;">   ...</strong></p></td><td style="border:1px solid black;border: 1px solid #000000;"><span style="color: #ff0000;"><strong>FAIL</strong></span></td></tr></tbody></table><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Two files portal.war and other.war are deployed in jboss 7. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I have read cdi documentation, I understand that a library or module wich contains a beans.xml is a "bean archive" and beans which are packaged in a bean archive are available for injection, lookup an EL resolution to classes ans jsf pages packaged in some other bean archive. A<span class="short_text" id="result_box" lang="en"><span class="hps">ccording to</span> <span class="hps">what</span> <span class="hps">the documentation says</span> <span class="hps">textuallyin the chapter of Modularity<br/></span></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-size: 8pt;"><em><span class="short_text" lang="en"><span class="hps">" </span></span>Beans and their clients may be deployed in modules in a module architecture such as the Java EE environment. In a mod-</em></span></p><p><span style="font-size: 8pt;"><em>ule architecture, certain modules are considered bean archives. In the Java EE module architecture, any Java EE module or</em></span></p><p><span style="font-size: 8pt;"><em>library is a module. The Java EE module or library is a bean archive if it contains a beans.xml file, as defined in Sec-</em></span></p><p><span style="font-size: 8pt;"><em>tion 12.1, “Bean archives”.</em></span></p><p><strong style="font-size: 8pt;"><em>A bean packaged in a certain module is available for injection, lookup and EL resolution to classes and JSP/JSF pages</em></strong></p><p><strong style="font-size: 8pt;"><em>packaged in some other module if and only if the bean class of the bean is required to be accessible to the other module by</em></strong></p><p><strong style="font-size: 8pt;"><em>the class accessibility requirements of the module architecture. In the Java EE module architecture, a bean class is access-</em></strong></p><p><strong style="font-size: 8pt;"><em>ible in a module if and only if it is required to be accessible according to the class loading requirements defined by the</em></strong></p><p><strong style="font-size: 8pt;"><em>Java EE platform specification.</em></strong></p><p><span style="font-size: 8pt;"><em>Note that, in some Java EE implementations, a bean class might be accessible to some other class even when this is not re-</em></span></p><p><span style="font-size: 8pt;"><em>quired by the Java EE platform specification. For the purposes of this specification, a class is not considered accessible to</em></span></p><p><span style="font-size: 8pt;"><em>another class unless accessibility is explicitly required by the Java EE platform specification.</em></span></p><p><span style="font-size: 8pt;"><em>An alternative is not available for injection, lookup or EL resolution to classes or JSP/JSF pages in a module unless the</em></span></p><p><span style="font-size: 8pt;"><em>module is a bean archive and the alternative is explicitly selected in that bean archive. An alternative is never available for</em></span></p><p><span style="font-size: 8pt;"><em>injection, lookup or EL resolution in a module that is not a bean archive.</em></span><span style=": ; font-size: 8pt;"><em>"</em></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style=": ; font-size: 10pt;">I have found a "solution" for this but I do not believe that is the best way, is for that I want to ask you What I can do for this purpose.</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style=": ; font-size: 10pt;">My "solution" is create an empty class </span><span style=": ; font-size: 10pt;">com.test.portal.</span>PortalManagedBean<span style=": ; font-size: 10pt;"> in another.war, thus jsf pages can resolve </span><strong style="color: #ff0000;">#{portalManagedBean.text}, </strong><span style="color: #000000;">But i repeat I do not think is the correct way.</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="color: #000000;">PD: My english is not the best, I hope you undestand me<br/></span></p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/763043#763043">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss AS 7 Development at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2225">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>