4 Replies Latest reply on Feb 15, 2002 5:31 AM by Adrian Brock

    Integrates a JMX remote connection to resource adaptor

    roysun Newbie

      Hi there.
      I use a client program with a connection to call a JMX agent remotely, it works fine.
      And then I integrate the connection to a resource adaptor I got Error thrown from MBeanServer during invoke "startService()" method of ConnectorFactoryService. The more strange things I could not see the print out message in "start()" method of ServiceMBeanSupport which is parent of ConnectorFactoryService.

      "startService()" is called through the message printed out I can prove that. But this method instantiats a ConnectorFactoryImpl. I could not see the constructor of ConnectorFactoryImpl was called.

      I am not able to understand. Could you please help?

      Roy

        • 1. Re: Integrates a JMX remote connection to resource adaptor
          Adrian Brock Master

          Perhaps you can show the code segment for startService().
          And show the error you get?
          If this is configured as a jboss service, maybe you
          can post the jboss-service.xml or jboss.jcml?

          You could also try wrapping startService with
          an exception handler, e.g.

          [pre]
          public void startService()
          throws Exception
          {
          try
          {
          // Your code
          }
          catch (Exception e)
          {
          log.error("Unexpected error", e);
          throw e;
          }
          }
          [/pre]

          It is hard to help when you just report it doesn't work. :-)

          Regards,
          Adrian

          • 2. Re: Integrates a JMX remote connection to resource adaptor
            roysun Newbie

            try
            {
            lLocalServer.invoke(
            lFactoryInstance.getObjectName(),
            "start",
            new Object[] {},
            new String[] {}
            );
            }
            catch(Exception e)
            {
            log.error("HiveAgentConnection::unexpect exception==",e);
            }

            I got exception like the following. I still can not explain this.

            [15:24:49,360,HiveAgentConnection] HiveAgentConnection::unexpect exception==
            javax.management.RuntimeErrorException: Error thrown in operation start

            • 3. Re: Integrates a JMX remote connection to resource adaptor
              roysun Newbie

              I implemented createManagedConnection() method of ManagedConnectionFactoryImpl like:

              public ManagedConnection createManagedConnection(javax.security.auth.Subject subject, ConnectionRequestInfo info)
              throws ResourceException
              {
              System.out.println("ManagedConnectionFactoryImpl::createManagedConnection ");
              HiveAgentConnection conn = null;
              try
              {
              conn = new HiveAgentConnection();
              }
              catch(HiveConnectException e)
              {
              throw new ResourceException("Hive connecting failed: " + e);
              }

              return new ManagedConnectionImpl(subject, info, conn);
              }

              The construction calls createRemoteMBeanServer() which is like:

              private RemoteMBeanServer createRemoteMBeanServer() throws HiveConnectException
              {
              RemoteMBeanServer lConnector = null;

              System.out.println("HiveAgnetConnection==createRemoteMBeanServer");
              try
              {
              // create a MBeanServer and let it start
              final MBeanServer lLocalServer = MBeanServerFactory.createMBeanServer();
              System.out.println("HiveAgnetConnection==createRemoteMBeanServer==createMBeanServer() successed");

              // register the connector factory
              final ObjectInstance lFactoryInstance = lLocalServer.createMBean(
              "org.jboss.jmx.connector.ConnectorFactoryService",
              new ObjectName( lLocalServer.getDefaultDomain(), "name", "ConnectorFactory" )
              );

              System.out.println("HiveAgnetConnection==createRemoteMBeanServer==setAttribute");

              /** set up notification type to rmi */
              int lType = RemoteMBeanServer.NOTIFICATION_TYPE_RMI;

              lLocalServer.setAttribute(
              lFactoryInstance.getObjectName(),
              new Attribute( "NotificationType", new Integer( lType ) )
              );

              System.out.println("HiveAgnetConnection==createRemoteMBeanServer==invoke start");
              System.out.println("HiveAgentConnection==createRemoteMBeanServer==getObjectName: "+ lFactoryInstance.getObjectName());
              try
              {
              lLocalServer.invoke(
              lFactoryInstance.getObjectName(),
              "start",
              new Object[] {},
              new String[] {}
              );
              }
              catch(Exception e)
              {
              log.error("HiveAgentConnection::unexpect exception==",e);
              }
              ......
              }


              • 4. Re: Integrates a JMX remote connection to resource adaptor
                Adrian Brock Master

                Change the exception handling to the following,

                [pre]
                try
                {
                lLocalServer.invoke(
                lFactoryInstance.getObjectName(),
                "start",
                new Object[] {},
                new String[] {}
                );
                }
                catch(RuntimeErrorException e)
                {
                log.error("HiveAgentConnection::runtime error==",e.getTargetError());
                }
                catch(Exception e)
                {
                log.error("HiveAgentConnection::unexpect exception==",e);
                }
                [/pre]

                Regards,
                Adrian