Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
得到;未定义的方法“[]';对于nil:NilClass“;安装java Cookbook_Java_Ruby_Maven_Chef Infra_Vagrant - Fatal编程技术网

得到;未定义的方法“[]';对于nil:NilClass“;安装java Cookbook

得到;未定义的方法“[]';对于nil:NilClass“;安装java Cookbook,java,ruby,maven,chef-infra,vagrant,Java,Ruby,Maven,Chef Infra,Vagrant,我尝试使用Chef Solo和Berkshelf建立一个流浪vm。我想用这本食谱。“maven”依赖于“java”和“java_ark”(包含在“java”食谱中)。所有这些都是由Opscode创建的 但每次我遇到这个错误: NoMethodError ------------- undefined method `[]' for nil:NilClass Cookbook Trace: --------------- /tmp/vagrant-chef-1/chef-solo-

我尝试使用Chef Solo和Berkshelf建立一个流浪vm。我想用这本食谱。“maven”依赖于“java”和“java_ark”(包含在“java”食谱中)。所有这些都是由Opscode创建的

但每次我遇到这个错误:

NoMethodError

-------------

undefined method `[]' for nil:NilClass




Cookbook Trace:
---------------
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/java/recipes/default.rb:21:in `from_file'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/platform-slayer/recipes/slayer_worker.rb:2:in `from_file'


Relevant File Content:
----------------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/java/recipes/default.rb:

 14:  # Unless required by applicable law or agreed to in writing, software
 15:  # distributed under the License is distributed on an "AS IS" BASIS,
 16:  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 17:  # See the License for the specific language governing permissions and
 18:  # limitations under the License.
 19:  #
 20:  
 21>> include_recipe "java::#{node['java']['install_flavor']}"
 22:  
 23:  # Purge the deprecated Sun Java packages if remove_deprecated_packages is true
 24:  %w[sun-java6-jdk sun-java6-bin sun-java6-jre].each do |pkg|
 25:    package pkg do
 26:      action :purge
 27:      only_if { node['java']['remove_deprecated_packages'] }
 28:    end
 29:  end
 30:
有人知道这个问题吗?
如果您需要更多信息,请告诉我。

我认为问题在于
node['java']
的计算结果为
nil

一种可能的解决方案是在烹饪书或节点定义或相关角色定义中定义属性
节点['java']['install\u flavor']


但是它看起来像是食谱中的一个bug,因为文档中说默认值应该应用于
install\u flavor
属性。

这看起来确实像一个bug。对于那些有类似问题的人,我建议使用java::openjdk。

似乎没有安装java。您能确认是否安装了java吗?您可以打印
java-version
谢谢回复!不,Java安装由于我发布的错误正在中止。哪个操作系统?您可以使用其他包管理工具吗?能否打印
角色/base.rb
。您可能必须覆盖oracle下载条款。没有角色/base.rb覆盖已完成,但没有效果。我使用Xubuntu作为主机操作系统,Debian Wheezy作为来宾OSIf open jdk对您来说很好,我相信
sudo apt get install openjdk-7-jre
将安装java。你能在外部安装java后再试一次吗?我很确定这才是真正的问题所在。尝试破解你的食谱副本以获得更多信息;e、 g.在无法打印插入字符串的行之前添加一行。是的,这是正确的,因为配方必须作为元数据中的依赖项添加。rb谢谢您的帮助!;)@Morphesus我认为最好添加“metadata.rb”解决方案作为答案,并选择它作为公认的答案。这将使这一页更容易阅读。。。你帮我解决了这个问题,但我几乎忽略了这一步。