{"record":{"id":"c83e6f9feef37364","repo":"apache/beam","slug":"solaceio-read-could-not-create-a-receiver-from-the-jcsmp","errorCode":null,"errorMessage":"SolaceIO.Read: Could not create a receiver from the Jcsmp session: session object is null.","messagePattern":"SolaceIO\\.Read: Could not create a receiver from the Jcsmp session: session object is null\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"critical","filePath":"sdks/java/io/solace/src/main/java/org/apache/beam/sdk/io/solace/broker/JcsmpSessionService.java","lineNumber":154,"sourceCode":"      throw new IOException(\"SolaceIO.Write: Could not create producer, producer object is null\");\n    }\n    return new SolaceMessageProducer(producer);\n  }\n\n  private MessageReceiver createFlowReceiver() throws JCSMPException, IOException {\n    Queue queue = checkStateNotNull(queue(), \"SolaceIO.Read: Queue is not set.\");\n\n    ConsumerFlowProperties flowProperties = new ConsumerFlowProperties();\n    flowProperties.setEndpoint(queue);\n    flowProperties.setAckMode(JCSMPProperties.SUPPORTED_MESSAGE_ACK_CLIENT);\n\n    EndpointProperties endpointProperties = new EndpointProperties();\n    endpointProperties.setAccessType(EndpointProperties.ACCESSTYPE_NONEXCLUSIVE);\n    if (jcsmpSession != null) {\n      return new SolaceMessageReceiver(\n          createFlowReceiver(jcsmpSession, flowProperties, endpointProperties));\n    }\n    throw new IOException(\n        \"SolaceIO.Read: Could not create a receiver from the Jcsmp session: session object is\"\n            + \" null.\");\n  }\n\n  // The `@SuppressWarning` is needed here, because the checkerframework reports an error for the\n  // first argument of the `createFlow` being null, even though the documentation allows it:\n  // https://docs.solace.com/API-Developer-Online-Ref-Documentation/java/com/solacesystems/jcsmp/JCSMPSession.html#createFlow-com.solacesystems.jcsmp.XMLMessageListener-com.solacesystems.jcsmp.ConsumerFlowProperties-com.solacesystems.jcsmp.EndpointProperties-\n  @SuppressWarnings(\"nullness\")\n  private static FlowReceiver createFlowReceiver(\n      JCSMPSession jcsmpSession,\n      ConsumerFlowProperties flowProperties,\n      EndpointProperties endpointProperties)\n      throws JCSMPException {\n    return jcsmpSession.createFlow(null, flowProperties, endpointProperties);\n  }\n\n  private int connectReadSession() throws JCSMPException {\n    if (jcsmpSession == null) {","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/solace/src/main/java/org/apache/beam/sdk/io/solace/broker/JcsmpSessionService.java#L136-L172","documentation":"SolaceIO.Read throws this IOException in JcsmpSessionService.createFlowReceiver when the JCSMP session object is null at the moment the reader tries to create a message flow receiver. It means the source could not establish a usable session to the Solace broker before subscribing, so reading cannot proceed. This is a fail-fast guard rather than a transient failure: the code checks `if (jcsmpSession != null)` and throws otherwise.","triggerScenarios":"Calling SolaceIO.read() when the JcsmpSessionService was never initialized with a connected session — e.g. `createSession` failed earlier and null was propagated, a custom SessionServiceFactory returned a service whose session is null, or the session was closed/nulled before the pipeline started pulling from the queue.","commonSituations":"Wrong broker host/credentials causing session creation to silently produce null in a custom factory; a user-supplied `SessionServiceFactory` implementation returning a partially constructed service; session closed by another thread during pipeline teardown or restart; copy-pasted custom broker integration code that doesn't call `session.connect()`.","solutions":["Verify the broker connection parameters (host, VPN, username, password) are correct so the JCSMP session is actually created and connected before reading.","If using a custom SessionServiceFactory, ensure it returns a service whose `getJcsmpSession()` never returns null and that `session.connect()` was called.","Check pipeline logs for an earlier JCSMPException during session creation — fix that root cause (DNS, VPN name, auth) first.","Do not close or null out the session before the read pipeline finishes; guard lifecycle ordering in custom code."],"exampleFix":"// before (custom factory)\npublic JcsmpSessionService create() {\n  JCSMPProperties props = new JCSMPProperties();\n  props.setProperty(JCSMPProperties.HOST, host);\n  return new JcsmpSessionService(props); // session never connected\n}\n// after\npublic JcsmpSessionService create() {\n  JCSMPProperties props = new JCSMPProperties();\n  props.setProperty(JCSMPProperties.HOST, host);\n  props.setProperty(JCSMPProperties.VPN_NAME, vpn);\n  JCSMPException cause = null;\n  JCSMPSession session = JCSMPFactory.onlyInstance().createSession(props);\n  session.connect(); // ensure session is usable\n  return new JcsmpSessionService(props);\n}","handlingStrategy":"validation","validationCode":"if (sessionService == null || sessionService.getJcsmpSession() == null) {\n  throw new IllegalArgumentException(\"JCSMP session not initialized — check broker config/factory\");\n}","typeGuard":null,"tryCatchPattern":"try { pipeline.run().waitUntilFinish(); } catch (IOException e) { if (e.getMessage().contains(\"session object is null\")) { /* fix session init, resubmit */ } throw e; }","preventionTips":["Always verify session.connect() succeeds before starting the read pipeline","Never return partially initialized services from custom SessionServiceFactory implementations","Check pipeline logs for earlier JCSMPExceptions that null out the session"],"tags":["solace","java","io","session","null-session"],"backgroundTag":"null-argument","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"}