<!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">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;">
    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/557388#557388">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>With a temporary workaround to the beanManager issue (simply replaced "entry.getKey().getId().equals("flat"))" by "entry.getKey().getClass().getName().contains("org.jboss.weld.integration.")") I ran into an issue involving the service registry. I'm not sure if this is related to the beanManager issue or not, but the problem is that Weld complains if a new BDA created by Deployment.loadBDA method has a clean service registry:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">DEPLOYMENTS IN ERROR:
&#160; Deployment "vfs:///home/fla/Development/projects/jbossas-trunk/testsuite/output/lib/weld-translator.ear_WeldBootstrapBean" is in error due to the following reason(s):
org.jboss.weld.exceptions.ForbiddenStateException: WELD-000117 Required service org.jboss.weld.injection.spi.EjbInjectionServices has not been specified, **ERROR**

&#160;&#160;&#160; at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:1370) [:2.2.0.Alpha6]
&#160;&#160;&#160; at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:1316) [:2.2.0.Alpha6]
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So, I created a workaround to populate the loaded BDA service registry, just to see if the error would go away. DeploymentImpl initializes the loaded BDA service registry with a copy of the service registries of the BDAs contained in the DeploymentImpl (only services added during bootstrap).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This makes WeldNumberguessExampleUnitTestCase to pass, but WeldTranslatorExampleUnitTestCase still fails, stating that TranslatorControllerBean is ambigously defined:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">DEPLOYMENTS IN ERROR:
&#160; Deployment <font color="red">"vfs:///home/fla/Development/projects/jbossas-trunkLATEST/testsuite/output/lib/weld-translator.ear_WeldBootstrapBean"</font> is in error due to the
following reason(s): org.jboss.weld.exceptions.DeploymentException: WELD-001414 Bean name is ambiguous. Name translator resolves to beans
[org.jboss.weld.bean-BaseClassLoader@62b92dc2<font color="navy">{</font>vfs:<font color="darkgreen">///home/fla/Development/projects/jbossas-trunkLATEST/build/target/jboss-6.0.0-SNAPSHOT/server/all/deployers/resteasy.deployer}-SessionBean-TranslatorControllerBean, org.jboss.weld.bean-BaseClassLoader@7e7186b{vfs:///home/fla/Development/projects/jbossas-trunkLATEST/testsuite/output/lib/weld-translator.ear}-SessionBean-TranslatorControllerBean],</font>
**ERROR**
&#160;
&#160;&#160;&#160; at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:1370) [:2.2.0.Alpha6]
&#160;&#160;&#160; at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:1316) [:2.2.0.Alpha6]
&#160;&#160;&#160; at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:968) [:2.2.0.Alpha6]
&#160;&#160;&#160; at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.checkComplete(MainDeployerPlugin.java:82) [:6.0.0-SNAPSHOT]
&#160;&#160;&#160; at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.checkComplete(ProfileControllerContext.java:125) [:0.1.0.Alpha1]
&#160;&#160;&#160; at org.jboss.profileservice.plugins.deploy.actions.DeploymentStartAction.doPrepare(DeploymentStartAction.java:104) [:0.1.0.Alpha1]
&#160;&#160;&#160; at org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction.prepare(AbstractTwoPhaseModificationAction.java:100) [:0.1.0.Alpha1]
&#160;&#160;&#160; at org.jboss.profileservice.management.ModificationSession.prepare(ModificationSession.java:87) [:0.1.0.Alpha1]
&#160;&#160;&#160; at org.jboss.profileservice.management.AbstractActionController.internalPerfom(AbstractActionController.java:234) [:0.1.0.Alpha1]
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So, the problem is that Weld finds two EjbDescriptors of the same bean. One in the BDA that represents weld-translator.ear, included in the corresponding DeploymentImpl, and another one in the bda that has been loaded by the Deployment, representing resteasy.deployer.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>If I still initialize the loaded BDA service registry with a copy of the other BDAs service registry, but this time adding a new, clean, JBossEJBServices to the loaded BDA serviceRegistry, and putting no EjbInjectionServices in it, I get a message complaining that the injection point has unsatisfied dependencies:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">DEPLOYMENTS IN ERROR:
&#160; Deployment "vfs:///home/fla/Development/projects/jbossas-trunkLATEST/testsuite/output/lib/weld-translator.ear_WeldBootstrapBean" is in error due to the following reason(s): org.jboss.weld.exceptions.DeploymentException: WELD-001408 Injection point has unsatisfied dependencies.&#160; Injection point:&#160; field org.jboss.test.deployers.weld.translator.ejb.TranslatorControllerBean.translator;&#160; Qualifiers:&#160; [@javax.enterprise.inject.Default()], **ERROR**

&#160;&#160;&#160; at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:1370) [:2.2.0.Alpha6]
&#160;&#160;&#160; at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:1316) [:2.2.0.Alpha6]
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>If anybody wants to retrace my steps, there is a <a class="jive-link-external-small" href="https://jira.jboss.org/browse/JBAS-8250">patch attached to Jira</a> that can be applied to JBoss AS trunk. You can check loadBDA implementation <a class="jive-link-external-small" href="http://anonsvn.jboss.org/repos/jbossas/trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java">here</a>.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So, what is expected from the ServiceRegistry of a newly created BDA? Should it be initialized with some services? Which ones?</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/557388#557388">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>