"Cannot invoke 'java.net.URL.toString()'" failure in Bamboo remote agent installation

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

The installation of a Bamboo remote agent fails with a NullPointerException error during the agent bootstrap, and the following error can be found in <bamboo-agent-home>/atlassian-bamboo-agent.log:

Caused by: java.lang.NullPointerException: Cannot invoke "java.net.URL.toString()" because the return value of "com.atlassian.bamboo.agent.bootstrap.RemoteAgentBootstrap.getFinalUrlWithRedirects(String)" is null

Environment

The solution has been validated in Bamboo Data Center 10.2.0 but may be applicable to other versions.

Diagnosis

Cannot invoke "java.net.URL.toString()"

The following error is present in the <bamboo-agent-home>/atlassian-bamboo-agent.log file:

INFO | jvm 1 | 2025/01/15 21:53:05 | WrapperSimpleApp Error: Caused by: java.lang.NullPointerException: Cannot invoke "java.net.URL.toString()" because the return value of "com.atlassian.bamboo.agent.bootstrap.RemoteAgentBootstrap.getFinalUrlWithRedirects(String)" is null

A proxy is involved in the connection between the agent machine and the Bamboo machine.

Upon manually verifying the headers returned by Bamboo through the proxy when the agents try to connect to it, you can verify that there are additional (incorrect or duplicate) headers that affect the Bamboo agent's logic and prevent it from successfully generating a connection URL to the Bamboo server.

The commands below can be used to verify that:

  • Running from the Remote agent machine, using the same account that runs the agent, this will provide the headers that the agent receives from Bamboo through the proxy. Replace the BAMBOO_URL accordingly:

curl --http1.1 -s -I -H "Accept-encoding: identity" <BAMBOO_URL>/agentServer/bootstrap/content-cache-test
curl --http1.1 -k -s -I -H "Accept-encoding: identity" <BAMBOO_URL>/agentServer/bootstrap/content-cache-test
  • Running the following command from the Bamboo server, using the same user account that runs Bamboo. This is to make sure Bamboo responds correctly when directly inquired by the agent/proxy. Adjust port 8085 if your Bamboo instance uses another one.

curl --http1.1 -s -I -H "Accept-encoding: identity" http://localhost:8085/agentServer/bootstrap/content-cache-test

Cause

Issue with proxy setup

The error indicates a failure in obtaining the URL for connection, possibly due to a proxy setup.

Example response with a common scenario: Cache-Control is returning an additional/duplicate entry for "max-age", while only one is expected.

curl --http1.1 -k -s -I -H "Accept-encoding: identity" http://myBamboo/agentServer/bootstrap/content-cache-test HTTP/1.1 200 Date: Wed, 15 Jan 2025 16:13:00 GMT Server: Apache/2.4.10 (Unix) OpenSSL/1.0.1e-fips PHP/5.6.40 Referrer-Policy: no-referrer-when-downgrade X-XSS-Protection: 1; mode=block X-Frame-Options: SAMEORIGIN X-Content-Type-Options: nosniff X-Seraph-LoginReason: AUTHENTICATED_FAILED Last-Modified: Wed, 15 Jan 2025 13:53:05 GMT Cache-Control: public, max-age=30, max-age=1 Content-Type: text/plain;charset=UTF-8 Content-Length: 5002 Expires: Wed, 15 Jan 2025 16:13:01 GMT

Solution

Remove the extra values for Cache-Control

  1. Adjust your Proxy configuration to remove the additional/duplicate values for Cache-Control. By doing so, the expected response for Cache-Control would be "public, max-age=30", passing the validation and successfully constructing the URL for the agent to connect and proceed with its startup process.

  2. Once you have removed the additional header content and restarted your proxy software, validate if the output from the cURL commands returns exactly "Cache-Control: public, max-age=30":

    curl --http1.1 -s -I -H "Accept-encoding: identity" <BAMBOO_URL>/bamboo/agentServer/bootstrap/content-cache-test
  3. If yes, restart the agent and attempt to install it again.

Updated on June 2, 2025

Still need help?

The Atlassian Community is here for you.