{"record":{"id":"678b0c240ee08728","repo":"apache/beam","slug":"error-connecting-to-jms","errorCode":null,"errorMessage":"Error connecting to JMS","messagePattern":"Error connecting to JMS","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/jms/src/main/java/org/apache/beam/sdk/io/jms/JmsIO.java","lineNumber":783,"sourceCode":"      Read<T> spec = source.spec;\n      ConnectionFactory connectionFactory = spec.getConnectionFactory();\n      try {\n        Connection connection;\n        if (spec.getUsername() != null) {\n          connection = connectionFactory.createConnection(spec.getUsername(), spec.getPassword());\n        } else {\n          connection = connectionFactory.createConnection();\n        }\n        connection.start();\n        this.connection = connection;\n        if (spec.getAutoScaler() == null) {\n          this.autoScaler = new DefaultAutoscaler();\n        } else {\n          this.autoScaler = spec.getAutoScaler();\n        }\n        this.autoScaler.start();\n      } catch (Exception e) {\n        throw new IOException(\"Error connecting to JMS\", e);\n      }\n\n      recreateSession();\n\n      return advance();\n    }\n\n    @Override\n    public boolean advance() throws IOException {\n      try {\n        Message message;\n        synchronized (this) {\n          if (receiveTimeoutMillis == 0L) {\n            message = this.consumer.receiveNoWait();\n          } else {\n            message = this.consumer.receive(receiveTimeoutMillis);\n          }\n          // put add in synchronized to make sure all messages in preparer are in same session","sourceCodeStart":765,"sourceCodeEnd":801,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/jms/src/main/java/org/apache/beam/sdk/io/jms/JmsIO.java#L765-L801","documentation":"UnboundedJmsReader.start() wraps all connection/session/autoscaler setup in a try block; any Exception from creating the JMS Connection or starting the autoScaler is rethrown as an IOException with the message \"Error connecting to JMS\". The original exception is chained as the cause, so inspecting it reveals the real problem (bad broker URL, auth failure, network unreachable, etc.).","triggerScenarios":"Calling start() on the JMS unbounded source when connectionFactory.createConnection() or connection.start() fails: wrong broker URL, broker down, credentials rejected, SSL handshake failure, or autoScaler.start() throwing.","commonSituations":"Broker unreachable from the runner workers (firewall/VPC), expired username/password, TLS truststore misconfiguration, DNS resolution failure.","solutions":["Read the chained cause exception to identify the root failure (ConnectionRefused, JMSSecurityException, etc.).","Verify withUsername/withPassword credentials and the broker URL on each runner worker.","Confirm network connectivity from worker machines to the broker (telnet/host check, firewall rules).","For TLS, validate keystore/truststore configuration on the workers."],"exampleFix":"// before\nJmsIO.<JmsRecord>read().withConnectionFactory(cf).withQueue(\"queue\").withUsername(\"user\").withPassword(\"wrong\")\n// after\nJmsIO.<JmsRecord>read().withConnectionFactory(cf).withQueue(\"queue\")\n  .withUsername(\"user\").withPassword(System.getenv(\"JMS_PASSWORD\"))","handlingStrategy":"try-catch","validationCode":"// pre-flight connectivity check\ntry (Socket s = new Socket()) {\n  s.connect(new InetSocketAddress(brokerHost, brokerPort), 5000);\n} catch (IOException e) {\n  throw new IllegalStateException(\"broker unreachable before pipeline start\", e);\n}","typeGuard":null,"tryCatchPattern":"try { reader.start(); } catch (IOException e) {\n  Throwable root = e; while (root.getCause() != null) root = root.getCause();\n  log.error(\"JMS connect failed: {}\", root.toString()); // then retry with backoff\n}","preventionTips":["Validate broker URL and credentials in a smoke test before deploying the pipeline.","Check worker-to-broker network reachability (VPC/firewall/security groups).","Pre-verify TLS truststores when using ssl:// URLs."],"tags":["jms","connection","io"],"backgroundTag":"connection-refused","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"}