0 Replies Latest reply on Mar 26, 2008 3:31 AM by frankthetank

    Beanshell - MBean issues

    frankthetank

      I was just starting to realize the pure coolness of using Beanshell in JBoss when I stumbled over this issue.

      I am having some wierd issues with a Beanshell script that is accessing an MBean and trying to call the MBean's methods.

      I have written an MBean that works fine and is accessible from the jmx-console and the methods can be executed there.

      All methods I want to access are in the interface and I can actually list them in the Beanshell script using reflection.

      I just cannot call some of them.

      I presume it might be that Beanshell is interpretating get/set/is as my attempt to access one of it's Attributes.

      Any one have any ideas?

      import javax.management.*;
      import org.jboss.system.server.*;
      import com.me.ManagerMBean;
      import java.lang.reflect.Method;
      
      try
      {
       MBeanServer mbs = MBeanServerFactory.findMBeanServer(null).get(0);
      
       print ( "MBeanServer : " + mbs );
      
       if (mbs == null )
       {
       return;
       }
      
       ObjectName objectName = new ObjectName("com.me:service=Manager");
      
       ManagerMBean rdm = (ManagerMBean)(MBeanServerInvocationHandler.newProxyInstance(mbs, objectName, ManagerMBean.class, false));
       print ("ManagerMBean : " + rdm);
      
       try
       {
       print ("auto : " + rdm.isAutoupdate() );
      
       }catch ( Throwable t )
       {
       print (t.getCause());
       t.printStackTrace();
       }
      
      }
      catch (Exception e )
      {
       System.out.println("Exception @ Test.MyTask.run() : " + e);
      }
      




      08:21:48,326 INFO [STDOUT] MBeanServer : org.jboss.mx.server.MBeanServerImpl@a4e743[ defaultDomain='jboss' ]
      08:21:48,326 INFO [STDOUT] ManagerMBean : MBeanProxy(org.jboss.mx.server.MBeanServerImpl@a4e743[ defaultDomain='jboss' ][com.me:service=Manager])
      08:21:48,342 INFO [STDOUT] javax.management.AttributeNotFoundException: not found: Autoupdate
      08:21:48,358 ERROR [STDERR] java.lang.reflect.UndeclaredThrowableException
      08:21:48,358 ERROR [STDERR] at $Proxy282.isAutoupdate(Unknown Source)
      08:21:48,358 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      08:21:48,358 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      08:21:48,358 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      08:21:48,358 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
      08:21:48,358 ERROR [STDERR] at bsh.Reflect.invokeMethod(Unknown Source)
      08:21:48,358 ERROR [STDERR] at bsh.Reflect.invokeObjectMethod(Unknown Source)
      08:21:48,358 ERROR [STDERR] at bsh.Name.invokeMethod(Unknown Source)
      08:21:48,358 ERROR [STDERR] at bsh.BSHMethodInvocation.eval(Unknown Source)
      08:21:48,358 ERROR [STDERR] at bsh.BSHPrimaryExpression.eval(Unknown Source)
      08:21:48,358 ERROR [STDERR] at bsh.BSHPrimaryExpression.eval(Unknown Source)
      08:21:48,358 ERROR [STDERR] at bsh.BSHBinaryExpression.eval(Unknown Source)
      08:21:48,358 ERROR [STDERR] at bsh.BSHArguments.getArguments(Unknown Source)
      08:21:48,358 ERROR [STDERR] at bsh.BSHMethodInvocation.eval(Unknown Source)
      08:21:48,358 ERROR [STDERR] at bsh.BSHPrimaryExpression.eval(Unknown Source)
      08:21:48,358 ERROR [STDERR] at bsh.BSHPrimaryExpression.eval(Unknown Source)
      08:21:48,358 ERROR [STDERR] at bsh.BSHBlock.evalBlock(Unknown Source)
      08:21:48,358 ERROR [STDERR] at bsh.BSHBlock.eval(Unknown Source)
      08:21:48,358 ERROR [STDERR] at bsh.BSHBlock.eval(Unknown Source)
      08:21:48,374 ERROR [STDERR] at bsh.BSHTryStatement.eval(Unknown Source)
      08:21:48,374 ERROR [STDERR] at bsh.BSHBlock.evalBlock(Unknown Source)
      08:21:48,374 ERROR [STDERR] at bsh.BSHBlock.eval(Unknown Source)
      08:21:48,374 ERROR [STDERR] at bsh.BSHBlock.eval(Unknown Source)
      08:21:48,374 ERROR [STDERR] at bsh.BSHTryStatement.eval(Unknown Source)
      08:21:48,374 ERROR [STDERR] at bsh.Interpreter.eval(Unknown Source)
      08:21:48,374 ERROR [STDERR] at bsh.Interpreter.eval(Unknown Source)
      08:21:48,374 ERROR [STDERR] at org.jboss.varia.deployment.BeanShellScript.loadScript(BeanShellScript.java:369)
      08:21:48,374 ERROR [STDERR] at org.jboss.varia.deployment.BeanShellScript.<init>(BeanShellScript.java:109)
      08:21:48,374 ERROR [STDERR] at org.jboss.varia.deployment.BeanShellSubDeployer.create(BeanShellSubDeployer.java:153)
      08:21:48,374 ERROR [STDERR] at org.jboss.deployment.MainDeployer.create(MainDeployer.java:969)
      08:21:48,374 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:818)
      08:21:48,374 ERROR [STDERR] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
      08:21:48,374 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
      08:21:48,374 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      08:21:48,374 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
      08:21:48,374 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      08:21:48,374 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      08:21:48,374 ERROR [STDERR] at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
      08:21:48,374 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
      08:21:48,374 ERROR [STDERR] at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
      08:21:48,374 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
      08:21:48,374 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      08:21:48,374 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      08:21:48,374 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
      08:21:48,374 ERROR [STDERR] at $Proxy9.deploy(Unknown Source)
      08:21:48,374 ERROR [STDERR] at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
      08:21:48,374 ERROR [STDERR] at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
      08:21:48,374 ERROR [STDERR] at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
      08:21:48,374 ERROR [STDERR] at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
      08:21:48,374 ERROR [STDERR] at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
      08:21:48,374 ERROR [STDERR] Caused by: javax.management.AttributeNotFoundException: not found: Autoupdate
      08:21:48,374 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.getAttribute(AbstractMBeanInvoker.java:335)
      08:21:48,374 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.getAttribute(MBeanServerImpl.java:556)
      08:21:48,374 ERROR [STDERR] at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:272)
      08:21:48,374 ERROR [STDERR] ... 50 more