newrelic: Curling for java agent is returning a 404

curl for the java agent is returning a 404 but I get a 200 in a browser.

$  curl -I  http://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/
HTTP/1.1 404 Not Found
Last-Modified: Tue, 20 Sep 2016 22:13:40 GMT
x-amz-version-id: NLCnxJuorRTx5WOnoeySmdST9dAqQyv1
ETag: "a33b4d0f06bf8a8f61a6898e363bdbdb"
x-amz-error-code: NoSuchKey
x-amz-error-message: The specified key does not exist.
x-amz-error-detail-Key: newrelic/java-agent/newrelic-agent/current/index.html
x-amz-request-id: AE3A9E8C693EF743
x-amz-id-2: nrhCfQK6C74mH2f9pqlkw0PX2L54HrseJcvvVQd729sVlXQnKyRPKFoDKcW6iMplAXzdCrb+QDI=
Content-Type: text/html
Server: AmazonS3
Content-Length: 8129
Accept-Ranges: bytes
Date: Thu, 22 Sep 2016 18:44:17 GMT
Via: 1.1 varnish
Age: 2461
Connection: keep-alive
X-Served-By: cache-ord1728-ORD
X-Cache: HIT
X-Cache-Hits: 2
X-Timer: S1474569857.467308,VS0,VE0```

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 19 (7 by maintainers)

Most upvoted comments

I resolved the issue by specifying the version of the Java agent.

The problem as pointed out by @drewglass is here: https://github.com/djoos-cookbooks/newrelic/blob/master/providers/agent_java.rb#L46

It is better to avoid parsing that page, just download directly: https://download.newrelic.com/newrelic/java-agent/newrelic-agent/#{version}/newrelic-java.zip And then unzip only newrelic.jar from the zip. Something like this (not tested):

def agent_jar
  zip_file = 'newrelic-java.zip'
  version = new_resource.version
  version = 'current' if version == 'latest'
  https_download = "https://download.newrelic.com/newrelic/java-agent/newrelic-agent/#{version}/#{zip_file}"

  cache_dir = Chef::Config[:file_cache_path]
  tmp_file = "#{cache_dir}/#{zip_file}"

  remote_file tmp_file do
    source https_download
    mode '0664'
    action :create
    notifies :run, "bash[unzip-#{tmp_file}]", :immediately
  end

  package 'unzip'

  bash "unzip-#{tmp_file}" do
    user new_resource.app_user
    group new_resource.app_group
    action :nothing
    code <<-EOH
      unzip -oj "#{tmp_file}" "newrelic/newrelic.jar" -d "#{new_resource.install_dir}"
    EOH
  end
end

Would be great if the download URL in the cookbook was an attribute so we could easily override it. Not just to work around this but to also have a more localized location to download from.

That said it seems the current issue might be because https://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/ is actually responding with a 404, but most browsers will render the page so you can still see the file list.

curl -I https://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/ HTTP/1.1 404 Not Found Last-Modified: Tue, 20 Sep 2016 22:13:40 GMT x-amz-version-id: NLCnxJuorRTx5WOnoeySmdST9dAqQyv1 ETag: “a33b4d0f06bf8a8f61a6898e363bdbdb” x-amz-error-code: NoSuchKey x-amz-error-message: The specified key does not exist. x-amz-error-detail-Key: newrelic/java-agent/newrelic-agent/current/index.html x-amz-request-id: 0C6172A37DE4710D x-amz-id-2: 9T9M6o1KgMPo/r8wrEpI031upusBq+WwNpBWgZ1LhxHy7OGI+/uCRhcx4G2Jz0dGCKAwDfPQOR4= Content-Type: text/html Server: AmazonS3 Content-Length: 8129 Accept-Ranges: bytes Date: Thu, 22 Sep 2016 21:08:49 GMT Via: 1.1 varnish Age: 266 Connection: keep-alive X-Served-By: cache-sea1926-SEA X-Cache: HIT X-Cache-Hits: 1 X-Timer: S1474578529.520986,VS0,VE0