Announcement Announcement Module
Collapse
No announcement yet.
ReflectionException: target not found Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ReflectionException: target not found

    Hi Guys,

    I'm trying to expose the MBeans of jmx in my web application. So far I was able to invoke the method that do not require attributes. But when I try to call setter methods I'm encountering exception.

    javax.management.ReflectionException: Target method not found:
    Any solution with this?

    Thanks

  • #2
    ReflectionException: Target Method Not Found

    In order to provide assistance or ideas, it would be helpful if you provided more details.

    For example ...
    • Are you using Spring's metadata configuration to expose the getter/setter methods for your attributes?
    • What is the name of the attibute and your corresponding getter and setter (do they follow JavaBean conventions)?
    • What is the signature of your setter (does it return void and only accept a single parameter of the same datatype as the attribute)?
    • Code snippets (Java and Spring XML or other configuration) would be most helpful and would answer some of the above questions.

    Comment


    • #3
      Here's the client code


      To connect, I'm using this method.
      Code:
      public boolean connect(){
          	//MBeanExporter mbe = new MBeanExporter();
              try {            
              	MseJmxClient listener = new MseJmxClient();
              	
                  String address = "service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/" + name;
                  JMXServiceURL serviceURL = new JMXServiceURL(address);
                  Map environment = null;
                  JMXConnector connector = JMXConnectorFactory.connect(serviceURL, environment);
                  mBeanConnection = connector.getMBeanServerConnection();
      
                  incomingMseAdaptorEngineName = ObjectName.getInstance("MSE:type=mseIncomingMDBEngineMonitored");            
                  outgoingMseAdaptorEngineName = ObjectName.getInstance("MSE:type=mseOutgoingMDBEngineMonitored");
                  smscMseAdaptorEngineName = ObjectName.getInstance("MSE:type=mseSmscAdaptorEngineMonitored");
                  incomingSmscEngineName= ObjectName.getInstance("MSE:type=mseSmscEngineMonitored");
                  outgoingSmscEngineName = ObjectName.getInstance("MSE:type=mseNotificationMDBEngineMonitored");
                  
                  mBeanConnection.addNotificationListener(incomingMseAdaptorEngineName, listener, null, null);
                  mBeanConnection.addNotificationListener(outgoingMseAdaptorEngineName, listener, null, null);
                  mBeanConnection.addNotificationListener(smscMseAdaptorEngineName, listener, null, null);
                  mBeanConnection.addNotificationListener(incomingSmscEngineName, listener, null, null);
                  mBeanConnection.addNotificationListener(outgoingSmscEngineName, listener, null, null);
                  
                  connected = true;
                  
              } catch (Exception e){
                  e.printStackTrace();
                  this.close();
                  connected = false;
                  return false;
              }
              
              return true;
          }
      Invoking below's method is basically ok.
      Code:
      public String updateIncomingMseLogins() throws Exception {
              if (connected) 
                  return (String) mBeanConnection.invoke(incomingMseAdaptorEngineName, "updateReactors", null, null);
              else
                  return null;
          }
      But invoking this next method, I'm getting the exception.

      Code:
       public String restartIncomingMseLogins(int port) throws Exception {
              if (connected)
                  return (String) mBeanConnection.invoke(incomingMseAdaptorEngineName, "restartReactor", new Object[]{port}, null);
              else
              	return null;
          }

      Here's the updateReactors method under my code
      Code:
      @ManagedOperation(description="Update Reactors")
          public String updateReactors(){
              
              String reactorStatus = "";
              
              if (log.isDebugEnabled()){
                  log.debug("[updateReactors]: START");
                  reactorStatus = reactorStatus.concat("begin\n");
              }
      
              ....

      and the restartReactor method
      Code:
      @ManagedOperation(description="Restart Reactor")
          @ManagedOperationParameters({
              @ManagedOperationParameter(name = "port", description = "mse port")}) 
          public String restartReactor(int port){
          	String ret="";
              try {
                  log.info("Restarting reactor with port :" + port + "....");
                  MseReactor reactor = getReactor(port);
                  if (null==reactor) {
                      log.info("no reset done. port not defined in any reactor.");
                      ret = "Port not defined in any reactor";
                      return ret;
                  }
                 ....

      Comment


      • #4
        Signature (String[]) is Missing from MBeanServerConnection.invoke Call

        It looks like the issue is that you're passing a parameter to your restartReactor method, but you are not providing the MBeanServerConnection.invoke method with the required signature. Your other method, updateReactors, does not expect any arguments and so you properly don't pass an argument or provide a signature for "invoking" that method. However, for the method restartReactor that does expect a parameter, you need to provide the String array signature to go along with your passed-in parameter. This signature String array specifies the data types of the parameters you are passing in.

        Because you are only passing a single parameter, port, your signature will also have only one element. You need to pass a single-element String array in as your fourth parameter to the invoke method. That single parameter should be "int", though it is probably preferable pass in Integer.TYPE.toString() as the single String rather than hard-coding "int."

        If you replace your null as the fourth parameter to the invoke method with a single-element String array that accurately describes the type of parameter you passed in with the single-element Object array as the third parameter, this should work for you.

        Comment


        • #5
          Thanks spring_dm!!!

          Works very fine!!!

          Problem solved

          Comment

          Working...
          X