JDK-8211012 : [Linux] JDK 11, warning when uninstall rpm package "warning: %postun(jdk-11-2000:11-ga.x86_64) scriptlet failed, exit status 2
  • Type: Bug
  • Component: install
  • Sub-Component: uninstall
  • Affected Version: 11,12
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • CPU: x86_64
  • Submitted: 2018-09-21
  • Updated: 2019-01-15
  • Resolved: 2018-09-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11
11.0.2Fixed
Description
Download jdk 11+28 rpm package from
https://java.se.oracle.com/artifactory/re-release-local/jdk/11/28/bundles/linux-x64/jdk-11_linux-x64_bin.rpm
 
[testuser@emb-jh-01 staged]$ ls
jdk-11_linux-x64_bin.rpm
[testuser@emb-jh-01 staged]$ sudo rpm -ivh jdk-11_linux-x64_bin.rpm 
[sudo] password for testuser: 
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk-11-2000:11-ga                ################################# [100%]
[testuser@emb-jh-01 staged]$ cd /usr/java
[testuser@emb-jh-01 java]$ ls
default  jdk-11  latest
[testuser@emb-jh-01 java]$ sudo rpm -e jdk-11
failed to read link /usr/bin/javac: No such file or directory
warning: %postun(jdk-11-2000:11-ga.x86_64) scriptlet failed, exit status 2
[testuser@emb-jh-01 java]$ 
Comments
The problem of issue is it will broke the environment, and block the future link creation while installing. Description and issue reproduce steps: 1. find a clean machine that install/uninstall 8uX without issues. 2. install jdk 11 3. uninstall jdk 11 4. install another version of java, e.g. 8u191 5. try to verify the links created for 8u191, somehow the javac links to jdk-11, not 8u191 jacey@sca00bfn -> ls -la /usr/bin/javac lrwxrwxrwx 1 root wheel 23 Sep 24 22:21 /usr/bin/javac -> /etc/alternatives/javac jacey@sca00bfn -> ls -la /etc/alternatives/javac lrwxrwxrwx 1 root wheel 26 Sep 24 22:21 /etc/alternatives/javac -> /usr/java/jdk-11/bin/javac 6. check alternatives javac link definition. Somehow, the jdk-11 uninstall process doesn't remove javac link correctly. jacey@sca00bfn -> sudo alternatives --display javac javac - status is auto. link currently points to /usr/java/jdk-11/bin/javac ... User should manually run below command to fix environment issue, otherwise all the future installation (e.g. 8uX, 9u, 10u) will fail to create javac links. sudo alternatives --remove javac /usr/java/jdk-11/bin/javac sudo alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_191-amd64/bin/javac 180191
25-09-2018

I manually cleaned up the alternatives database per the instruction. I tried the install/uninstall again. I don't see message "failed to read link /usr/bin/javac: No such file or directory", but still get the warning message: [testuser@emb-jh-01 java]$ sudo rpm -e jdk-11 warning: %postun(jdk-11-2000:11-ga.x86_64) scriptlet failed, exit status 2
21-09-2018

This is well known issue with alternatives script. It occurs on a system where multiple JDK were installed and that were not cleanly removed. Bad JDK uninstalls result in dangling records in alternatives database. Suggested fix for the problem is to clean up alternatives database manually. 1. Get a list of alternatives associated with "javac" key with the following shell command: /usr/sbin/alternatives --display javac | grep priority The output should be something like this: --- /usr/java/jdk-11.0.1/bin/javac - priority 110001000 /usr/java/jdk-11/bin/javac - priority 110000000 /usr/java/jdk1.8.0_181-amd64/bin/javac - priority 180181 /usr/java/jdk1.8.0_72-amd64/bin/javac - priority 18072 --- 2. For each reported record matching to non-existing JDK installation run "/usr/sbin/alternatives --remove ..." command to clean alternatives database: --- sudo /usr/sbin/alternatives --remove javac /usr/java/jdk-11.0.1/bin/javac sudo /usr/sbin/alternatives --remove javac /usr/java/jdk-11/bin/javac sudo /usr/sbin/alternatives --remove javac /usr/java/jdk1.8.0_181-amd64/bin/javac sudo /usr/sbin/alternatives --remove javac /usr/java/jdk1.8.0_72-amd64/bin/javac --- So this is not an installer issue, but environment issue.
21-09-2018