javax.management.InstanceAlreadyExistsException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • 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>.
    via by Jerry Shea,
  • QuickFIX/J Jira
    via by Unknown author,
  • 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
    via by Thomas Hügel,
  • 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
    via by Thomas Hügel,
    • 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)

    Users with the same issue

    batwalrus76batwalrus76
    1247 times, last one,
    HandemelindoHandemelindo
    3 times, last one,
    kjhdofjosvskjhdofjosvs
    3 times, last one,
    tvrmsmithtvrmsmith
    2 times, last one,
    davidvanlaatumdavidvanlaatum
    54 times, last one,
    24 more bugmates