1 Reply Latest reply on Mar 30, 2004 10:55 AM by starksm64

    Inteceptor not being called

    andrewboyd

      Hi all,
      I have a class that extends ServiceMBean that has an Inteceptor
      that extends AbstractInceptor that never seems to get called.

      MBean Class:

      public interface ParsingAgentMBean extends org.jboss.system.ServiceMBean {
      
       com.digitalreasoning.kdas.Message parse(com.digitalreasoning.kdas.Message msg) ;
      



      jboss-service.xml:
       <mbean code="com.clarity.cpin.agent.ParsingAgent"
       name="drs.kafe:type=LocalAgent,name=ParsingAgent">
       <depends>drs.kafe:type=Host,name=Host</depends>
       <descriptors>
       <interceptors>
       <interceptor code="com.digitalreasoning.kdas.util.rtfConverter.RTFConverterInterceptor"/>
       </interceptors>
       <persistence persistPolicy="Never"/>
       <currencyTimeLimit value="10"/>
       <state-action-on-update value="keep-running"/>
       </descriptors>
      
       </mbean>
      
       <mbean code="com.clarity.cpin.agent.ParsingAgentTester"
       name="drs.kafe:type=LocalAgent,name=ParsingAgentTester">
       <depends>drs.kafe:type=LocalAgent,name=ParsingAgent</depends>
       </mbean>
      


      I'm calling it just for testing from the startService method in ParsingAgentTester.
      calling code:

       logger.debug("Starting Service");
       ObjectName parseAgentName = new ObjectName(ParsingAgent.OBJECT_NAME_STR);
       MessageFactory msgFac = MessageFactory.getMessageFactory(2, new String[]{"dummy1","dummy2"});
      
       Message msg = msgFac.createMessage(null,"This is a message");
       System.out.println("Is ParsingAgent registered? : "+mBeanServer.isRegistered(parseAgentName));
       logger.debug("Calling ParsingAgent.parse(msg) via MBeanServer");
       mBeanServer.invoke(parseAgentName,"parse", new Message[]{msg},
       new String[]{Message.class.getName()});
       super.startService();
      
      


      std out:
      15:58:37,785 DEBUG [ParsingAgentTester] Starting
      15:58:37,785 DEBUG [ParsingAgentTester] Starting Service
      15:58:38,035 INFO [STDOUT] Is ParsingAgent registered? : true
      15:58:38,035 DEBUG [ParsingAgentTester] Calling ParsingAgent.parse(msg) via MBeanServer

      ...snip... // print outs that show parse is working as it should

      15:58:38,045 ERROR [ParsingAgentTester] Starting failed
      RuntimeMBeanException: RuntimeException in MBean operation 'parse(com.digitalreasoning.kdas.Message)'
      Cause: java.lang.NullPointerException
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:299)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at com.clarity.cpin.agent.ParsingAgentTester.startService(ParsingAgentTester.java:47)
      at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
      at sun.reflect.GeneratedMethodAccessor29.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 $Proxy14.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:394)


      I've put print outs that is called from the constructors of the inteceptor:
      public class RTFConverterInterceptor extends AbstractInterceptor{
      
       private RTFParser converter;
      
       public RTFConverterInterceptor(){
       super();
       createConverter();
       }
      
       public RTFConverterInterceptor(String s){
       super(s);
       createConverter();
       }
      
       public RTFConverterInterceptor(MBeanInfo mBeanInfo, MBeanInvoker mBeanInvoker){
       super(mBeanInfo, mBeanInvoker);
       createConverter();
       }
      
       public Object invoke(Invocation invocation) throws InvocationException{
       String opName = invocation.getName();
       System.out.println("RTFConverterInterceptor opName : "+opName);
       // If this is not the invoke(Invocation) op just pass it along
       if(opName.equals("invoke") == false){
       return getNext().invoke(invocation);
       }
      
       Object[] args = invocation.getArgs();
       // Do our stuff here.
       //converter.reinitialize();
      
       return getNext().invoke(invocation);
       }
       private void createConverter(){
       System.out.println("Creating RTFConverter");
       converter = RTFParser.createParser(new InputStreamReader(System.in));
       }
      }
      


      The stack trace does not show any indication of the inteceptor and there
      is no output from it. I have a feeling the NPE probably hase something
      to do with the missing inteceptor.

      Any Suggestions?

      Thanks,

      Andrew

        • 1. Re: Inteceptor not being called
          starksm64

          Only xmbeans support interceptors, not standard mbeans. See the xmbeans such as JNDIView found in the 3.2.3 release which has:

           <mbean code="org.jboss.naming.JNDIView"
           name="jboss:service=JNDIView"
           xmbean-dd="resource:xmdesc/JNDIView-xmbean.xml">
           </mbean>