<!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;">
    JBoss-classloading.xml in EAR /EJB
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/lordpraveen">Prav Ford</a> in <i>JBoss Microcontainer</i> - <a href="http://community.jboss.org/message/562595#562595">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;">&#160;</p><p>I have an EAR which I deploy in jboss-5.1.0.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>A.EAR</p><p>&#160;&#160;&#160; |----lib/x.jar</p><p>&#160;&#160;&#160; |----EJB1.jar</p><p>&#160;&#160;&#160; |----EJB2.jar</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p> I wanted to just expose the interfaces from the EJB's, hence I have jboss-classloading.xml in both EJB1.jar and EJB2.jar.</p><p>What I was hoping to achieve is that just have the interfaces exposed in my EJB's to other EJB's in the same EAR and also to other EAR's in AS.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>EJB1.jar</p><p>&#160;&#160;&#160; |-----------com.ejb1.interface.EJB1Intf / EJB1IntfLocal extends EJB1Intf / EJB1IntfRemote extends EJB1Intf</p><p>&#160;&#160;&#160; |-----------com.ejb1.implementation.EJB1Bean implements EJB1IntfLocal,EJB1IntfRemote.</p><p>&#160;&#160;&#160; |-----------META-INF/jboss-classloading.xml</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag">&lt;classloading xmlns="urn:jboss:classloading:1.0" domain="A.EAR-0.0.1-SNAPSHOT-exploded.ear" parent-domain="DefaultDomain"
&#160;&#160;&#160; export-all="NON_EMPTY" import-all="true" excluded="META-INF"&gt;</span>
&#160;&#160;&#160; <span class="jive-xml-tag">&lt;capabilities&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;package name="com.ejb1.interface" /&gt;</span>
&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/capabilities&gt;</span>
<span class="jive-xml-tag">&lt;/classloading&gt;</span></code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Similarly for EJB2.jar.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This is how my jmx-console looks like:</p><h2><a class="jive-link-anchor-small">jboss.classloader</a></h2><ul><li><a class="jive-link-external-small" href="http://localhost:8080/jmx-console/HtmlAdaptor?action=inspectMBean&amp;name=jboss.classloader%3Asystem%3D557851707%2Cdomain%3D%22ExamplesEAR-0.0.1-SNAPSHOT-exploded.ear%22">domain="A.EAR-0.0.1-SNAPSHOT-exploded.ear",system=557851707</a></li><li><a class="jive-link-external-small" href="http://localhost:8080/jmx-console/HtmlAdaptor?action=inspectMBean&amp;name=jboss.classloader%3Aid%3D%22vfsfile%3A%2FVolumes%2FMustang%2Fbranch%2FJBoss_CELMI_20091103%2Fjboss-5.1.0.GA%2Fserver%2Fcelmi%2Fdeploy%2FExamplesEAR-0.0.1-SNAPSHOT-exploded.ear%2F%22">id="vfsfile:/jboss-5.1.0.GA/server/default/deploy/AEAR-0.0.1-SNAPSHOT-exploded.ear/"</a></li><li><a class="jive-link-external-small" href="http://localhost:8080/jmx-console/HtmlAdaptor?action=inspectMBean&amp;name=jboss.classloader%3Aid%3D%22vfszip%3A%2FVolumes%2FMustang%2Fbranch%2FJBoss_CELMI_20091103%2Fjboss-5.1.0.GA%2Fserver%2Fcelmi%2Fdeploy%2FExamplesEAR-0.0.1-SNAPSHOT-exploded.ear%2FProducerEJB-0.0.1-SNAPSHOT.jar%2F%22">id="vfszip:/jboss-5.1.0.GA/server/default/deploy/AEAR-0.0.1-SNAPSHOT-exploded.ear/EJB1.jar/"</a></li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>EJB1 calls EJB2 via JNDI.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>EJB1Bean:</p><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>public</b></font> <font color="navy"><b>boolean</b></font> callTheOtheEJB() <font color="navy">{</font>
&#160;&#160;&#160; EJB2Intf myStateless = lookup(EJB2Intf.class, <font color="red">"service/EJB2IntfBean"</font>);
&#160;&#160;&#160; logger.info(<font color="red">"Called myStateless sayHello = "</font>+&#160; myStateless.sayHello());
&#160;&#160;&#160;&#160; <font color="navy"><b>return</b></font> <font color="navy"><b>true</b></font>;
&#160;&#160;&#160; <font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>EJB2Bean:</p><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>public</b></font> String sayHello()<font color="navy">{</font>
&#160;&#160;&#160;&#160; <font color="navy"><b>return</b></font> <font color="red">"Hello"</font>
<font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>My Client:</p><pre class="jive-pre"><code class="jive-code jive-java">Properties props = <font color="navy"><b>new</b></font> Properties();
&#160;&#160;&#160; props.put(InitialContext.INITIAL_CONTEXT_FACTORY, <font color="red">"org.jnp.interfaces.NamingContextFactory"</font>);
&#160;&#160;&#160; props.put(InitialContext.PROVIDER_URL, <font color="red">"jnp://127.0.0.1:1099"</font>);
&#160;&#160;&#160; <font color="navy"><b>try</b></font> <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; InitialContext jndiContext = <font color="navy"><b>new</b></font> InitialContext(props);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Object obj = jndiContext.lookup(<font color="red">"AEAR-0.0.1-SNAPSHOT-exploded/EJB1Bean/remote"</font>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println(obj.getClass());
&#160;&#160;&#160;&#160;&#160;&#160;&#160; EJB1Intf callingEJBIntf = (EJB1Intf)obj;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; callingEJBIntf.callTheOtheEJB();
&#160;
&#160;&#160;&#160; <font color="navy">}</font> <font color="navy"><b>catch</b></font> (NamingException e) <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">// TODO Auto-generated catch block</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.printStackTrace();
&#160;&#160;&#160; <font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Problem: EJB1 cant see EJB2Intf.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Caused by: java.lang.ClassNotFoundException: com.ejb2.interface.EJB2Intf from BaseClassLoader@1f9c621d{VFSClassLoaderPolicy@53ed6e21{name=vfszip:/jboss-5.1.0.GA/server/default/deploy/AEAR-0.0.1-SNAPSHOT-exploded.ear/EJB1.jar/ domain=ClassLoaderDomain@b901239{name=AEAR-0.0.1-SNAPSHOT-exploded.ear parentPolicy=BEFORE parent=ClassLoaderDomain@7a0aae8a{DefaultDomain}} roots=[DelegatingHandler@148464531[path=AEAR-0.0.1-SNAPSHOT-exploded.ear/EJB1.jar context=file:/jboss-5.1.0.GA/server/default/deploy/ real=file:/jboss-5.1.0.GA/server/default/deploy/AEAR-0.0.1-SNAPSHOT-exploded.ear/EJB1.jar]]&#160; delegates=null exported=[com.ejb1.interface]NON_EMPTY}}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>They are part of the same ClassLoaderDomain.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>When I do listExportingClassloader() for AEAR domain,</p><pre>{com.ejb1.interface=[jboss.classloader:id="vfszip:/jboss-5.1.0.GA/server/default/deploy/<br/>AEAR-0.0.1-SNAPSHOT-exploded.ear/EJB1-SNAPSHOT.jar/"], <br/>com.ejb2.interface=[jboss.classloader:id="vfszip:/jboss-5.1.0.GA/server/default/deploy/<br/>AEAR-0.0.1-SNAPSHOT-exploded.ear/EJB2-SNAPSHOT.jar/"]}
</pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Can anyone help? I am not sure where I am going wrong.</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/562595#562595">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Microcontainer at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2114">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


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

</div>

</body>
</html>