I use the the java cookbook to install Oracle and it works as it should. I then attempt to uninstall Oracle using the java_oracle_install block, but I get a NoMethodError undefined method `[]' for nil:NilClass error. I walked the recipe to see what node properties that it might be using for the uninstall that might not be set, but I cannot see the issue.
java_oracle_install[jdk] action remove
================================================================================
Error executing action `remove` on resource 'java_oracle_install[jdk]'
================================================================================
NoMethodError
-------------
undefined method `[]' for nil:NilClass
Cookbook Trace:
---------------
/tmp/kitchen/cache/cookbooks/java_wrapper/resources/remove_installed.rb:8:in `block in class_from_file'
/tmp/kitchen/cache/cookbooks/java_wrapper/resources/remove_installed.rb:45:in `block (3 levels) in class_from_file'
Resource Declaration:
---------------------
# In /tmp/kitchen/cache/cookbooks/java_wrapper/resources/remove_installed.rb
39: java_oracle_install 'jdk' do
40: url file_url
41: checksum checksum
42: app_home r.java_home
43: bin_cmds node['java']['jdk'][r.version]['bin_cmds']
44: action :remove
45: only_if { r.build == 'oracle' }
46: end
47:
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cache/cookbooks/java_wrapper/resources/remove_installed.rb:39:in `block in class_from_file'
java_oracle_install("jdk") do
action [:remove]
default_guard_interpreter :default
declared_type :java_oracle_install
cookbook_name "java_wrapper"
url "http://nexus-server/repository/files/java/8/oracle/jdk/jdk-8u212-linux-x64.tar.gz"
checksum "3160c50aa8d8e081c8c7fe0f859ea452922eca5d2ae8f8ef22011ae87e6fedfb"
app_home "/usr/lib/jvm/java-8-oracle-amd64"
bin_cmds ["appletviewer", "apt", "ControlPanel", "extcheck", "idlj", "jar", "jarsigner", "java", "javac", "javadoc", "javafxpackager", "javah", "javap", "javaws", "jcmd", "jconsole", "jcontrol", "jdb", "jdeps", "jhat", "jinfo", "jjs", "jmap", "jmc", "jps", "jrunscript", "jsadebugd", "jstack", "jstat", "jstatd", "jvisualvm", "keytool", "native2ascii", "orbd", "pack200", "policytool", "rmic", "rmid", "rmiregistry", "schemagen", "serialver", "servertool", "tnameserv", "unpack200", "wsgen", "wsimport", "xjc"]
only_if { #code block }
end
System Info:
------------
chef_version=14.13.11
platform=ubuntu
platform_version=16.04
ruby=ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
program_name=/opt/chef/bin/chef-client
executable=/opt/chef/bin/chef-client
Running handlers:
[2019-07-10T17:42:56+00:00] ERROR: Running exception handlers
Running handlers complete
[2019-07-10T17:42:56+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 01 seconds
[2019-07-10T17:42:56+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
[2019-07-10T17:42:56+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2019-07-10T17:42:56+00:00] FATAL: NoMethodError: undefined method `[]' for nil:NilClass
Cookbook version
4.1.0
Chef-client version
Chef Workstation: 0.2.53 chef-run: 0.2.8 chef-client: 14.10.9 delivery-cli: 0.0.52 (9d07501a3b347cc687c902319d23dc32dd5fa621) berks: 7.0.7 test-kitchen: 1.24.0 inspec: 3.6.6
Using test kitchen and pinning chef client to 14.
Platform Details
ubuntu-16.04
Scenario:
I use the the java cookbook to install Oracle and it works as it should. I then attempt to uninstall Oracle using the java_oracle_install block, but I get a NoMethodError undefined method `[]' for nil:NilClass error. I walked the recipe to see what node properties that it might be using for the uninstall that might not be set, but I cannot see the issue.