I've been working with setting up a few servers over the past week using Ansible. Everything has been humming along fine until today a couple of hours ago the java8 playbook I had been using quit working randomly. I haven't touched it or looked at it in weeks. I even did git checkout to a known working version, still doesn't work.

The problem is almost verbatim the same as this one https://stackoverflow.com/questions/46815897/jdk-8-is-not-installed-error-404-not-found where I'm getting a 404 every time I try to run sudo apt-get install oracle-java8-installer. It also tries to download java8 on other commands like sudo apt autoremove and I always see the same error -

HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz?AuthParam=1531861842_cbe60a307e0051ef681fa0cef4e500ce [following]
--2018-07-17 21:08:42--  http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz?AuthParam=1531861842_cbe60a307e0051ef681fa0cef4e500ce
Connecting to download.oracle.com (download.oracle.com)||:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2018-07-17 21:08:42 ERROR 404: Not Found.

download failed
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

I've tried everything listed in the SO question above and many other solutions I found elsewhere. I'm beginning to think my IP is blocked or oracle is having some issues on their end, am I missing something?

  • Look at that URL in a web browser, and you will have your answer. – Michael Hampton Jul 17 '18 at 21:23
  • Yeah I just hit the same route from Postman on my local and got a 200 code, it must be blocked – Ryan Grush Jul 17 '18 at 21:34
  • Can you just go with java9? Do you really need java8? – Zoredache Jul 17 '18 at 21:36
  • @Zoredache I'm sure java9 will work for what I need, but unless Oracle started making java8 unavailable a couple of hours ago I dont think its that. I think I probably just hit my quota – Ryan Grush Jul 17 '18 at 21:39

I was having that same error as well. Until the people at WebUpd8 update their package you need to edit it yourself. I used the answer you linked to, just with the new data:

cd /var/lib/dpkg/info
sed -i 's|JAVA_VERSION=8u171|JAVA_VERSION=8u181|' oracle-java8-installer.*
sed -i 's|J_DIR=jdk1.8.0_171|J_DIR=jdk1.8.0_181|' oracle-java8-installer.*
sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/|' oracle-java8-installer.*
sed -i 's|SHA256SUM_TGZ="b6dd2837efaaec4109b36cfbb94a774db100029f98b0d78be68c27bec0275982"|SHA256SUM_TGZ="1845567095bfbfebd42ed0d09397939796d05456290fb20a83c476ba09f991d3"|' oracle-java8-installer.*

What version of Ubuntu are you using? Is there any reason for not using the official open source openjdk-8-jdk package instead of the one from oracle?

sudo apt-get install openjdk-8-jdk

Should work if you are on Ubuntu 18.04 and 16.04. The task for Ansible in this case is quite easy:

- name: Install openjdk-8-jdk
  action: apt pkg=openjdk-8-jdk state=installed

For versions prior to Ubuntu 16.04 (which I would only use 14.04, the others are EOL) you could use Matthias PPA repository:

sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update 
sudo apt-get install openjdk-8-jdk

Regarding Ansible, for this last case, you can add the repo as a task like this:

- hosts: your-server
    - name: install repo for Java 8 in Ubuntu 14.04 or below
      apt_repository: repo='ppa:openjdk-r/ppa'
  • I got it working with openjdk too before @glennsmith's answer, both worked. – Ryan Grush Jul 18 '18 at 14:15
  • The difference with the method from @glen is that it seems you are fixing the java version with those edits. You might not get security updates that way. Being java, I would advise you choose the repository option, as to allow for upgrades in case of security releases. Glad both versions worked any way!! Regards. – Leo Jul 19 '18 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.