<!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="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">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;">
    Implementing a non-flat deployment for Weld Integration
</h3>
<span style="margin-bottom: 10px;">
    reply from <a href="http://community.jboss.org/people/flavia.rainone%40jboss.com">Flavia Rainone</a> in <i>JBoss Microcontainer Development POJO Server</i> - <a href="http://community.jboss.org/message/546199#546199">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><blockquote class="jive-quote"><p>Flavia Rainone wrote:</p> <p>Finally, the tests are very poor. I just ported the already existing ones to test the new deployers. So writing real tests is what I'll be doing next, and I'm sure I have quite a few bugs to catch ;-)</p></blockquote><p>I stumbled upon some issue here.</p><p>The problem is located in WeldFilesDeployer:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Iterable&lt;VirtualFile&gt; classpaths = getClassPaths(unit);
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>for</b></font> (VirtualFile cp : classpaths)
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; VirtualFile wbXml = cp.getChild(<font color="red">"META-INF/beans.xml"</font>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>if</b></font> (wbXml.exists())
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">// add url</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; wbFiles.add(wbXml);
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">// add classes</font>
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; cpFiles.add(cp);
&#160;
&#160;
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font>
&#160;
</code></pre><p>This deployer deploys the cpFiles of the current unit only if it has the META-INF/beans.xml file.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The problem with this is that this results in an ArchiveInfo without any classes in it if we deploy an ejb-jar without META-INF/beans.xml. In the future, if Weld request for a BDA associated with the ejb-jar by calling Deployment.loadBeanDeploymentArchive, it will get a BDA that has no classes in it.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So, I tried to "fix" it:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Iterable&lt;VirtualFile&gt; classpaths = getClassPaths(unit);
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>for</b></font> (VirtualFile cp : classpaths)
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; VirtualFile wbXml = cp.getChild(<font color="red">"META-INF/beans.xml"</font>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>if</b></font> (wbXml.exists())
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">// add url</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; wbFiles.add(wbXml);
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font>
&#160;
&#160;
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">// add classes</font>
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; cpFiles.add(cp);
&#160;
&#160;
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font>
&#160;
&#160;
&#160;
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This resulted in a series of test failures. All related with the criteria that we use to decide whether to put a class in a BDA.</p><p>Overall, these are the scenarios that are broken:</p><p>- if one or more lib jars in an ear happen to not have a META-INF/beans.xml file, the lib classes were not part of the BDA that represents the ear (note that currently I'm creating a BDA for every classLoader. So, for an ear, there is a single BDA that contains all the info regarding lib jars and ejb-jars in it).</p><p>- if one ore more ejb-jars in an ear happen to not have a META-INF/beans.xml file, the classes of those non-CDI ejb-jars were not part of the resulting BDA</p><p>- if in a war that contains a WEB-INF/beans.xml we have one ore more lib jars that don't have a META-INF/beans.xml, the classes of those libs are not part of the resulting BDA (we currently create a single BDA for every war; this BDA represents both the classes and the libs of the war)</p><p>- if, in a war that lacks a WEB-INF/beans.xml, we have one ore more lib jars that have the META-INF/beans.xml, the classes of the war (WEB-INF/classes) are not part of the resulting BDA.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>In all the scenarios I described, the classes that were not part of the resulting BDA became part of the BDA with my "fix".</p><p>Notice that, interestingly, in the way things are implemented today, if you pass one of the missing classes as a parameter to a Deployment.loadBeanDeploymentArchive, my implementation will return the requested BDA correctly, but still the BDA wil lack the requested class!</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So, we clearly have made some mistaken assumption here:</p><p>- either the classes that were not part of the BDAs in the previously described scenarios were supposed to be in the BDA and I fixed the bug. Now, all I have left to do is fixing the tests as well.</p><p>- or we should not create a BDA for every ClassLoader. We should be creating a BDA for every classpath entry (i.e., there should be a BDA for the WEB-INF/classes war; and another BDA for every lib in the war; simillarly, there should be a BDA for every distinct jar in the ear archive). As a result, we have one ore more BDAs that can see each other simultaneously because they all happen to belong to the same ClassLoader. Also, in a single AS instace, we will have a larger number of BDAs when compared to my current implementation.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Which way should I go now?</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/546199#546199">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Microcontainer Development POJO Server at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2116">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>