You observe a `java.lang.NullPointerException` from Mule Runtime when invoking the Salesforce Connector. This typically occurs after migrating a Salesforce integration from basic authentication to OAuth JWT/ECA, specifically when the token endpoint configuration for the JWT connection is not correctly populated or referenced.
CAUSE
The `java.lang.NullPointerException` arises when the Salesforce Connector, configured for OAuth JWT/ECA, attempts to utilize a token endpoint that is either unpopulated, incorrectly referenced, or resolves to a null value. This often stems from a misconfiguration, such as a typo in property or variable names used to define or retrieve the token endpoint, preventing the connector from properly initializing its OAuth JWT connection. The connector's internal logic expects a valid token endpoint URL to be present for successful authentication.
SOLUTION
1. **Review Salesforce Connector Configuration:** Examine the configuration of your Salesforce Connector in your Mule application's XML or properties.
2. **Locate JWT Connection:** If you are using an OAuth JWT connection, identify the `<salesforce:jwt-connection>` element.
3. **Verify `tokenEndpoint` Attribute:** Ensure that the `tokenEndpoint` attribute within this configuration is correctly populated. This value should point to your Salesforce instance's token endpoint (e.g., `https://login.salesforce.com/services/oauth2/token` for production or `https://test.salesforce.com/services/oauth2/token` for sandbox).
* **Example Configuration:**
```xml
<salesforce:jwt-connection name="Salesforce_JWT_Connection" doc:name="Salesforce JWT Connection">
<salesforce:jwt-oauth-connection
keyStore="${secure::salesforce.keystore.path}"
keyStorePassword="${secure::salesforce.keystore.password}"
keyAlias="${secure::salesforce.key.alias}"
keyPassword="${secure::salesforce.key.password}"
principal="${secure::salesforce.principal}"
tokenEndpoint="${secure::salesforce.token.endpoint}"
audience="https://login.salesforce.com"
expiration="300000"
reconnectionAttempts="3"
reconnectionFrequency="5000" />
</salesforce:jwt-connection>
```
4. **Check Property/Variable Resolution:** If the `tokenEndpoint` value is being retrieved from a property or variable (e.g., `${secure::salesforce.token.endpoint}`), perform the following checks:
* **Typo Check:** Verify that the property/variable name is spelled correctly and matches its definition in your configuration files (e.g., `mule-app.properties`, `config.yaml`, secure properties).
* **Definition and Accessibility:** Confirm that the property/variable is correctly defined and accessible in the environment where the application is deployed (e.g., CloudHub properties, local properties).
* **Value Validation:** Ensure that the property/variable resolves to a valid, non-null URL for the token endpoint.
5. **Correct Misconfigurations:** Rectify any typos or incorrect references in the `tokenEndpoint` attribute or the properties/variables it references.
6. **Redeploy Application:** Redeploy your Mule application with the corrected configuration.
APPLIES TO
- Mule Runtime 4.x (specifically observed on 4.9.19:8)
- Salesforce Connector 11.4.0 and later versions using OAuth JWT connection
- CloudHub deployment model
005390249

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.