{"record":{"id":"7da0c6e9689576e2","repo":"apache/beam","slug":"unable-to-instantiate-jms-connectionfactory-of-class","errorCode":null,"errorMessage":"Unable to instantiate JMS ConnectionFactory of class ${className}. Must be a supported provider (ActiveMQ, Qpid, IBM MQ) or implement BeamGenericJmsConnectionFactory.","messagePattern":"Unable to instantiate JMS ConnectionFactory of class (.+?)\\. Must be a supported provider \\(ActiveMQ, Qpid, IBM MQ\\) or implement BeamGenericJmsConnectionFactory\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/jms/src/main/java/org/apache/beam/sdk/io/jms/ConnectionConfiguration.java","lineNumber":136,"sourceCode":"          e);\n    }\n    if (BeamGenericJmsConnectionFactory.class.isAssignableFrom(clazz)) {\n      factoryClass = (Class<? extends BeamGenericJmsConnectionFactory>) clazz;\n    } else if (className.contains(\"org.apache.activemq.ActiveMQConnectionFactory\")\n        || className.contains(\"org.apache.qpid.jms\")) {\n      // Connectors supported by StandardJmsConnectionFactory\n      factoryClass = StandardJmsConnectionFactory.class;\n    } else if (className.contains(\"com.ibm.mq\")) {\n      factoryClass = IbmMqJmsConnectionFactory.class;\n    } else {\n      // Attempt to use StandardJmsConnectionFactory.class;\n      factoryClass = StandardJmsConnectionFactory.class;\n    }\n    try {\n      BeamGenericJmsConnectionFactory factory = factoryClass.getDeclaredConstructor().newInstance();\n      return factory.createConnectionFactory(this);\n    } catch (Exception e) {\n      throw new IllegalArgumentException(\n          \"Unable to instantiate JMS ConnectionFactory of class \"\n              + className\n              + \". Must be a supported provider (ActiveMQ, Qpid, IBM MQ) or implement BeamGenericJmsConnectionFactory.\",\n          e);\n    }\n  }\n\n  /**\n   * A {@link BeamGenericJmsConnectionFactory} implementation for standard JMS connection factories.\n   */\n  public static class StandardJmsConnectionFactory implements BeamGenericJmsConnectionFactory {\n\n    @Override\n    public ConnectionFactory createConnectionFactory(ConnectionConfiguration config)\n        throws Exception {\n      String className = config.getConnectionFactoryClassName();\n      if (className == null || className.isEmpty()) {\n        className = \"org.apache.activemq.ActiveMQConnectionFactory\";","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/jms/src/main/java/org/apache/beam/sdk/io/jms/ConnectionConfiguration.java#L118-L154","documentation":"Thrown from ConnectionConfiguration.createConnectionFactory() when the class named by className loads but cannot be instantiated or fails to create the underlying ConnectionFactory. Beam requires either a known supported provider (ActiveMQ, Qpid, IBM MQ, via StandardJmsConnectionFactory) or a class implementing BeamGenericJmsConnectionFactory; anything else, or a constructor/session failure, results in this wrapped IllegalArgumentException.","triggerScenarios":"className resolves to a class that is not a supported provider and does not implement BeamGenericJmsConnectionFactory; or newInstance()/createConnectionFactory(this) throws (no-arg constructor missing, constructor throws, broker connection setup fails) inside the try block.","commonSituations":"Pointing className at the raw vendor ConnectionFactory (e.g. org.apache.activemq.ActiveMQConnectionFactory directly) instead of the Beam standard factory; client library version mismatch causing factory init to fail; broker rejecting the connection during factory creation.","solutions":["Use a class that implements BeamGenericJmsConnectionFactory (e.g. StandardJmsConnectionFactory / provider-specific Beam factories shipped with Beam)","If wrapping a vendor factory, implement BeamGenericJmsConnectionFactory with a public no-arg constructor and delegate createConnectionFactory(config) to the vendor factory","Check the cause exception for the real failure (constructor error, broker connectivity, auth) and fix that underlying issue","Align the JMS client library version with the one Beam was compiled against"],"exampleFix":"// before\nConnectionConfiguration.create(uri, user, pass, \"org.apache.activemq.ActiveMQConnectionFactory\")\n// after\nConnectionConfiguration.create(uri, user, pass, \"org.apache.beam.sdk.io.jms.StandardJmsConnectionFactory\")","handlingStrategy":"validation","validationCode":"Class<?> c = Class.forName(className);\nif (!BeamGenericJmsConnectionFactory.class.isAssignableFrom(c) && !isKnownProvider(c)) {\n  throw new IllegalArgumentException(className + \" must implement BeamGenericJmsConnectionFactory or be a supported provider\");\n}\ntry {\n  c.getDeclaredConstructor().newInstance();\n} catch (Exception e) {\n  throw new IllegalStateException(\"Factory class lacks usable no-arg constructor: \" + className);\n}","typeGuard":null,"tryCatchPattern":"try {\n  pipeline.apply(JmsIO.read().withConnectionConfiguration(cfg));\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Unable to instantiate JMS ConnectionFactory\")) {\n    // inspect e.getCause() for the real constructor/session failure\n  } else throw e;\n}","preventionTips":["Use Beam's StandardJmsConnectionFactory (or provider-specific Beam factories) instead of raw vendor classes","Implement BeamGenericJmsConnectionFactory with a public no-arg constructor for custom brokers","Keep JMS client versions aligned with Beam's dependency versions"],"tags":["jms","reflection","instantiation","beam"],"backgroundTag":"class-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}