3 Replies Latest reply on Jul 1, 2010 1:09 PM by elgabo

    calling aspect from netty thread inside jboss 5.1

    elgabo

      Hi,

       

      We are using netty to send and receive network messages.  But for some reason advices are not being called when messages are received.

       

      All classes and xml files involved on the project are _not_ inside the same jar, basically I have 2  jar, basic.jar with common code like the aspect, the jboss-beans.xml  file where the netty SocketChannelFactory is defined (a exact copy of  the file found inside netty.jar/META-INF/jboss-beans.xml) and other  common beans defined inside jboss-beans.xml file

       

      basic.jar

      +com.test.* (common classes)

      +com.test.TestAspect

      +META-INF

           +jboss-beans.xml

           +netty-jboss-beans.xml

       

      And network.jar with  network specific code like MyNetworkListener, netty ChannleHandlers, and  of course the jboss-beans.xml file that defines beans and aspects

       

      network.jar

      +com.test.MyNetworkListener

      +META-INF

           +jboss-beans.xml

       

      For example I have the following aspect:

       

      public class TestAspect {

         createSomething(MethodInvocation inv) {...}

         updateSomething(MethodInvocation inv) {...}

      }

       

      updateSomething must be called after a message is received from network so inside jboss-beans.xml I put

       

      <aop:aspect xmlns:aop="urn:jboss:aop-beans:1.0"
              xsi:schemaLocation="urn:jboss:aop-beans:1.0 aop-beans_1_0.xsd"
              class="com.test.TestAspect" name="TestAspect"/>


      <aop:bind xmlns:aop="urn:jboss:aop-beans:1.0"
              xsi:schemaLocation="urn:jboss:aop-beans:1.0 aop-beans_1_0.xsd"
              pointcut="execution(public void com.test.MyNetworkListener->responseReceived(..))">
              <aop:after aspect="TestAspect" name="updateSomething"/>
      </aop:bind>

       

      the MyNetworkListener.responseReceived method is called by a netty ChannelHandler (obviosly running inside a IO thread) so I'm guessing that MyNetworkListener is not being weived properly because is being called from a thread not managed by the jboss server/aop libs? or maybe is a classloading issue?

       

      Thanks for your help on this issue

       

      Regards,

        • 1. Re: calling aspect from netty thread inside jboss 5.1
          elgabo

          Hi,

           

          It's worth noting that when calling my bean methods from a MDB packaged inside basic.jar AOP works as expected, but the call starts from a IO thread AOP code fails to run.

           

          Regards

          • 2. Re: calling aspect from netty thread inside jboss 5.1
            kabirkhan

            Is the Thread.currentThread().getContextClassLoader() in MyNetworkListener what you would expect for your application?

             

            JBoss AOP doesn't really do anything fancy with classloaders unless your application uses isolated classloading, which I don't think is the case in your application.

             

            If you're using loadtime weaving, the -aop.xml stuff must be available before accessing the classes. For your basic.jar the deployers are smart enough to deploy the aop xml before the bean classes are loaded. Can you try getting rid of both jars, and then starting the server with basic.jar only. Once started deploy network.jar. If that helps, I'll dig out some resources on deployment ordering

            • 3. Re: calling aspect from netty thread inside jboss 5.1
              elgabo

              Hi Kabir,

              Kabir Khan escribió:

               

              Is the Thread.currentThread().getContextClassLoader() in MyNetworkListener what you would expect for your application?

               

               

              Thanks for your response.  First of all I don't know what context to expect. When the MDB calls the aspectized methods the thread context toString() method returns BaseClassLoader@1c6e768{vfszip:/home/gabriel/devel/tools/jboss-5.1.0.GA/server/default/deploy/base.jar/} it makes sense.  The thread context is BaseClassLoader@d2b042{vfszip:/home/gabriel/devel/tools/jboss-5.1.0.GA/server/default/deploy/network.jar/} when the message is received.

               

              JBoss AOP doesn't really do anything fancy with classloaders unless your application uses isolated classloading, which I don't think is the case in your application.

               

              If you're using loadtime weaving, the -aop.xml stuff must be available before accessing the classes. For your basic.jar the deployers are smart enough to deploy the aop xml before the bean classes are loaded. Can you try getting rid of both jars, and then starting the server with basic.jar only. Once started deploy network.jar. If that helps, I'll dig out some resources on deployment ordering

               

              I'm running my application inside JBoss 5.1, I'm not sure if it uses loadtime weaving by default.  Actually I'm running the server using Eclipse 3.5 so if it helps here are the VM's arguments:

               

              -Dprogram.name=run.bat -Xms128m -Xmx512m  -XX:MaxPermSize=256m

               

              The aop stuff is inside the network.jar/META-INF/jboss-beans.xml.  Can will putting it inside basic.jar/META-INF/jboss-beans.xml will help? I started the server with basic.jar and the deployed network.jar but the same happens.

               

              Thanks for your answers.