javax.management.InstanceAlreadyExistsException: org.quickfixj:type=Connector,role=Initiator

QuickFIX/J JIRA | Thomas Hügel | 10 years ago
  1. 0

    QuickFIX/J Jira

    quickfixj.org | 3 months ago
    javax.management.InstanceAlreadyExistsException: org.quickfixj:type=Connector,role=Initiator
  2. 0

    Hello, the current implementation of ConnectorJMXExporter.java does only work if you dont use a second connector. The name "type=Connector,role=Initiator" is to generic because the second connector has allways the same name, the error would look like the following: 22.05.2007 17:49:24 org.quickfixj.jmx.mbean.connector.ConnectorJmxExporter export SCHWERWIEGEND: Failed to export connector MBean javax.management.InstanceAlreadyExistsException: org.quickfixj:type=Connector,role=Initiator at com.sun.jmx.mbeanserver.RepositorySupport.addMBean(RepositorySupport.java:452) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(DefaultMBeanServerInterceptor.java:1410) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:936) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:337) at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:497) at org.quickfixj.jmx.mbean.connector.ConnectorJmxExporter.export(ConnectorJmxExporter.java:56) at org.quickfixj.jmx.JmxExporter.export(JmxExporter.java:60) My approach was to add the name of the configFile in the JMXExporter.export() function, this is probably to simple in case that the configfiles are not in the same directory. Must be a better way. **** public void export(MBeanServer mbeanServer, SessionConnector connector, String configFileName) { try { ConnectorAdmin connectorAdmin; if (connector instanceof AbstractSocketAcceptor) { connectorAdmin = new SocketAcceptorAdmin((AbstractSocketAcceptor) connector, sessionExporter); } else if (connector instanceof AbstractSocketInitiator) { connectorAdmin = new SocketInitiatorAdmin((AbstractSocketInitiator) connector, sessionExporter); } else { throw new QFJException("Unknown connector type: " + connector.getClass().getName()); } //changed: ObjectName connectorName = getConnectorName(connector); ObjectName connectorName = getConnectorName(connector, configFileName); mbeanServer.registerMBean(connectorAdmin, connectorName); ArrayList sessionIDs = connector.getSessions(); for (int i = 0; i < sessionIDs.size(); i++) { SessionID sessionID = (SessionID) sessionIDs.get(i); sessionExporter.export(mbeanServer, Session.lookupSession(sessionID), connectorName, connector.getSettings()); } } catch (Exception e) { log.error("Failed to export connector MBean", e); } } //private ObjectName getConnectorName(SessionConnector connector) private ObjectName getConnectorName(SessionConnector connector, String configFileName) throws MalformedObjectNameException { ObjectNameFactory nameFactory = new ObjectNameFactory(); nameFactory.addProperty("type", "Connector"); nameFactory.addProperty("role", connector instanceof Acceptor ? "Acceptor" : "Initiator"); //changed nameFactory.addProperty("configFileName", configFileName); return nameFactory.createName(); } *** The jmx export im my code looks like jmxExporter = new JmxExporter(ManagementFactory.getPlatformMBeanServer()); jmxExporter.export(acceptor, this.getConfigFile()); instead of jmxExporter = new JmxExporter(ManagementFactory.getPlatformMBeanServer()); jmxExporter.export(acceptor); I checked with jconsole, works. Regards Thomas Hügel

    QuickFIX/J JIRA | 10 years ago | Thomas Hügel
    javax.management.InstanceAlreadyExistsException: org.quickfixj:type=Connector,role=Initiator
  3. 0

    Hello, the current implementation of ConnectorJMXExporter.java does only work if you dont use a second connector. The name "type=Connector,role=Initiator" is to generic because the second connector has allways the same name, the error would look like the following: 22.05.2007 17:49:24 org.quickfixj.jmx.mbean.connector.ConnectorJmxExporter export SCHWERWIEGEND: Failed to export connector MBean javax.management.InstanceAlreadyExistsException: org.quickfixj:type=Connector,role=Initiator at com.sun.jmx.mbeanserver.RepositorySupport.addMBean(RepositorySupport.java:452) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(DefaultMBeanServerInterceptor.java:1410) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:936) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:337) at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:497) at org.quickfixj.jmx.mbean.connector.ConnectorJmxExporter.export(ConnectorJmxExporter.java:56) at org.quickfixj.jmx.JmxExporter.export(JmxExporter.java:60) My approach was to add the name of the configFile in the JMXExporter.export() function, this is probably to simple in case that the configfiles are not in the same directory. Must be a better way. **** public void export(MBeanServer mbeanServer, SessionConnector connector, String configFileName) { try { ConnectorAdmin connectorAdmin; if (connector instanceof AbstractSocketAcceptor) { connectorAdmin = new SocketAcceptorAdmin((AbstractSocketAcceptor) connector, sessionExporter); } else if (connector instanceof AbstractSocketInitiator) { connectorAdmin = new SocketInitiatorAdmin((AbstractSocketInitiator) connector, sessionExporter); } else { throw new QFJException("Unknown connector type: " + connector.getClass().getName()); } //changed: ObjectName connectorName = getConnectorName(connector); ObjectName connectorName = getConnectorName(connector, configFileName); mbeanServer.registerMBean(connectorAdmin, connectorName); ArrayList sessionIDs = connector.getSessions(); for (int i = 0; i < sessionIDs.size(); i++) { SessionID sessionID = (SessionID) sessionIDs.get(i); sessionExporter.export(mbeanServer, Session.lookupSession(sessionID), connectorName, connector.getSettings()); } } catch (Exception e) { log.error("Failed to export connector MBean", e); } } //private ObjectName getConnectorName(SessionConnector connector) private ObjectName getConnectorName(SessionConnector connector, String configFileName) throws MalformedObjectNameException { ObjectNameFactory nameFactory = new ObjectNameFactory(); nameFactory.addProperty("type", "Connector"); nameFactory.addProperty("role", connector instanceof Acceptor ? "Acceptor" : "Initiator"); //changed nameFactory.addProperty("configFileName", configFileName); return nameFactory.createName(); } *** The jmx export im my code looks like jmxExporter = new JmxExporter(ManagementFactory.getPlatformMBeanServer()); jmxExporter.export(acceptor, this.getConfigFile()); instead of jmxExporter = new JmxExporter(ManagementFactory.getPlatformMBeanServer()); jmxExporter.export(acceptor); I checked with jconsole, works. Regards Thomas Hügel

    QuickFIX/J JIRA | 10 years ago | Thomas Hügel
    javax.management.InstanceAlreadyExistsException: org.quickfixj:type=Connector,role=Initiator
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    See http://sourceforge.net/mailarchive/forum.php?thread_name=ce06b7320901101754l6050baf0j888ae610bdd7bf04%40mail.gmail.com&forum_name=quickfixj-users I am using the JmxExporter class to expose QFJ to JMX. If I attempt to shutdown and restart my QFJ instance (my stopping then restarting my Initiator within the same process) then I get the following exception because QFJ tries to export to JMX again. ... ... ERROR org.quickfixj.jmx.mbean.connector.ConnectorJmxExporter - Failed to export connector MBean javax.management.InstanceAlreadyExistsException: org.quickfixj:type=Session,beginString=FIX.4.2,xxxxxxxx at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:453) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(DefaultMBeanServerInterceptor.java:1484) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:963) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:917) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:312) at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:482) at org.quickfixj.jmx.mbean.session.SessionJmxExporter.export(SessionJmxExporter.java:28) at org.quickfixj.jmx.mbean.connector.ConnectorJmxExporter.export(ConnectorJmxExporter.java:66) at org.quickfixj.jmx.mbean.connector.ConnectorJmxExporter.export(ConnectorJmxExporter.java:46) at org.quickfixj.jmx.JmxExporter.export(JmxExporter.java:60) Spring has a solution to this kind of thing with MBeanRegistrationSupport.setRegistrationBehaviorName<http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/jmx/support/MBeanRegistrationSupport.html#setRegistrationBehaviorName%28java.lang.String%29>.

    QuickFIX/J JIRA | 8 years ago | Jerry Shea
    javax.management.InstanceAlreadyExistsException: org.quickfixj:type=Session,beginString=FIX.4.2,xxxxxxxx

  1. batwalrus76 60 times, last 6 days ago
  2. Handemelindo 1 times, last 3 weeks ago
  3. kjhdofjosvs 3 times, last 7 days ago
  4. tvrmsmith 2 times, last 1 month ago
  5. davidvanlaatum 54 times, last 2 months ago
3 more registered users
21 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. javax.management.InstanceAlreadyExistsException

    org.quickfixj:type=Connector,role=Initiator

    at com.sun.jmx.mbeanserver.RepositorySupport.addMBean()
  2. Java RT
    JmxMBeanServer.registerMBean
    1. com.sun.jmx.mbeanserver.RepositorySupport.addMBean(RepositorySupport.java:452)
    2. com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(DefaultMBeanServerInterceptor.java:1410)
    3. com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:936)
    4. com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:337)
    5. com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:497)
    5 frames
  3. Apache ServiceMix :: Bundles :: ${pkgArtifactId}
    JmxExporter.export
    1. org.quickfixj.jmx.mbean.connector.ConnectorJmxExporter.export(ConnectorJmxExporter.java:56)
    2. org.quickfixj.jmx.JmxExporter.export(JmxExporter.java:60)
    2 frames