<!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;">
    Mark all Stateless EJBs as part of cluster using ejb3-interceptors-aop.xml
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/nitin_jain">Nitin Jain</a> in <i>JBoss AOP</i> - <a href="http://community.jboss.org/message/613833#613833">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hello Forum,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I am running my application in a clustered environment. I would like to avoid annotating every stateless EJB with @Clustered annotation and rather make use of "ejb3-interceptors-aop.xml".</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>When I use @Clustered annotation, the annotated EJB is logged by JBoss in the following manner.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">2011-07-07 10:06:18,251 INFO&#160; [org.jboss.ejb3.deployers.JBossASKernel] (main) Added bean(jboss.j2ee:ear=myapp.ear,jar=platform-services-ejbs.jar,name=NotificationProcessorBean,service=EJB3) to KernelDeployment of: platform-services-ejbs.jar
2011-07-07 10:06:18,251 INFO&#160; [org.jboss.ejb3.deployers.JBossASKernel] (main) installing bean: jboss.j2ee:ear=myapp.ear,jar=platform-services-ejbs.jar,name=RequestDispatcherBean,service=EJB3
2011-07-07 10:06:18,251 INFO&#160; [org.jboss.ejb3.deployers.JBossASKernel] (main)&#160;&#160; with dependencies:
2011-07-07 10:06:18,251 INFO&#160; [org.jboss.ejb3.deployers.JBossASKernel] (main)&#160;&#160; and demands:
2011-07-07 10:06:18,251 INFO&#160; [org.jboss.ejb3.deployers.JBossASKernel] (main)&#160; jboss.ejb:service=EJBTimerService
2011-07-07 10:06:18,251 INFO&#160; [org.jboss.ejb3.deployers.JBossASKernel] (main)&#160; partition:partitionName=MyCluster
2011-07-07 10:06:18,251 INFO&#160; [org.jboss.ejb3.deployers.JBossASKernel] (main)&#160;&#160; and supplies:
2011-07-07 10:06:18,251 INFO&#160; [org.jboss.ejb3.deployers.JBossASKernel] (main)&#160; Class:com.myapp.platform.bs.SampleEJB
2011-07-07 10:06:18,251 INFO&#160; [org.jboss.ejb3.deployers.JBossASKernel] (main)&#160; jndi:myapp/SampleEJBBean/remote-com.myapp.platform.bs.SampleEJB
2011-07-07 10:06:18,251 INFO&#160; [org.jboss.ejb3.deployers.JBossASKernel] (main)&#160; jndi:myapp/SampleEJBBean/remote</code></pre><p>From the log it can be understood that "SampleEJBBean" is part of "MyCluster".</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Is it possible to add annotation element for @Clustered annotation in "ejb3-interceptors-aop.xml" and achieve similar functionality?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>To give it a try I added the following elements in the "ejb3-interceptors-aop.xml" file present at "\server\all\deploy" with no success. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-xml">&#160;&#160; <span class="jive-xml-tag">&lt;domain name="Stateless Bean" extends="Intercepted Bean" inheritBindings="true"&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;bind pointcut="execution(public * *-&gt;</span>*(..))<span class="jive-xml-quote">&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/bind&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;bind pointcut="execution(public * @org.jboss.ejb3.annotation.SecurityDomain-&gt;</span>*(..))</span>&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;interceptor-ref name="Basic Authorization"/&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/bind&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;bind pointcut="execution(public * *-&gt;</span>*(..))<span class="jive-xml-quote">&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/bind&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;bind pointcut="execution(public * @org.jboss.ejb3.annotation.Clustered-&gt;</span>*(..))</span>&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;interceptor-ref name="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory"/&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/bind&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;bind pointcut="execution(public * *-&gt;</span>*(..))<span class="jive-xml-quote">&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;interceptor-ref name="org.jboss.ejb3.tx.CMTTxInterceptorFactory"/&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;interceptor-ref name="org.jboss.ejb3.tx.BMTTxInterceptorFactory"/&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-comment">&lt;!-- interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/ --&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;stack-ref name="EJBInterceptors"/&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/bind&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.Pool)"&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; @org.jboss.ejb3.annotation.Pool (value=</span>ThreadlocalPool<span class="jive-xml-quote">, maxSize=30, timeout=10000)
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/annotation&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;annotation expr="class(@javax.ejb.Remote) AND !class(@org.jboss.annotation.ejb.Clustered)"&gt;</span>
&#160;&#160;&#160;&#160;&#160; 

&#160;&#160;&#160;&#160; @org.jboss.annotation.ejb.Clustered(partition=</span>MyCluster<span class="jive-xml-quote">, loadBalancePolicy=</span>org.jboss.ha.framework.interfaces.RandomRobin")

&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/annotation&gt;</span>
&#160;&#160; <span class="jive-xml-tag">&lt;/domain&gt;</span>

</code></pre><p>I have tried other possiblities like </p><pre class="jive-pre"><code class="jive-code jive-xml">&#160;&#160; <span class="jive-xml-tag">&lt;annotation expr="class(*) AND !class(@org.jboss.annotation.ejb.Clustered)"&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160; @org.jboss.annotation.ejb.Clustered(partition=<span class="jive-xml-quote">MyCluster</span>, loadBalancePolicy=<span class="jive-xml-quote">org.jboss.ha.framework.interfaces.RandomRobin</span>)
&#160;&#160; <span class="jive-xml-tag">&lt;/annotation&gt;</span>

</code></pre><p>and </p><pre class="jive-pre"><code class="jive-code jive-xml">&#160;&#160; <span class="jive-xml-tag">&lt;annotation expr="!class(@org.jboss.annotation.ejb.Clustered)"&gt;</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; @org.jboss.annotation.ejb.Clustered(partition=<span class="jive-xml-quote">MyCluster</span>, loadBalancePolicy=<span class="jive-xml-quote">org.jboss.ha.framework.interfaces.RandomRobin</span>)
&#160;&#160; <span class="jive-xml-tag">&lt;/annotation&gt;</span>
</code></pre><p> but with no success. I do not see any of my other stateless EJB with a similar log as depicted for "SampleEJBBean".</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Please advise on how to fix this issue.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Regards,</p><p>Nitin</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/613833#613833">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss AOP at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2027">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


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

</div>

</body>
</html>