1 Reply Latest reply on Feb 17, 2009 11:05 AM by danezu

    MBeanServerConnection & JRMPInvokerProxy problem

    danezu

      Hi guys

      I'm new on this forum and i need you help pretty much

      I use JMX to connect to a JBoss 4.2.2 GA with JBossMQ as messaging system.
      I try to connect to the 'jmx/rmi/RMIAdaptor' using MBeanServerConnection, something like this:

      Properties props = new Properties();
      props.put(Context.PROVIDER_URL, "jnp://myurl:1099");
      props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");

      Context ctx = new InitialContext(props);
      MBeanServerConnection srvConn = (MBeanServerConnection)ctx.lookup("jmx/rmi/RMIAdaptor");
      ObjectName oName = new ObjectName("jboss.mq.destination:name=testQueue,service=Queue");
      Object attrValue = srvConn.getAttribute(oName, "QueueDepth");

      It works perfectly when i run this as simple Java class, but when i try to launch it from some OSGi bundle, i get this error:

      java.lang.ClassCastException: $Proxy13 cannot be cast to javax.management.MBeanServerConnection

      where $Proxy13 proves to be an org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy instance.

      I don't understand why in the first situation it works, and in the second doesn't

      Can you please help me?

      Thanx & regards