11 Replies Latest reply on Mar 2, 2004 10:14 AM by Adrian Brock

    How to plugin my interceptor into the interceptor chain ?

    dengyuan Newbie

      Hi,

      Is that possible to implement my own interceptor extends the JMSServerInterceptorSupport which behaves just like the TracingInterceptor ? If it's possible, how do I plug in or deploy it ?

      Thanx in advance, wenchia.

        • 1. Re: How to plugin my interceptor into the interceptor chain
          Adrian Brock Master

          jbossmq-service.xml

          Regards,
          Adrian

          • 2. Re: How to plugin my interceptor into the interceptor chain
            dengyuan Newbie

            Hi Adria,

            I did modify this file to chain my interceptor/replace the TracingInterceptor.

            I implemented a class org.a.b.MyInterceptor extends the JMSServerInterceptorSupport, I created a myinterceptor.jar and deployed inot server/default/deploy. I specified the service as 'org.a:service=MyInterceptor'. But, I cannot load/deploy proper. Could you kindly point me to right direction ?

            TIA, wenchia

            • 3. Re: How to plugin my interceptor into the interceptor chain
              Adrian Brock Master

              Why did you change the jmx name, can you not see the dependency just above?

              ALWAYS POST THE ERRORS NOT "IT DOES NOT WORK" (sigh!)

              Regards,
              Adrian

              • 4. Re: How to plugin my interceptor into the interceptor chain
                dengyuan Newbie

                Hope this will help me to explain the error:

                --- server/default/deploy/jms/jbossmq-service.xml

                 <mbean code="org.jboss.mq.server.jmx.Invoker" name="jboss.mq:service=Invoker">
                 <depends optional-attribute-name="NextInterceptor">org.a.b:service=MyInterceptor</depends>
                 </mbean>
                
                 <mbean code="org.jboss.mq.server.jmx.InterceptorLoader" name="org.a.b:service=MyInterceptor">
                 <attribute name="InterceptorClass">org.a.b.MyInterceptor</attribute>
                 <depends optional-attribute-name="NextInterceptor">jboss.mq:service=SecurityManager</depends>
                 </mbean>
                
                

                --- code org.a.b.MyInterceptor

                package org.a.b;

                public class MyInterceptor extends JMSServerInterceptorSupport {
                }

                --- error from jboss
                13:31:27,207 INFO [MainDeployer] Starting deployment of package: file:/C:/tools/jboss-3.2.3/server/default/deploy/jms/jbossmq-service.xml
                13:31:27,247 WARN [NestedThrowable] Duplicate throwable nesting of same base type: class org.jboss.deployment.DeploymentException is assignable from: class org.jboss.deployment.DeploymentException
                13:31:27,257 ERROR [MainDeployer] could not create deployment: file:/C:/tools/jboss-3.2.3/server/default/deploy/jms/jbossmq-service.xml
                org.jboss.deployment.DeploymentException: create operation failed for package file:/C:/tools/jboss-3.2.3/server/default/deploy/jms/jbossmq-service.xml; - nested throwable: (org.jboss.deployment.DeploymentException: missing domain; - nested throwable: (javax.management.MalformedObjectNameException: missing domain))
                at org.jboss.deployment.SARDeployer.create(SARDeployer.java:202)
                at org.jboss.deployment.MainDeployer.create(MainDeployer.java:786)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:641)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
                at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                at $Proxy6.deploy(Unknown Source)
                at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
                at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:476)
                at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:201)
                at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:274)
                at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
                at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
                at $Proxy0.start(Unknown Source)
                at org.jboss.system.ServiceController.start(ServiceController.java:394)
                at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                at $Proxy4.start(Unknown Source)
                at org.jboss.deployment.SARDeployer.start(SARDeployer.java:226)
                at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:589)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                at $Proxy5.deploy(Unknown Source)
                at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:384)
                at org.jboss.system.server.ServerImpl.start(ServerImpl.java:291)
                at org.jboss.Main.boot(Main.java:150)
                at org.jboss.Main$1.run(Main.java:395)
                at java.lang.Thread.run(Thread.java:534)
                Caused by: org.jboss.deployment.DeploymentException: missing domain; - nested throwable: (javax.management.MalformedObjectNameException: missing domain)
                at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:139)
                at org.jboss.system.ServiceController.install(ServiceController.java:225)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                at $Proxy4.install(Unknown Source)
                at org.jboss.deployment.SARDeployer.create(SARDeployer.java:183)
                ... 48 more
                Caused by: javax.management.MalformedObjectNameException: missing domain
                at javax.management.ObjectName.init(ObjectName.java:205)
                at javax.management.ObjectName.(ObjectName.java:87)
                at org.jboss.system.ServiceConfigurator.parseObjectName(ServiceConfigurator.java:627)
                at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigurator.java:147)
                at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:114)
                ... 58 more



                • 5. Re: How to plugin my interceptor into the interceptor chain
                  Adrian Brock Master

                  Post your real jbossmq-service.xml
                  The error says you have an invalid jmx ObjectName. See the jmx spec for more info.

                  Regards,
                  Adrian

                  • 6. Re: How to plugin my interceptor into the interceptor chain
                    dengyuan Newbie

                    jboss-3.2.3/server/default/deploy/jms/jbossmq-service.xml

                    <?xml version="1.0" encoding="UTF-8"?>
                    
                    <!-- $Id: jbossmq-service.xml,v 1.10.2.14 2003/08/27 07:44:42 ejort Exp $ -->
                    
                    <server>
                    
                     <!-- ==================================================================== -->
                     <!-- JBossMQ -->
                     <!-- ==================================================================== -->
                    
                    
                     <!-- ==================================================================== -->
                     <!-- JBossMQ Interceptor chain configuration -->
                     <!-- ==================================================================== -->
                     <!-- To tune performance, you can have the Invoker skip over the TracingInterceptor -->
                     <!-- and/or the SecurityManager, but then you loose the ability to trace and/or enforce security. -->
                     <!--
                     <mbean code="org.jboss.mq.server.jmx.Invoker" name="jboss.mq:service=Invoker">
                     <depends optional-attribute-name="NextInterceptor">jboss.mq:service=TracingInterceptor</depends>
                     </mbean>
                    
                     <mbean code="org.jboss.mq.server.jmx.InterceptorLoader" name="jboss.mq:service=TracingInterceptor">
                     <attribute name="InterceptorClass">org.jboss.mq.server.TracingInterceptor</attribute>
                     <depends optional-attribute-name="NextInterceptor">jboss.mq:service=SecurityManager</depends>
                     </mbean>
                     -->
                    
                     <mbean code="org.jboss.mq.server.jmx.Invoker" name="jboss.mq:service=Invoker">
                     <depends optional-attribute-name="NextInterceptor">user:service=MyInterceptor</depends>
                     </mbean>
                    
                     <mbean code="org.jboss.mq.server.jmx.InterceptorLoader" name="user:service=MyInterceptor">
                     <attribute name="InterceptorClass">a.b.c.MyInterceptor</attribute>
                     <depends optional-attribute-name="NextInterceptor">jboss.mq:service=SecurityManager</depends>
                     </mbean>
                    
                     <mbean code="org.jboss.mq.security.SecurityManager" name="jboss.mq:service=SecurityManager">
                     <attribute name="DefaultSecurityConfig">
                     <security>
                     <role name="guest" read="true" write="true" create="true"/>
                     </security>
                     </attribute>
                     <attribute name="SecurityDomain">jbossmq</attribute>
                     <depends optional-attribute-name="NextInterceptor">jboss.mq:service=DestinationManager</depends>
                     </mbean>
                    
                     <!--
                     | The ClientMonitorInterceptor disconnects clients that have been idle for to long.
                     | This interceptor is not enabled by default since the server might disconnect clients
                     | when the it is under high load.
                     -->
                     <!--
                     <mbean code="org.jboss.mq.server.jmx.ClientMonitorInterceptor" name="jboss.mq:service=ClientMonitorInterceptor">
                     <attribute name="ClientTimeout">80000</attribute>
                     <depends optional-attribute-name="NextInterceptor">jboss.mq:service=ClientReconnectInterceptor</depends>
                     </mbean>
                     -->
                    
                     <!--
                     | The ClientReconnectInterceptor is used to allow a client to connect to the server even
                     | if it's clientID is allready being used by another client. This interceptor will disconnect
                     | the previously connected client to allow the new connection to succeed. This is not enabled
                     | by default since the JMS spec states that the 2nd client connecting to the server with the same
                     | id should get an exception.
                     -->
                     <!--
                     <mbean code="org.jboss.mq.server.jmx.InterceptorLoader" name="jboss.mq:service=ClientReconnectInterceptor">
                     <attribute name="InterceptorClass">org.jboss.mq.server.ClientReconnectInterceptor</attribute>
                     <depends optional-attribute-name="NextInterceptor">jboss.mq:service=DestinationManager</depends>
                     </mbean>
                     -->
                    
                     <!-- ==================================================================== -->
                     <!-- The state manager -->
                     <!-- ==================================================================== -->
                    
                     <!--
                     | The StateManager is used to keep JMS persistent state data.
                     | For example: what durable subscriptions are active.
                     -->
                     <mbean code="org.jboss.mq.sm.file.DynamicStateManager"
                     name="jboss.mq:service=StateManager">
                     <!-- This file is pulled from the configuration URL of the server -->
                     <attribute name="StateFile">jbossmq-state.xml</attribute>
                     </mbean>
                    
                     <!-- ==================================================================== -->
                     <!-- System Destinations -->
                     <!-- ==================================================================== -->
                    
                     <!-- Dead Letter Queue -->
                     <mbean code="org.jboss.mq.server.jmx.Queue"
                     name="jboss.mq.destination:service=Queue,name=DLQ">
                     <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
                     <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
                     </mbean>
                    
                    </server>
                    


                    jboss-3.2.3/server/default/deploy/user-service.xml
                    <server>
                     <classpath codebase="." archives="myinterceptor.jar"/>
                     <mbean code="a.b.c.MyInterceptor" name="user:service=MyInterceptor">
                     <attribute name="MyAttribute">AttributeValue</attribute>
                     </mbean>
                    </server>
                    


                    MyInterceptor.java
                    package a.b.c;
                    
                    import javax.jms.JMSException;
                    
                    import org.jboss.mq.ConnectionToken;
                    import org.jboss.mq.SpyMessage;
                    import org.jboss.mq.server.JMSServerInterceptorSupport;
                    
                    public class MyInterceptor extends JMSServerInterceptorSupport {
                     public void addMessage(ConnectionToken dc, SpyMessage message) throws JMSException {
                     getNext().addMessage(dc, message);
                     return;
                     }
                     public SpyMessage receive(ConnectionToken dc, int subscriberId, long wait)
                     throws JMSException {
                     return getNext().receive(dc, subscriberId, wait);
                     }
                    }
                    



                    • 7. Re: How to plugin my interceptor into the interceptor chain
                      Adrian Brock Master

                      It looks ok to me, but why do you have user:service=MyInterceptor twice
                      in two different files?

                      Regards,
                      Adrian

                      • 8. Re: How to plugin my interceptor into the interceptor chain
                        dengyuan Newbie

                        I removed the user:service in user-service.xml, but it still cannot load the myinterceptor.jar which i deployed/placed into server/default/deploy sub-directory.

                        I don't think I specified properly how the myinterceptor.jar be loaded since the exception says 'No ClassLoader found for: a.b.c.MyInterceptor' when the MainDeployer deployed the jbossmq-service.xml.

                        09:28:07,258 INFO [MainDeployer] Starting deployment of package: file:/C:/tools/jboss-3.2.3/server/default/deploy/jms/jbossmq-service.xml
                        09:29:01,155 INFO [ServiceConfigurator] Problem configuring service user:service=MyInterceptor
                        org.jboss.deployment.DeploymentException: Exception setting attribute javax.management.Attribute: name=InterceptorClass value=a.b.c.MyInterceptor on mbean user:service=MyInterceptor; - nested throwable: (java.lang.ClassNotFoundException: No ClassLoaders found for: a.b.c.MyInterceptor)
                         at org.jboss.system.ServiceConfigurator.setAttribute(ServiceConfigurator.java:501)
                         at org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.java:328)
                         at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigurator.java:172)
                         at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:114)
                         at org.jboss.system.ServiceController.install(ServiceController.java:225)
                         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:324)
                         at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                         at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                         at $Proxy4.install(Unknown Source)
                         at org.jboss.deployment.SARDeployer.create(SARDeployer.java:183)
                         at org.jboss.deployment.MainDeployer.create(MainDeployer.java:786)
                         at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:641)
                         at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
                         at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:324)
                         at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                         at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                         at $Proxy6.deploy(Unknown Source)
                         at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
                         at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:476)
                         at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:201)
                         at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:274)
                         at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
                         at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:324)
                         at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                         at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
                         at $Proxy0.start(Unknown Source)
                         at org.jboss.system.ServiceController.start(ServiceController.java:394)
                         at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:324)
                         at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                         at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                         at $Proxy4.start(Unknown Source)
                         at org.jboss.deployment.SARDeployer.start(SARDeployer.java:226)
                         at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
                         at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
                         at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
                         at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:589)
                         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:324)
                         at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                         at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                         at $Proxy5.deploy(Unknown Source)
                         at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:384)
                         at org.jboss.system.server.ServerImpl.start(ServerImpl.java:291)
                         at org.jboss.Main.boot(Main.java:150)
                         at org.jboss.Main$1.run(Main.java:395)
                         at java.lang.Thread.run(Thread.java:534)
                        Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: a.b.c.MyInterceptor
                         at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:161)
                         at org.jboss.mx.loading.UnifiedClassLoader3.loadClassImpl(UnifiedClassLoader3.java:169)
                         at org.jboss.mx.loading.UnifiedClassLoader3.loadClass(UnifiedClassLoader3.java:123)
                         at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
                         at org.jboss.mq.server.jmx.InterceptorLoader.setInterceptorClass(InterceptorLoader.java:42)
                         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:324)
                         at org.jboss.mx.capability.ReflectedMBeanDispatcher.setAttribute(ReflectedMBeanDispatcher.java:186)
                         at org.jboss.mx.server.MBeanServerImpl.setAttribute(MBeanServerImpl.java:500)
                         at org.jboss.system.ServiceConfigurator.setAttribute(ServiceConfigurator.java:497)
                         ... 61 more
                        09:29:01,255 INFO [DynamicStateManager] Started jboss.mq:service=StateManager
                        


                        TIA, wenchia


                        • 9. Re: How to plugin my interceptor into the interceptor chain
                          Adrian Brock Master

                          Put it in server/default/lib or make your jar and jbossmq-service.xml into a sar.

                          Regards,
                          Adrian

                          • 10. Re: How to plugin my interceptor into the interceptor chain
                            dengyuan Newbie

                            I put it into server/default/lib and it works. Thanks for your help.

                            What do I need to do with your second suggestion, I got two questions. The first one is sar file needs META-INF/jboss-service.xml which I don't know how to specify it. The second question is where to put the jbossmq-service.xml and do I need to remove the the jbossmq-service.xml from server/default/deploy/jms ?

                            TIA, wenchia

                            • 11. Re: How to plugin my interceptor into the interceptor chain
                              Adrian Brock Master

                              Your second question answers the first.
                              The jbossmq-service.xml becomes the META-INF/jboss-service.xml

                              This thread is getting too long for such a simple question.

                              Regards,
                              Adrian