0 Replies Latest reply on Sep 7, 2006 11:28 AM by yair.zaslavsky

    A question about injection vs. lookup of JMX service

    yair.zaslavsky

      Hi all,
      I have a pojo that tries to invoke a method on a service (i lookup the service and then perform the invocation).

      I get the following exception:
      14:31:00,125 INFO [STDOUT] Getting job

      14:31:00,391 ERROR [AMSAddContentRequest] Error during adding content

      java.lang.RuntimeException: Could not find type for operation 'add' on com.imag

      ine.ams.logic.content_priority_manager.ContentPriorityManagerMBean

      at org.jboss.ejb3.service.ServiceMBeanDelegate.getOperation(ServiceMBean

      Delegate.java:374)

      at org.jboss.ejb3.service.ServiceMBeanDelegate.invoke(ServiceMBeanDelega

      te.java:165)

      at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:1

      64)

      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

      java:39)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

      sorImpl.java:25)

      at java.lang.reflect.Method.invoke(Method.java:585)

      at org.jboss.jmx.connector.invoker.InvokerAdaptorService.invoke(InvokerA

      daptorService.java:266)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

      java:39)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

      sorImpl.java:25)


      However, this pojo is used from inside a session bean. When I perform dependency injection inside the bean, and pass the injected service as parameter to the pojo, the method gets activated.
      I have no ClassCastException or NullPointerException in the lookup, here is the lookup code:

      String providerURL = AMSConfigurationProxy.getAMSConfiguration().getHost() + ":1099";
      Hashtable props = new Hashtable();
      props.put(InitialContext.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      props.put(InitialContext.PROVIDER_URL,providerURL);

      InitialContext ctx = new InitialContext(props);
      MBeanServerConnection mbsc = (MBeanServerConnection)ctx.lookup("jmx/invoker/RMIAdaptor");
      ObjectName objName = new ObjectName("ams:service=contentPriorityManager");

      manager = (ContentPriorityManager)MBeanServerInvocationHandler.newProxyInstance(mbsc,
      objName,ContentPriorityManager.class,false);


      Can you please help me understand why i cannot activate the method "add" after the lookup?
      (I'm using jboss 4.0.4GA)

      Thanks

      Yair Zaslavsky