在我的LWRP扩展超市食谱中,我得到了以下工作。
module PIWebsphereCookBook
class WebsphereJbdc < WebsphereCookBook::WebsphereBase
当我在这两个之间介绍我自己的类时,我得到' Unitialized Constant Error '
require_relative './pi_websphere_base'
module PIWebsphereCookBook
class WebsphereJbdc < PIWebsphereBase
我想扩展的基类如下所示:
module PIWebsphereCookBook
class PIWebsphereBase < WebsphereCookbook::WebsphereBase
我从日志中看到正在加载引用的类/文件
[2017-06-23T18:37:28-04:00] DEBUG: Loading cookbook pi_websphere's resources from /var/chef/cache/cookbooks/pi_websphere/resources/pi_websphere_base.rb
[2017-06-23T18:37:28-04:00] DEBUG: Loaded contents of /var/chef/cache/cookbooks/pi_websphere/resources/pi_websphere_base.rb into resource pi_websphere_pi_websphere_base (Custom resource pi_websphere_pi_websphere_base from cookbook pi_websphere)
[2017-06-23T18:37:28-04:00] DEBUG: Loading cookbook pi_websphere's resources from /var/chef/cache/cookbooks/pi_websphere/resources/websphere_j2c.rb
[2017-06-23T18:37:28-04:00] DEBUG: Loaded contents of /var/chef/cache/cookbooks/pi_websphere/resources/websphere_j2c.rb into resource pi_websphere_websphere_j2c (Custom resource pi_websphere_websphere_j2c from cookbook pi_websphere)
[2017-06-23T18:37:28-04:00] DEBUG: Loading cookbook pi_websphere's resources from /var/chef/cache/cookbooks/pi_websphere/resources/websphere_jdbc.rb
[2017-06-23T18:37:28-04:00] DEBUG: Filtered backtrace of compile error: /var/chef/cache/cookbooks/pi_websphere/resources/websphere_jdbc.rb:3:in `<module:PIWebsphereCookBook>',/var/chef/cache/cookbooks/pi_websphere/resources/websphere_jdbc.rb:2:in `class_from_file'
[2017-06-23T18:37:28-04:00] DEBUG: Backtrace entry for compile error: '/var/chef/cache/cookbooks/pi_websphere/resources/websphere_jdbc.rb:3:in `<module:PIWebsphereCookBook>''
[2017-06-23T18:37:28-04:00] DEBUG: Line number of compile error: '3'
Recipe Compile Error in
/var/chef/cache/cookbooks/pi_websphere/resources/websphere_jdbc.rb
NameError
---------
uninitialized constant #
<Class:0x000000052796d8>::PIWebsphereCookBook::PIWebsphereBase
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/pi_websphere/resources/websphere_jdbc.rb:3:in ` <module:PIWebsphereCookBook>'
/var/chef/cache/cookbooks/pi_websphere/resources/websphere_jdbc.rb:2:in ` class_from_file'
Relevant File Content:
----------------------
/var/chef/cache/cookbooks/pi_websphere/resources/websphere_jdbc.rb:
1: require_relative './pi_websphere_base'
2: module PIWebsphereCookBook
3>> class WebsphereJbdc < PIWebsphereBase
4: require_relative 'helper'
5:
文件夹结构如下所示
[root@localhost pi_websphere]# tree
.
├── attributes
│ └── default.rb
├── Gemfile
├── jaas_auth.py
├── libraries
│ ├── abc.rb
│ ├── artifactory_helper.rb
│ ├── pi_websphere_base.rb
│ └── websphere_base.rb
├── metadata.rb
├── README.md
├── resources
│ ├── artifactory_client.rb
│ ├── helper.rb
│ ├── websphere_j2c.rb
│ ├── websphere_jdbc.rb