# Recipe application does not work because chef\_envronment is not defined

**URL:** <https://discourse.chef.io/t/recipe-application-does-not-work-because-chef-envronment-is-not-defined/2654>\
**Category:** Chef Infra (archive)\
**Created:** [April 11, 2012, 7:20am UTC](https://discourse.chef.io/t/recipe-application-does-not-work-because-chef-envronment-is-not-defined/2654 "2012-04-11T07:20:26Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jesus\_M\_Movilla](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@Jesus\_M\_Movilla](https://discourse.chef.io/u/Jesus_M_Movilla)\
**Post date:** [April 11, 2012, 7:20am UTC](https://discourse.chef.io/t/recipe-application-does-not-work-because-chef-envronment-is-not-defined/2654/1 "2012-04-11T07:20:26Z")

</div>

Hi all,

I have installed chef 0.10.4 and I am testing the application cookbook.

The thing is that executing this cookbookit fails when the recipe  
application::java\_webapp.rb tries to get the value of the method  
chef\_environment of the Node Object (node.chef\_environment). This is the error:

Re-raising exception: ArgumentError - Attribute chef\_environment is not  
defined!

I have checked the node with knife node edit command and I have seen that the  
attribute chef\_environment is set to “\_default”

* * *

“chef\_environment”: “\_default”,  
“run\_list”: [  
“recipe[application]”,  
“role[my\_app]”  
]

* * *

So, I guess the value of the node.chef\_environment should be “\_default”, what  
is the problem?

On the other hand, I have tried to modify the environment of this node via  
knife by changing the value to “prooduction” (after creating this environment  
in the chef server as it is said in the Usage section of this cookbook ) and It  
happens two things:  
1)The recipe still fails (same error)  
2)The chef\_environment in the node is changed back to “\_default” after excution  
of the recipe

Any hint?  
Best Regards

---

<div class="post-metadata">

**Author:** ![Andrea\_Campi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/andrea_campi/32/514_2.png) [@Andrea\_Campi](https://discourse.chef.io/u/Andrea_Campi)\
**Post date:** [April 11, 2012, 7:50am UTC](https://discourse.chef.io/t/recipe-application-does-not-work-because-chef-envronment-is-not-defined/2654/2 "2012-04-11T07:50:00Z")

</div>

On Wed, Apr 11, 2012 at 9:20 AM, [jesus.movilla@altran.es](mailto:jesus.movilla@altran.es) wrote:

> Hi all,
> 
> I have installed chef 0.10.4 and I am testing the application cookbook.
> 
> The thing is that executing this cookbookit fails when the recipe  
> application::java\_webapp.rb tries to get the value of the method  
> chef\_environment of the Node Object (node.chef\_environment). This is the error:
> 
> Re-raising exception: ArgumentError - Attribute chef\_environment is not  
> defined!

First of all, be aware that I'm currently on refactoring the  
application cookbook, I will have a replacement ready in the next few  
weeks.

Having said that, the current one shouldn't fail like this.  
Can you show me where it fails? A backtrace would be most useful.

> I have checked the node with knife node edit command and I have seen that the  
> attribute chef\_environment is set to "\_default"
> 
> * * *
> 
> "chef\_environment": "\_default",  
> "run\_list": [  
> "recipe[application]",  
> "role[my\_app]"  
> ]
> 
> * * *
> 
> So, I guess the value of the node.chef\_environment should be "\_default", what  
> is the problem?
> 
> On the other hand, I have tried to modify the environment of this node via  
> knife by changing the value to "prooduction" (after creating this environment  
> in the chef server as it is said in the Usage section of this cookbook ) and It  
> happens two things:  
> 1)The recipe still fails (same error)  
> 2)The chef\_environment in the node is changed back to "\_default" after excution  
> of the recipe

Regarding #2, that can happen if you edit the node while a chef-client  
run is happening on the client.  
I assume you tried again, but try again 🙂

Andrea

---

<div class="post-metadata">

**Author:** ![Jesus\_M\_Movilla](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@Jesus\_M\_Movilla](https://discourse.chef.io/u/Jesus_M_Movilla)\
**Post date:** [April 11, 2012, 8:15am UTC](https://discourse.chef.io/t/recipe-application-does-not-work-because-chef-envronment-is-not-defined/2654/3 "2012-04-11T08:15:01Z")

</div>

Hi Andrea

Regarding #1. Next I include the backtrace. Just to point out that  
"chef-client version" in the node shows "Starting Chef Run (_Version 0.9.18_)".  
However Chef server is 0.10.4

[Wed, 11 Apr 2012 10:05:26 +0200] DEBUG: Sending HTTP Request via GET to  
10.95.107.48:4000/search/apps  
[Wed, 11 Apr 2012 10:05:26 +0200] DEBUG: Loading Recipe  
application::java\_webapp via include\_recipe  
[Wed, 11 Apr 2012 10:05:26 +0200] DEBUG: Found recipe java\_webapp in  
cookbook application  
[Wed, 11 Apr 2012 10:05:26 +0200] ERROR: Running exception handlers  
[Wed, 11 Apr 2012 10:05:26 +0200] ERROR: Exception handlers complete  
[Wed, 11 Apr 2012 10:05:26 +0200] DEBUG: Re-raising exception:  
ArgumentError - Attribute chef\_environment is not defined!  
/usr/lib/ruby/1.8/chef/node/attribute.rb:428:in `method_missing' /usr/lib/ruby/1.8/chef/node.rb:319:in `send'  
/usr/lib/ruby/1.8/chef/node.rb:319:in `method_missing' /var/cache/chef/cookbooks/application/recipes/java_webapp.rb:28:in `from\_file'  
/usr/lib/ruby/1.8/chef/cookbook\_version.rb:473:in `load_recipe' /usr/lib/ruby/1.8/chef/mixin/language_include_recipe.rb:40:in `include\_recipe'  
/usr/lib/ruby/1.8/chef/mixin/language\_include\_recipe.rb:27:in `each' /usr/lib/ruby/1.8/chef/mixin/language_include_recipe.rb:27:in `include\_recipe'  
/var/cache/chef/cookbooks/application/recipes/default.rb:31:in `from_file' /var/cache/chef/cookbooks/application/recipes/default.rb:28:in `each'  
/var/cache/chef/cookbooks/application/recipes/default.rb:28:in `from_file' /var/cache/chef/cookbooks/application/recipes/default.rb:25:in `each'  
/var/cache/chef/cookbooks/application/recipes/default.rb:25:in `from_file' /usr/lib/ruby/1.8/chef/search/query.rb:39:in `call'  
/usr/lib/ruby/1.8/chef/search/query.rb:39:in `search' /usr/lib/ruby/1.8/chef/search/query.rb:39:in `each'  
/usr/lib/ruby/1.8/chef/search/query.rb:39:in `search' /usr/lib/ruby/1.8/chef/mixin/language.rb:135:in `search'  
/var/cache/chef/cookbooks/application/recipes/default.rb:21:in `from_file' /usr/lib/ruby/1.8/chef/cookbook_version.rb:473:in `load\_recipe'  
/usr/lib/ruby/1.8/chef/mixin/language\_include\_recipe.rb:40:in  
`include_recipe' /usr/lib/ruby/1.8/chef/mixin/language_include_recipe.rb:27:in `each'  
/usr/lib/ruby/1.8/chef/mixin/language\_include\_recipe.rb:27:in  
`include_recipe' /usr/lib/ruby/1.8/chef/run_context.rb:94:in `load'  
/usr/lib/ruby/1.8/chef/run\_context.rb:91:in `each' /usr/lib/ruby/1.8/chef/run_context.rb:91:in `load'  
/usr/lib/ruby/1.8/chef/run\_context.rb:55:in `initialize' /usr/lib/ruby/1.8/chef/client.rb:166:in `new'  
/usr/lib/ruby/1.8/chef/client.rb:166:in `run' /usr/lib/ruby/1.8/chef/application/client.rb:222:in `run\_application'  
/usr/lib/ruby/1.8/chef/application/client.rb:212:in `loop' /usr/lib/ruby/1.8/chef/application/client.rb:212:in `run\_application'  
/usr/lib/ruby/1.8/chef/application.rb:62:in `run' /usr/bin/chef-client:26 /usr/lib/ruby/1.8/chef/node/attribute.rb:428:in `method\_missing': Attribute  
chef\_environment is not defined! (ArgumentError)  
from /usr/lib/ruby/1.8/chef/node.rb:319:in `send' from /usr/lib/ruby/1.8/chef/node.rb:319:in `method\_missing'  
from  
/var/cache/chef/cookbooks/application/recipes/java\_webapp.rb:28:in  
`from_file' from /usr/lib/ruby/1.8/chef/cookbook_version.rb:473:in `load\_recipe'  
from /usr/lib/ruby/1.8/chef/mixin/language\_include\_recipe.rb:40:in  
`include_recipe' from /usr/lib/ruby/1.8/chef/mixin/language_include_recipe.rb:27:in `each'  
from /usr/lib/ruby/1.8/chef/mixin/language\_include\_recipe.rb:27:in  
`include_recipe' from /var/cache/chef/cookbooks/application/recipes/default.rb:31:in `from\_file'  
from /var/cache/chef/cookbooks/application/recipes/default.rb:28:in  
`each' from /var/cache/chef/cookbooks/application/recipes/default.rb:28:in `from\_file'  
from /var/cache/chef/cookbooks/application/recipes/default.rb:25:in  
`each' from /var/cache/chef/cookbooks/application/recipes/default.rb:25:in `from\_file'  
from /usr/lib/ruby/1.8/chef/search/query.rb:39:in `call' from /usr/lib/ruby/1.8/chef/search/query.rb:39:in `search'  
from /usr/lib/ruby/1.8/chef/search/query.rb:39:in `each' from /usr/lib/ruby/1.8/chef/search/query.rb:39:in `search'  
from /usr/lib/ruby/1.8/chef/mixin/language.rb:135:in `search' from /var/cache/chef/cookbooks/application/recipes/default.rb:21:in `from\_file'  
from /usr/lib/ruby/1.8/chef/cookbook\_version.rb:473:in `load_recipe' from /usr/lib/ruby/1.8/chef/mixin/language_include_recipe.rb:40:in `include\_recipe'  
from /usr/lib/ruby/1.8/chef/mixin/language\_include\_recipe.rb:27:in  
`each' from /usr/lib/ruby/1.8/chef/mixin/language_include_recipe.rb:27:in `include\_recipe'  
from /usr/lib/ruby/1.8/chef/run\_context.rb:94:in `load' from /usr/lib/ruby/1.8/chef/run_context.rb:91:in `each'  
from /usr/lib/ruby/1.8/chef/run\_context.rb:91:in `load' from /usr/lib/ruby/1.8/chef/run_context.rb:55:in `initialize'  
from /usr/lib/ruby/1.8/chef/client.rb:166:in `new' from /usr/lib/ruby/1.8/chef/client.rb:166:in `run'  
from /usr/lib/ruby/1.8/chef/application/client.rb:222:in  
`run_application' from /usr/lib/ruby/1.8/chef/application/client.rb:212:in `loop'  
from /usr/lib/ruby/1.8/chef/application/client.rb:212:in  
`run_application' from /usr/lib/ruby/1.8/chef/application.rb:62:in `run'  
from /usr/bin/chef-client:26

On Wed, Apr 11, 2012 at 9:50 AM, Andrea Campi  
[andrea.campi@zephirworks.com](mailto:andrea.campi@zephirworks.com)wrote:

> On Wed, Apr 11, 2012 at 9:20 AM, [jesus.movilla@altran.es](mailto:jesus.movilla@altran.es) wrote:
> 
> > Hi all,
> > 
> > I have installed chef 0.10.4 and I am testing the application cookbook.
> > 
> > The thing is that executing this cookbookit fails when the recipe  
> > application::java\_webapp.rb tries to get the value of the method  
> > chef\_environment of the Node Object (node.chef\_environment). This is the  
> > error:
> > 
> > Re-raising exception: ArgumentError - Attribute chef\_environment is not  
> > defined!
> 
> First of all, be aware that I'm currently on refactoring the  
> application cookbook, I will have a replacement ready in the next few  
> weeks.
> 
> Having said that, the current one shouldn't fail like this.  
> Can you show me where it fails? A backtrace would be most useful.
> 
> > I have checked the node with knife node edit command and I have seen  
> > that the  
> > attribute chef\_environment is set to "\_default"
> > 
> > * * *
> > 
> > "chef\_environment": "\_default",  
> > "run\_list": [  
> > "recipe[application]",  
> > "role[my\_app]"  
> > ]
> > 
> > * * *
> > 
> > So, I guess the value of the node.chef\_environment should be "\_default",  
> > what  
> > is the problem?
> > 
> > On the other hand, I have tried to modify the environment of this node  
> > via  
> > knife by changing the value to "prooduction" (after creating this  
> > environment  
> > in the chef server as it is said in the Usage section of this cookbook )  
> > and It  
> > happens two things:  
> > 1)The recipe still fails (same error)  
> > 2)The chef\_environment in the node is changed back to "\_default" after  
> > excution  
> > of the recipe
> 
> Regarding #2, that can happen if you edit the node while a chef-client  
> run is happening on the client.  
> I assume you tried again, but try again 🙂

This is the sequence of the commands that I execute:

1)knife node edit \<node\_name\>  
2)I go to the "chef\_environment" attribute and I write "production"  
instaead of "\_default"  
3)I save the changes (!wq with vi EDITOR)  
4)I wait a minute and type again knife node edit \<node\_name\> to check the  
value is still "production" (it is)  
5) I ecxecute "chef-client" in the node whose run\_list includes the  
cookbook application  
6)The cookbook fails (the problem stated above)  
7)I type again knife node edit \<node\_name\> and the values is back to  
"\_default"

> Andrea

Thanks a lot!

Jesus

---

<div class="post-metadata">

**Author:** ![Andrea\_Campi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/andrea_campi/32/514_2.png) [@Andrea\_Campi](https://discourse.chef.io/u/Andrea_Campi)\
**Post date:** [April 11, 2012, 8:47am UTC](https://discourse.chef.io/t/recipe-application-does-not-work-because-chef-envronment-is-not-defined/2654/4 "2012-04-11T08:47:58Z")

</div>

On Wed, Apr 11, 2012 at 10:15 AM, Jesus M. Movilla  
[jesus.movilla@altran.es](mailto:jesus.movilla@altran.es) wrote:

> Hi Andrea
> 
> Regarding #1. Next I include the backtrace. Just to point out that  
> "chef-client version" in the node shows "Starting Chef Run (Version  
> 0.9.18)". However Chef server is 0.10.4

That's your problem then, you need to upgrade the chef gem on your  
client. 0.9.x didn't know about environments.

---

<div class="post-metadata">

**Author:** ![Jesus\_M\_Movilla](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@Jesus\_M\_Movilla](https://discourse.chef.io/u/Jesus_M_Movilla)\
**Post date:** [April 11, 2012, 9:19am UTC](https://discourse.chef.io/t/recipe-application-does-not-work-because-chef-envronment-is-not-defined/2654/5 "2012-04-11T09:19:06Z")

</div>

Hi Andrea

Thanks!

I have followed the instructions from this page to do it. The node is  
Ubuntu 10.10

Debian packaging; the service will be stopped and started for you.  
sudo apt-get update  
sudo apt-install chef

and this is what it hapens:

root@sdcnode01:~# sudo apt-get install chef  
Leyendo lista de paquetes... Hecho  
Creando Ã¡rbol de dependencias  
Leyendo la informaciÃ³n de estado... Hecho  
chef ya estÃ¡ en su versiÃ³n mÃ¡s reciente.  
0 actualizados, 0 se instalarÃ¡n, 0 para eliminar y 92 no actualizados.

If I type chef-client, the version is not upgraded... (

[Wed, 11 Apr 2012 11:11:03 +0200] INFO: Starting Chef Run (Version 0.9.18)

Typing apt-get update, the following opscode repos appear in the full list  
of repos:

Obj [http://apt.opscode.com](http://apt.opscode.com) lucid Release.gpg  
Ign [http://apt.opscode.com/](http://apt.opscode.com/) lucid/main Translation-en  
Ign [http://apt.opscode.com/](http://apt.opscode.com/) lucid/main Translation-es  
Obj [http://apt.opscode.com](http://apt.opscode.com) lucid Release  
Ign [http://apt.opscode.com](http://apt.opscode.com) lucid/main amd64 Packages  
Obj [http://apt.opscode.com](http://apt.opscode.com) lucid/main amd64 Packages

What is missing to upgrade chef-client to 0.10?

Regards

On Wed, Apr 11, 2012 at 10:47 AM, Andrea Campi \<[andrea.campi@zephirworks.com](mailto:andrea.campi@zephirworks.com)

> wrote:

> On Wed, Apr 11, 2012 at 10:15 AM, Jesus M. Movilla  
> [jesus.movilla@altran.es](mailto:jesus.movilla@altran.es) wrote:
> 
> > Hi Andrea
> > 
> > Regarding #1. Next I include the backtrace. Just to point out that  
> > "chef-client version" in the node shows "Starting Chef Run (Version  
> > 0.9.18)". However Chef server is 0.10.4
> 
> That's your problem then, you need to upgrade the chef gem on your  
> client. 0.9.x didn't know about environments.

---

<div class="post-metadata">

**Author:** ![Jesus\_M\_Movilla](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@Jesus\_M\_Movilla](https://discourse.chef.io/u/Jesus_M_Movilla)\
**Post date:** [April 11, 2012, 9:28am UTC](https://discourse.chef.io/t/recipe-application-does-not-work-because-chef-envronment-is-not-defined/2654/6 "2012-04-11T09:28:37Z")

</div>

Ok

I have been a repo names "lucid-0.10". I guess this is the good one.

I will try again  
Thanks!

On Wed, Apr 11, 2012 at 11:19 AM, Jesus M. Movilla  
[jesus.movilla@altran.es](mailto:jesus.movilla@altran.es)wrote:

> Hi Andrea
> 
> Thanks!
> 
> I have followed the instructions from this page to do it. The node is  
> Ubuntu 10.10
> 
> Debian packaging; the service will be stopped and started for you.  
> sudo apt-get update  
> sudo apt-install chef
> 
> and this is what it hapens:
> 
> root@sdcnode01:~# sudo apt-get install chef  
> Leyendo lista de paquetes... Hecho  
> Creando Ã¡rbol de dependencias  
> Leyendo la informaciÃ³n de estado... Hecho  
> chef ya estÃ¡ en su versiÃ³n mÃ¡s reciente.  
> 0 actualizados, 0 se instalarÃ¡n, 0 para eliminar y 92 no actualizados.
> 
> If I type chef-client, the version is not upgraded... (
> 
> [Wed, 11 Apr 2012 11:11:03 +0200] INFO: Starting Chef Run (Version 0.9.18)
> 
> Typing apt-get update, the following opscode repos appear in the full list  
> of repos:
> 
> Obj [http://apt.opscode.com](http://apt.opscode.com) lucid Release.gpg  
> Ign [http://apt.opscode.com/](http://apt.opscode.com/) lucid/main Translation-en  
> Ign [http://apt.opscode.com/](http://apt.opscode.com/) lucid/main Translation-es  
> Obj [http://apt.opscode.com](http://apt.opscode.com) lucid Release  
> Ign [http://apt.opscode.com](http://apt.opscode.com) lucid/main amd64 Packages  
> Obj [http://apt.opscode.com](http://apt.opscode.com) lucid/main amd64 Packages
> 
> What is missing to upgrade chef-client to 0.10?
> 
> Regards
> 
> On Wed, Apr 11, 2012 at 10:47 AM, Andrea Campi \<  
> [andrea.campi@zephirworks.com](mailto:andrea.campi@zephirworks.com)\> wrote:
> 
> > On Wed, Apr 11, 2012 at 10:15 AM, Jesus M. Movilla  
> > [jesus.movilla@altran.es](mailto:jesus.movilla@altran.es) wrote:
> > 
> > > Hi Andrea
> > > 
> > > Regarding #1. Next I include the backtrace. Just to point out that  
> > > "chef-client version" in the node shows "Starting Chef Run (Version  
> > > 0.9.18)". However Chef server is 0.10.4
> > 
> > That's your problem then, you need to upgrade the chef gem on your  
> > client. 0.9.x didn't know about environments.

---

<div class="post-metadata">

**Author:** ![Jesus\_M\_Movilla](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@Jesus\_M\_Movilla](https://discourse.chef.io/u/Jesus_M_Movilla)\
**Post date:** [April 11, 2012, 9:49am UTC](https://discourse.chef.io/t/recipe-application-does-not-work-because-chef-envronment-is-not-defined/2654/7 "2012-04-11T09:49:34Z")

</div>

Andrea,

The last problem has been solved. It was a problem of pointing at  
"lucid-0.10" repo instead of "lucid". Thaks a lot !

One question about application cookbok. Where is the war to be installed  
defined?.

I mean, I need to tell in some place the name of the war, the location....

According to recipe\* java\_webapp.rb\* it seems that the corresponding  
databag is the right place but there is nothing related to war in  
java\_app.json.

Where and how can define the war attribute?

Now the recipe fails at this line:

\*:war =\>  
"#{app['deploy\_to']}/releases/#{app['war'][node.chef\_environment]['checksum']}.war"  
\*

the backtrace

_undefined method `[]' for nil:NilClass* */var/cache/chef/cookbooks/application/recipes/java_webapp.rb:104:in `from\_file'_  
/usr/lib/ruby/vendor\_ruby/chef/mixin/recipe\_definition\_dsl\_core.rb:69:in  
`instance_eval' /usr/lib/ruby/vendor_ruby/chef/mixin/recipe_definition_dsl_core.rb:69:in `method\_missing'  
/var/cache/chef/cookbooks/application/recipes/java\_webapp.rb:103:in  
`from_file' /usr/lib/ruby/vendor_ruby/chef/cookbook_version.rb:578:in `load\_recipe'  
/usr/lib/ruby/vendor\_ruby/chef/mixin/language\_include\_recipe.rb:40:in  
`include_recipe' /usr/lib/ruby/vendor_ruby/chef/mixin/language_include_recipe.rb:27:in `each'  
/usr/lib/ruby/vendor\_ruby/chef/mixin/language\_include\_recipe.rb:27:in  
`include_recipe' /var/cache/chef/cookbooks/application/recipes/default.rb:31:in `from\_file'  
/var/cache/chef/cookbooks/application/recipes/default.rb:28:in `each' /var/cache/chef/cookbooks/application/recipes/default.rb:28:in `from\_file'  
/var/cache/chef/cookbooks/application/recipes/default.rb:25:in `each' /var/cache/chef/cookbooks/application/recipes/default.rb:25:in `from\_file'  
/usr/lib/ruby/vendor\_ruby/chef/search/query.rb:44:in `call' /usr/lib/ruby/vendor_ruby/chef/search/query.rb:44:in `search'  
/usr/lib/ruby/vendor\_ruby/chef/search/query.rb:44:in `each' /usr/lib/ruby/vendor_ruby/chef/search/query.rb:44:in `search'  
/usr/lib/ruby/vendor\_ruby/chef/mixin/language.rb:133:in `search' /var/cache/chef/cookbooks/application/recipes/default.rb:21:in `from\_file'  
/usr/lib/ruby/vendor\_ruby/chef/cookbook\_version.rb:578:in `load_recipe' /usr/lib/ruby/vendor_ruby/chef/mixin/language_include_recipe.rb:40:in `include\_recipe'  
/usr/lib/ruby/vendor\_ruby/chef/mixin/language\_include\_recipe.rb:27:in  
`each' /usr/lib/ruby/vendor_ruby/chef/mixin/language_include_recipe.rb:27:in `include\_recipe'  
/usr/lib/ruby/vendor\_ruby/chef/run\_context.rb:72:in `load' /usr/lib/ruby/vendor_ruby/chef/run_context.rb:69:in `each'  
/usr/lib/ruby/vendor\_ruby/chef/run\_context.rb:69:in `load' /usr/lib/ruby/vendor_ruby/chef/client.rb:195:in `setup\_run\_context'  
/usr/lib/ruby/vendor\_ruby/chef/client.rb:159:in `run' /usr/lib/ruby/vendor_ruby/chef/application/client.rb:239:in `run\_application'  
/usr/lib/ruby/vendor\_ruby/chef/application/client.rb:229:in `loop' /usr/lib/ruby/vendor_ruby/chef/application/client.rb:229:in `run\_application'  
/usr/lib/ruby/vendor\_ruby/chef/application.rb:67:in `run' /usr/bin/chef-client:25 [Wed, 11 Apr 2012 11:39:20 +0200] FATAL: Stacktrace dumped to /var/cache/chef/chef-stacktrace.out [Wed, 11 Apr 2012 11:39:20 +0200] DEBUG: NoMethodError: undefined method `' for nil:NilClass  
/var/cache/chef/cookbooks/application/recipes/java\_webapp.rb:104:in  
`from_file' /usr/lib/ruby/vendor_ruby/chef/mixin/recipe_definition_dsl_core.rb:69:in `instance\_eval'  
/usr/lib/ruby/vendor\_ruby/chef/mixin/recipe\_definition\_dsl\_core.rb:69:in  
`method_missing' /var/cache/chef/cookbooks/application/recipes/java_webapp.rb:103:in `from\_file'  
/usr/lib/ruby/vendor\_ruby/chef/cookbook\_version.rb:578:in `load_recipe' /usr/lib/ruby/vendor_ruby/chef/mixin/language_include_recipe.rb:40:in `include\_recipe'  
/usr/lib/ruby/vendor\_ruby/chef/mixin/language\_include\_recipe.rb:27:in `each' /usr/lib/ruby/vendor_ruby/chef/mixin/language_include_recipe.rb:27:in `include\_recipe'  
/var/cache/chef/cookbooks/application/recipes/default.rb:31:in `from_file' /var/cache/chef/cookbooks/application/recipes/default.rb:28:in `each'  
/var/cache/chef/cookbooks/application/recipes/default.rb:28:in `from_file' /var/cache/chef/cookbooks/application/recipes/default.rb:25:in `each'  
/var/cache/chef/cookbooks/application/recipes/default.rb:25:in `from_file' /usr/lib/ruby/vendor_ruby/chef/search/query.rb:44:in `call'  
/usr/lib/ruby/vendor\_ruby/chef/search/query.rb:44:in `search' /usr/lib/ruby/vendor_ruby/chef/search/query.rb:44:in `each'  
/usr/lib/ruby/vendor\_ruby/chef/search/query.rb:44:in `search' /usr/lib/ruby/vendor_ruby/chef/mixin/language.rb:133:in `search'  
/var/cache/chef/cookbooks/application/recipes/default.rb:21:in `from_file' /usr/lib/ruby/vendor_ruby/chef/cookbook_version.rb:578:in `load\_recipe'  
/usr/lib/ruby/vendor\_ruby/chef/mixin/language\_include\_recipe.rb:40:in  
`include_recipe' /usr/lib/ruby/vendor_ruby/chef/mixin/language_include_recipe.rb:27:in `each'  
/usr/lib/ruby/vendor\_ruby/chef/mixin/language\_include\_recipe.rb:27:in  
`include_recipe' /usr/lib/ruby/vendor_ruby/chef/run_context.rb:72:in `load'  
/usr/lib/ruby/vendor\_ruby/chef/run\_context.rb:69:in `each' /usr/lib/ruby/vendor_ruby/chef/run_context.rb:69:in `load'  
/usr/lib/ruby/vendor\_ruby/chef/client.rb:195:in `setup_run_context' /usr/lib/ruby/vendor_ruby/chef/client.rb:159:in `run'  
/usr/lib/ruby/vendor\_ruby/chef/application/client.rb:239:in  
`run_application' /usr/lib/ruby/vendor_ruby/chef/application/client.rb:229:in `loop'  
/usr/lib/ruby/vendor\_ruby/chef/application/client.rb:229:in  
`run_application' /usr/lib/ruby/vendor_ruby/chef/application.rb:67:in `run'  
/usr/bin/chef-client:25  
[Wed, 11 Apr 2012 11:39:20 +0200] FATAL: NoMethodError: undefined method  
`' for nil:NilClass

I guees beause \*app['war'] \*is not defined anywhere. Any hint?

Regards

On Wed, Apr 11, 2012 at 11:28 AM, Jesus M. Movilla  
[jesus.movilla@altran.es](mailto:jesus.movilla@altran.es)wrote:

> Ok
> 
> I have been a repo names "lucid-0.10". I guess this is the good one.
> 
> I will try again  
> Thanks!
> 
> On Wed, Apr 11, 2012 at 11:19 AM, Jesus M. Movilla \<  
> jesus.movilla@altran.es\> wrote:
> 
> > Hi Andrea
> > 
> > Thanks!
> > 
> > I have followed the instructions from this page to do it. The node is  
> > Ubuntu 10.10
> > 
> > Debian packaging; the service will be stopped and started for you.  
> > sudo apt-get update  
> > sudo apt-install chef
> > 
> > and this is what it hapens:
> > 
> > root@sdcnode01:~# sudo apt-get install chef  
> > Leyendo lista de paquetes... Hecho  
> > Creando Ã¡rbol de dependencias  
> > Leyendo la informaciÃ³n de estado... Hecho  
> > chef ya estÃ¡ en su versiÃ³n mÃ¡s reciente.  
> > 0 actualizados, 0 se instalarÃ¡n, 0 para eliminar y 92 no actualizados.
> > 
> > If I type chef-client, the version is not upgraded... (
> > 
> > [Wed, 11 Apr 2012 11:11:03 +0200] INFO: Starting Chef Run (Version 0.9.18)
> > 
> > Typing apt-get update, the following opscode repos appear in the full  
> > list of repos:
> > 
> > Obj [http://apt.opscode.com](http://apt.opscode.com) lucid Release.gpg  
> > Ign [http://apt.opscode.com/](http://apt.opscode.com/) lucid/main Translation-en  
> > Ign [http://apt.opscode.com/](http://apt.opscode.com/) lucid/main Translation-es  
> > Obj [http://apt.opscode.com](http://apt.opscode.com) lucid Release  
> > Ign [http://apt.opscode.com](http://apt.opscode.com) lucid/main amd64 Packages  
> > Obj [http://apt.opscode.com](http://apt.opscode.com) lucid/main amd64 Packages
> > 
> > What is missing to upgrade chef-client to 0.10?
> > 
> > Regards
> > 
> > On Wed, Apr 11, 2012 at 10:47 AM, Andrea Campi \<  
> > [andrea.campi@zephirworks.com](mailto:andrea.campi@zephirworks.com)\> wrote:
> > 
> > > On Wed, Apr 11, 2012 at 10:15 AM, Jesus M. Movilla  
> > > [jesus.movilla@altran.es](mailto:jesus.movilla@altran.es) wrote:
> > > 
> > > > Hi Andrea
> > > > 
> > > > Regarding #1. Next I include the backtrace. Just to point out that  
> > > > "chef-client version" in the node shows "Starting Chef Run (Version  
> > > > 0.9.18)". However Chef server is 0.10.4
> > > 
> > > That's your problem then, you need to upgrade the chef gem on your  
> > > client. 0.9.x didn't know about environments.

---

<div class="post-metadata">

**Author:** ![Andrea\_Campi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/andrea_campi/32/514_2.png) [@Andrea\_Campi](https://discourse.chef.io/u/Andrea_Campi)\
**Post date:** [April 11, 2012, 10:40am UTC](https://discourse.chef.io/t/recipe-application-does-not-work-because-chef-envronment-is-not-defined/2654/8 "2012-04-11T10:40:45Z")

</div>

On Wed, Apr 11, 2012 at 11:49 AM, Jesus M. Movilla  
[jesus.movilla@altran.es](mailto:jesus.movilla@altran.es)wrote:

> Andrea,
> 
> The last problem has been solved. It was a problem of pointing at  
> "lucid-0.10" repo instead of "lucid". Thaks a lot !
> 
> One question about application cookbok. Where is the war to be installed  
> defined?.
> 
> I mean, I need to tell in some place the name of the war, the location....

You should have an entry in your data bag like this:

"war": {  
"\_default": {  
"source": "[http://example.com/path/to/your/app.war](http://example.com/path/to/your/app.war)",  
"checksum": "SHA1 of the war file"  
},  
"production": {  
"source": "[http://example.com/path/to/your/app.war](http://example.com/path/to/your/app.war)",  
"checksum": "SHA1 of the war file"  
}  
}

---

<div class="post-metadata">

**Author:** ![Jesus\_M\_Movilla](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@Jesus\_M\_Movilla](https://discourse.chef.io/u/Jesus_M_Movilla)\
**Post date:** [April 11, 2012, 12:30pm UTC](https://discourse.chef.io/t/recipe-application-does-not-work-because-chef-envronment-is-not-defined/2654/9 "2012-04-11T12:30:17Z")

</div>

Andrea,

We keep ong going on 🙂

Now there is a problem when installing curl=7.19.5-1ubuntu2 which is  
specified in the java\_app.json in "packages". What is this packe for?, Can  
it be removed from the data\_bag?. The OS of the node is Ubuntu 10.10

Regards!

Generated at Wed Apr 11 14:27:24 +0200 2012  
Chef::Exceptions::Exec: package[curl] (application::java\_webapp line 32)  
had an error: Chef::Exceptions::Exec: apt-get -q -y install  
curl=7.19.5-1ubuntu2 returned 100, expected 0  
/usr/lib/ruby/vendor\_ruby/chef/mixin/command.rb:127:in  
`handle_command_failures' /usr/lib/ruby/vendor_ruby/chef/mixin/command.rb:74:in `run\_command'  
/usr/lib/ruby/vendor\_ruby/chef/mixin/command.rb:142:in  
`run_command_with_systems_locale' /usr/lib/ruby/vendor_ruby/chef/provider/package/apt.rb:92:in `install\_package'  
/usr/lib/ruby/vendor\_ruby/chef/provider/package.rb:60:in `action_install' /usr/lib/ruby/vendor_ruby/chef/resource.rb:440:in `send'  
/usr/lib/ruby/vendor\_ruby/chef/resource.rb:440:in `run_action' /usr/lib/ruby/vendor_ruby/chef/runner.rb:45:in `run\_action'  
/usr/lib/ruby/vendor\_ruby/chef/runner.rb:81:in `converge' /usr/lib/ruby/vendor_ruby/chef/runner.rb:81:in `each'  
/usr/lib/ruby/vendor\_ruby/chef/runner.rb:81:in `converge' /usr/lib/ruby/vendor_ruby/chef/resource_collection.rb:94:in `execute\_each\_resource'  
/usr/lib/ruby/vendor\_ruby/chef/resource\_collection/stepable\_iterator.rb:116:in  
`call' /usr/lib/ruby/vendor_ruby/chef/resource_collection/stepable_iterator.rb:116:in `call\_iterator\_block'  
/usr/lib/ruby/vendor\_ruby/chef/resource\_collection/stepable\_iterator.rb:85:in  
`step' /usr/lib/ruby/vendor_ruby/chef/resource_collection/stepable_iterator.rb:104:in `iterate'  
/usr/lib/ruby/vendor\_ruby/chef/resource\_collection/stepable\_iterator.rb:55:in  
`each_with_index' /usr/lib/ruby/vendor_ruby/chef/resource_collection.rb:92:in `execute\_each\_resource'  
/usr/lib/ruby/vendor\_ruby/chef/runner.rb:76:in `converge' /usr/lib/ruby/vendor_ruby/chef/client.rb:312:in `converge'  
/usr/lib/ruby/vendor\_ruby/chef/client.rb:160:in `run' /usr/lib/ruby/vendor_ruby/chef/application/client.rb:239:in `run\_application'  
/usr/lib/ruby/vendor\_ruby/chef/application/client.rb:229:in `loop' /usr/lib/ruby/vendor_ruby/chef/application/client.rb:229:in `run\_application'  
/usr/lib/ruby/vendor\_ruby/chef/application.rb:67:in `run'  
/usr/bin/chef-client:25

On Wed, Apr 11, 2012 at 12:40 PM, Andrea Campi \<[andrea.campi@zephirworks.com](mailto:andrea.campi@zephirworks.com)

> wrote:

> On Wed, Apr 11, 2012 at 11:49 AM, Jesus M. Movilla \<  
> jesus.movilla@altran.es\> wrote:
> 
> > Andrea,
> > 
> > The last problem has been solved. It was a problem of pointing at  
> > "lucid-0.10" repo instead of "lucid". Thaks a lot !
> > 
> > One question about application cookbok. Where is the war to be installed  
> > defined?.
> > 
> > I mean, I need to tell in some place the name of the war, the location....
> 
> You should have an entry in your data bag like this:
> 
> "war": {  
> "\_default": {  
> "source": "[http://example.com/path/to/your/app.war](http://example.com/path/to/your/app.war)",  
> "checksum": "SHA1 of the war file"  
> },  
> "production": {  
> "source": "[http://example.com/path/to/your/app.war](http://example.com/path/to/your/app.war)",  
> "checksum": "SHA1 of the war file"  
> }  
> }

---

<div class="post-metadata">

**Author:** ![Andrea\_Campi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/andrea_campi/32/514_2.png) [@Andrea\_Campi](https://discourse.chef.io/u/Andrea_Campi)\
**Post date:** [April 11, 2012, 1:02pm UTC](https://discourse.chef.io/t/recipe-application-does-not-work-because-chef-envronment-is-not-defined/2654/10 "2012-04-11T13:02:19Z")

</div>

On Wed, Apr 11, 2012 at 2:30 PM, Jesus M. Movilla  
[jesus.movilla@altran.es](mailto:jesus.movilla@altran.es) wrote:

> Andrea,
> 
> We keep ong going on 🙂
> 
> Now there is a problem when installing curl=7.19.5-1ubuntu2 which is  
> specified in the java\_app.json in "packages". What is this packe for?, Can  
> it be removed from the data\_bag?. The OS of the node is Ubuntu 10.10

That data bag is just an example; get rid of that package if you don't need it.  
If OTOH your app needs any package installed, that's where you should  
specify it—just make sure apt can find it and you should be good to go  
🙂

---

<div class="post-metadata">

**Author:** ![Jesus\_M\_Movilla](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@Jesus\_M\_Movilla](https://discourse.chef.io/u/Jesus_M_Movilla)\
**Post date:** [April 11, 2012, 1:19pm UTC](https://discourse.chef.io/t/recipe-application-does-not-work-because-chef-envronment-is-not-defined/2654/11 "2012-04-11T13:19:25Z")

</div>

Hi Adrea, all

Thanks for your previous reply.

I decided to remove the content of the attribute "packages" (as you said)  
to avoid the above problem and I got finnally the cookbook executed without  
errors but I can not see any tomcat installed. All that I can see is an  
structure of directories that have been created in the directory specified  
in "deploy\_to" all of them empty except releases that contains the war  
specified in "source" but with the name that has been specified in  
"checksum"...

I guess something is wrong... What is supposed to do the java\_webapp.rb and  
the corresponding java\_app.json recipe and data\_bag?, Should not end this  
story with a war deployed in a tomcat?

Thanks a lot!

On Wed, Apr 11, 2012 at 2:30 PM, Jesus M. Movilla  
[jesus.movilla@altran.es](mailto:jesus.movilla@altran.es)wrote:

> Andrea,
> 
> We keep ong going on 🙂
> 
> Now there is a problem when installing curl=7.19.5-1ubuntu2 which is  
> specified in the java\_app.json in "packages". What is this packe for?, Can  
> it be removed from the data\_bag?. The OS of the node is Ubuntu 10.10
> 
> Regards!
> 
> Generated at Wed Apr 11 14:27:24 +0200 2012  
> Chef::Exceptions::Exec: package[curl] (application::java\_webapp line 32)  
> had an error: Chef::Exceptions::Exec: apt-get -q -y install  
> curl=7.19.5-1ubuntu2 returned 100, expected 0  
> /usr/lib/ruby/vendor\_ruby/chef/mixin/command.rb:127:in  
> `handle_command_failures' /usr/lib/ruby/vendor_ruby/chef/mixin/command.rb:74:in `run\_command'  
> /usr/lib/ruby/vendor\_ruby/chef/mixin/command.rb:142:in  
> `run_command_with_systems_locale' /usr/lib/ruby/vendor_ruby/chef/provider/package/apt.rb:92:in `install\_package'  
> /usr/lib/ruby/vendor\_ruby/chef/provider/package.rb:60:in `action_install' /usr/lib/ruby/vendor_ruby/chef/resource.rb:440:in `send'  
> /usr/lib/ruby/vendor\_ruby/chef/resource.rb:440:in `run_action' /usr/lib/ruby/vendor_ruby/chef/runner.rb:45:in `run\_action'  
> /usr/lib/ruby/vendor\_ruby/chef/runner.rb:81:in `converge' /usr/lib/ruby/vendor_ruby/chef/runner.rb:81:in `each'  
> /usr/lib/ruby/vendor\_ruby/chef/runner.rb:81:in `converge' /usr/lib/ruby/vendor_ruby/chef/resource_collection.rb:94:in `execute\_each\_resource'  
> /usr/lib/ruby/vendor\_ruby/chef/resource\_collection/stepable\_iterator.rb:116:in  
> `call' /usr/lib/ruby/vendor_ruby/chef/resource_collection/stepable_iterator.rb:116:in `call\_iterator\_block'  
> /usr/lib/ruby/vendor\_ruby/chef/resource\_collection/stepable\_iterator.rb:85:in  
> `step' /usr/lib/ruby/vendor_ruby/chef/resource_collection/stepable_iterator.rb:104:in `iterate'  
> /usr/lib/ruby/vendor\_ruby/chef/resource\_collection/stepable\_iterator.rb:55:in  
> `each_with_index' /usr/lib/ruby/vendor_ruby/chef/resource_collection.rb:92:in `execute\_each\_resource'  
> /usr/lib/ruby/vendor\_ruby/chef/runner.rb:76:in `converge' /usr/lib/ruby/vendor_ruby/chef/client.rb:312:in `converge'  
> /usr/lib/ruby/vendor\_ruby/chef/client.rb:160:in `run' /usr/lib/ruby/vendor_ruby/chef/application/client.rb:239:in `run\_application'  
> /usr/lib/ruby/vendor\_ruby/chef/application/client.rb:229:in `loop' /usr/lib/ruby/vendor_ruby/chef/application/client.rb:229:in `run\_application'  
> /usr/lib/ruby/vendor\_ruby/chef/application.rb:67:in `run'  
> /usr/bin/chef-client:25
> 
> On Wed, Apr 11, 2012 at 12:40 PM, Andrea Campi \<  
> [andrea.campi@zephirworks.com](mailto:andrea.campi@zephirworks.com)\> wrote:
> 
> > On Wed, Apr 11, 2012 at 11:49 AM, Jesus M. Movilla \<  
> > jesus.movilla@altran.es\> wrote:
> > 
> > > Andrea,
> > > 
> > > The last problem has been solved. It was a problem of pointing at  
> > > "lucid-0.10" repo instead of "lucid". Thaks a lot !
> > > 
> > > One question about application cookbok. Where is the war to be installed  
> > > defined?.
> > > 
> > > I mean, I need to tell in some place the name of the war, the  
> > > location....
> > 
> > You should have an entry in your data bag like this:
> > 
> > "war": {  
> > "\_default": {  
> > "source": "[http://example.com/path/to/your/app.war](http://example.com/path/to/your/app.war)",  
> > "checksum": "SHA1 of the war file"  
> > },  
> > "production": {  
> > "source": "[http://example.com/path/to/your/app.war](http://example.com/path/to/your/app.war)",  
> > "checksum": "SHA1 of the war file"  
> > }  
> > }

---

<div class="post-metadata">

**Author:** ![Andrea\_Campi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/andrea_campi/32/514_2.png) [@Andrea\_Campi](https://discourse.chef.io/u/Andrea_Campi)\
**Post date:** [April 11, 2012, 1:37pm UTC](https://discourse.chef.io/t/recipe-application-does-not-work-because-chef-envronment-is-not-defined/2654/12 "2012-04-11T13:37:41Z")

</div>

On Wed, Apr 11, 2012 at 3:19 PM, Jesus M. Movilla  
[jesus.movilla@altran.es](mailto:jesus.movilla@altran.es) wrote:

> Hi Adrea, all
> 
> Thanks for your previous reply.
> 
> I decided to remove the content of the attribute "packages" (as you said) to  
> avoid the above problem and I got finnally the cookbook executed without  
> errors but I can not see any tomcat installed. All that I can see is an  
> structure of directories that have been created in the directory specified  
> in "deploy\_to" all of them empty except releases that contains the war  
> specified in "source" but with the name that has been specified in  
> "checksum"...
> 
> I guess something is wrong... What is supposed to do the java\_webapp.rb and  
> the corresponding java\_app.json recipe and data\_bag?, Should not end this  
> story with a war deployed in a tomcat?

Does your data bag contain tomcat too?

"type": {  
"my\_app": [ \<— with your app name, of course  
"java\_webapp",  
"tomcat"  
]  
},

If so, you should also have a ROOT.xml file in your Tomcat context  
directory, and it should contain the name of your war file.

But since you say Tomcat was not installed, I supposed you don't. Try with that.

Andrea

---

<div class="post-metadata">

**Author:** ![Jesus\_M\_Movilla](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@Jesus\_M\_Movilla](https://discourse.chef.io/u/Jesus_M_Movilla)\
**Post date:** [April 12, 2012, 10:23am UTC](https://discourse.chef.io/t/recipe-application-does-not-work-because-chef-envronment-is-not-defined/2654/13 "2012-04-12T10:23:27Z")

</div>

Hi Andrea

You are completely right. It was missing "tomcat" cookbook in the type  
attribute of the databag.

Everything worked fine excepto with the tomcat cookbook. The process of  
starting tomcat gives back the following error.

[Thu, 12 Apr 2012 12:18:34 +0200] DEBUG: service[tomcat] runlevel 5, action  
start, priority 92  
[Thu, 12 Apr 2012 12:18:34 +0200] DEBUG: Executing /usr/sbin/invoke-rc.d  
tomcat6 start  
[Thu, 12 Apr 2012 12:18:39 +0200] DEBUG: ---- Begin output of  
/usr/sbin/invoke-rc.d tomcat6 start ----  
[Thu, 12 Apr 2012 12:18:39 +0200] DEBUG: STDOUT: \* Starting Tomcat servlet  
engine tomcat6  
...fail!  
[Thu, 12 Apr 2012 12:18:39 +0200] DEBUG: STDERR: invoke-rc.d: initscript  
tomcat6, action "start" failed.  
[Thu, 12 Apr 2012 12:18:39 +0200] DEBUG: ---- End output of  
/usr/sbin/invoke-rc.d tomcat6 start ----  
[Thu, 12 Apr 2012 12:18:39 +0200] DEBUG: Ran /usr/sbin/invoke-rc.d tomcat6  
start returned 1  
[Thu, 12 Apr 2012 12:18:39 +0200] ERROR: service[tomcat] (tomcat::default  
line 42) has had an error  
[Thu, 12 Apr 2012 12:18:39 +0200] ERROR: service[tomcat]  
(/var/cache/chef/cookbooks/tomcat/recipes/default.rb:42:in `from\_file') had  
an error:  
service[tomcat] (tomcat::default line 42) had an error:  
Chef::Exceptions::Exec: /usr/sbin/invoke-rc.d tomcat6 start returned 1,  
expected 0  
---- Begin output of /usr/sbin/invoke-rc.d tomcat6 start ----  
STDOUT: \* Starting Tomcat servlet engine tomcat6  
...fail!STDERR: invoke-rc.d: initscript tomcat6, action "start" failed.  
---- End output of /usr/sbin/invoke-rc.d tomcat6 start ----

/usr/lib/ruby/vendor\_ruby/chef/mixin/command.rb:127:in  
`handle_command_failures' /usr/lib/ruby/vendor_ruby/chef/mixin/command.rb:74:in `run\_command'  
/usr/lib/ruby/vendor\_ruby/chef/provider/service/init.rb:37:in  
`start_service' /usr/lib/ruby/vendor_ruby/chef/provider/service.rb:57:in `action\_start'  
/usr/lib/ruby/vendor\_ruby/chef/resource.rb:440:in `send' /usr/lib/ruby/vendor_ruby/chef/resource.rb:440:in `run\_action'  
/usr/lib/ruby/vendor\_ruby/chef/runner.rb:45:in `run_action' /usr/lib/ruby/vendor_ruby/chef/runner.rb:81:in `converge'  
/usr/lib/ruby/vendor\_ruby/chef/runner.rb:81:in `each' /usr/lib/ruby/vendor_ruby/chef/runner.rb:81:in `converge'  
/usr/lib/ruby/vendor\_ruby/chef/resource\_collection.rb:94:in  
`execute_each_resource' /usr/lib/ruby/vendor_ruby/chef/resource_collection/stepable_iterator.rb:116:in `call'  
/usr/lib/ruby/vendor\_ruby/chef/resource\_collection/stepable\_iterator.rb:116:in  
`call_iterator_block' /usr/lib/ruby/vendor_ruby/chef/resource_collection/stepable_iterator.rb:85:in `step'  
/usr/lib/ruby/vendor\_ruby/chef/resource\_collection/stepable\_iterator.rb:104:in  
`iterate' /usr/lib/ruby/vendor_ruby/chef/resource_collection/stepable_iterator.rb:55:in `each\_with\_index'  
/usr/lib/ruby/vendor\_ruby/chef/resource\_collection.rb:92:in  
`execute_each_resource' /usr/lib/ruby/vendor_ruby/chef/runner.rb:76:in `converge'  
/usr/lib/ruby/vendor\_ruby/chef/client.rb:312:in `converge' /usr/lib/ruby/vendor_ruby/chef/client.rb:160:in `run'  
/usr/lib/ruby/vendor\_ruby/chef/application/client.rb:239:in  
`run_application' /usr/lib/ruby/vendor_ruby/chef/application/client.rb:229:in `loop'  
/usr/lib/ruby/vendor\_ruby/chef/application/client.rb:229:in  
`run_application' /usr/lib/ruby/vendor_ruby/chef/application.rb:67:in `run'  
/usr/bin/chef-client:25  
[Thu, 12 Apr 2012 12:18:39 +0200] ERROR: Running exception handlers  
[Thu, 12 Apr 2012 12:18:39 +0200] FATAL: Saving node information to  
/var/cache/chef/failed-run-data.json  
[Thu, 12 Apr 2012 12:18:39 +0200] ERROR: Exception handlers complete  
[Thu, 12 Apr 2012 12:18:39 +0200] DEBUG: Re-raising exception:  
Chef::Exceptions::Exec - service[tomcat] (tomcat::default line 42) had an  
error: Chef::Exceptions::Exec: /usr/sbin/invoke-rc.d tomcat6 start returned  
1, expected 0  
---- Begin output of /usr/sbin/invoke-rc.d tomcat6 start ----  
STDOUT: \* Starting Tomcat servlet engine tomcat6  
...fail!STDERR: invoke-rc.d: initscript tomcat6, action "start" failed.  
---- End output of /usr/sbin/invoke-rc.d tomcat6 start ----

/usr/lib/ruby/vendor\_ruby/chef/mixin/command.rb:127:in  
`handle_command_failures' /usr/lib/ruby/vendor_ruby/chef/mixin/command.rb:74:in `run\_command'  
/usr/lib/ruby/vendor\_ruby/chef/provider/service/init.rb:37:in  
`start_service' /usr/lib/ruby/vendor_ruby/chef/provider/service.rb:57:in `action\_start'  
/usr/lib/ruby/vendor\_ruby/chef/resource.rb:440:in `send' /usr/lib/ruby/vendor_ruby/chef/resource.rb:440:in `run\_action'  
/usr/lib/ruby/vendor\_ruby/chef/runner.rb:45:in `run_action' /usr/lib/ruby/vendor_ruby/chef/runner.rb:81:in `converge'  
/usr/lib/ruby/vendor\_ruby/chef/runner.rb:81:in `each' /usr/lib/ruby/vendor_ruby/chef/runner.rb:81:in `converge'  
/usr/lib/ruby/vendor\_ruby/chef/resource\_collection.rb:94:in  
`execute\_each\_resource'

/usr/lib/ruby/vendor\_ruby/chef/resource\_collection/stepable\_iterator.rb:116:in  
`call'

/usr/lib/ruby/vendor\_ruby/chef/resource\_collection/stepable\_iterator.rb:116:in  
`call\_iterator\_block'

/usr/lib/ruby/vendor\_ruby/chef/resource\_collection/stepable\_iterator.rb:85:in  
`step'

/usr/lib/ruby/vendor\_ruby/chef/resource\_collection/stepable\_iterator.rb:104:in  
`iterate'

/usr/lib/ruby/vendor\_ruby/chef/resource\_collection/stepable\_iterator.rb:55:in  
`each_with_index' /usr/lib/ruby/vendor_ruby/chef/resource_collection.rb:92:in `execute\_each\_resource'  
/usr/lib/ruby/vendor\_ruby/chef/runner.rb:76:in `converge' /usr/lib/ruby/vendor_ruby/chef/client.rb:312:in `converge'  
/usr/lib/ruby/vendor\_ruby/chef/client.rb:160:in `run' /usr/lib/ruby/vendor_ruby/chef/application/client.rb:239:in `run\_application'  
/usr/lib/ruby/vendor\_ruby/chef/application/client.rb:229:in `loop' /usr/lib/ruby/vendor_ruby/chef/application/client.rb:229:in `run\_application'  
/usr/lib/ruby/vendor\_ruby/chef/application.rb:67:in `run'  
/usr/bin/chef-client:25  
[Thu, 12 Apr 2012 12:18:39 +0200] FATAL: Stacktrace dumped to  
/var/cache/chef/chef-stacktrace.out  
[Thu, 12 Apr 2012 12:18:39 +0200] DEBUG: Chef::Exceptions::Exec:  
service[tomcat] (tomcat::default line 42) had an error:  
Chef::Exceptions::Exec: /usr/sbin/invoke-rc.d tomcat6 start returned 1,  
expected 0  
---- Begin output of /usr/sbin/invoke-rc.d tomcat6 start ----  
STDOUT: \* Starting Tomcat servlet engine tomcat6  
...fail!STDERR: invoke-rc.d: initscript tomcat6, action "start" failed.  
---- End output of /usr/sbin/invoke-rc.d tomcat6 start ----

/usr/lib/ruby/vendor\_ruby/chef/mixin/command.rb:127:in  
`handle_command_failures' /usr/lib/ruby/vendor_ruby/chef/mixin/command.rb:74:in `run\_command'  
/usr/lib/ruby/vendor\_ruby/chef/provider/service/init.rb:37:in  
`start_service' /usr/lib/ruby/vendor_ruby/chef/provider/service.rb:57:in `action\_start'  
/usr/lib/ruby/vendor\_ruby/chef/resource.rb:440:in `send' /usr/lib/ruby/vendor_ruby/chef/resource.rb:440:in `run\_action'  
/usr/lib/ruby/vendor\_ruby/chef/runner.rb:45:in `run_action' /usr/lib/ruby/vendor_ruby/chef/runner.rb:81:in `converge'  
/usr/lib/ruby/vendor\_ruby/chef/runner.rb:81:in `each' /usr/lib/ruby/vendor_ruby/chef/runner.rb:81:in `converge'  
/usr/lib/ruby/vendor\_ruby/chef/resource\_collection.rb:94:in  
`execute_each_resource' /usr/lib/ruby/vendor_ruby/chef/resource_collection/stepable_iterator.rb:116:in `call'  
/usr/lib/ruby/vendor\_ruby/chef/resource\_collection/stepable\_iterator.rb:116:in  
`call_iterator_block' /usr/lib/ruby/vendor_ruby/chef/resource_collection/stepable_iterator.rb:85:in `step'  
/usr/lib/ruby/vendor\_ruby/chef/resource\_collection/stepable\_iterator.rb:104:in  
`iterate' /usr/lib/ruby/vendor_ruby/chef/resource_collection/stepable_iterator.rb:55:in `each\_with\_index'  
/usr/lib/ruby/vendor\_ruby/chef/resource\_collection.rb:92:in  
`execute_each_resource' /usr/lib/ruby/vendor_ruby/chef/runner.rb:76:in `converge'  
/usr/lib/ruby/vendor\_ruby/chef/client.rb:312:in `converge' /usr/lib/ruby/vendor_ruby/chef/client.rb:160:in `run'  
/usr/lib/ruby/vendor\_ruby/chef/application/client.rb:239:in  
`run_application' /usr/lib/ruby/vendor_ruby/chef/application/client.rb:229:in `loop'  
/usr/lib/ruby/vendor\_ruby/chef/application/client.rb:229:in  
`run_application' /usr/lib/ruby/vendor_ruby/chef/application.rb:67:in `run'  
/usr/bin/chef-client:25  
[Thu, 12 Apr 2012 12:18:39 +0200] FATAL: Chef::Exceptions::Exec:  
service[tomcat] (tomcat::default line 42) had an error:  
Chef::Exceptions::Exec: /usr/sbin/invoke-rc.d tomcat6 start returned 1,  
expected 0  
---- Begin output of /usr/sbin/invoke-rc.d tomcat6 start ----  
STDOUT: \* Starting Tomcat servlet engine tomcat6  
...fail!STDERR: invoke-rc.d: initscript tomcat6, action "start" failed.  
---- End output of /usr/sbin/invoke-rc.d tomcat6 start ----

However, the tomcat is up and running and the war application can be  
accessed at http://:8080/ since it is described in ROOT.xml

Should I start another issue with the tmcat cookbook or remain here?

Thanks a lot for your help!

On Wed, Apr 11, 2012 at 3:37 PM, Andrea Campi  
[andrea.campi@zephirworks.com](mailto:andrea.campi@zephirworks.com)wrote:

> On Wed, Apr 11, 2012 at 3:19 PM, Jesus M. Movilla  
> [jesus.movilla@altran.es](mailto:jesus.movilla@altran.es) wrote:
> 
> > Hi Adrea, all
> > 
> > Thanks for your previous reply.
> > 
> > I decided to remove the content of the attribute "packages" (as you  
> > said) to  
> > avoid the above problem and I got finnally the cookbook executed without  
> > errors but I can not see any tomcat installed. All that I can see is an  
> > structure of directories that have been created in the directory  
> > specified  
> > in "deploy\_to" all of them empty except releases that contains the war  
> > specified in "source" but with the name that has been specified in  
> > "checksum"...
> > 
> > I guess something is wrong... What is supposed to do the java\_webapp.rb  
> > and  
> > the corresponding java\_app.json recipe and data\_bag?, Should not end this  
> > story with a war deployed in a tomcat?
> 
> Does your data bag contain tomcat too?
> 
> "type": {  
> "my\_app": [ \<— with your app name, of course  
> "java\_webapp",  
> "tomcat"  
> ]  
> },
> 
> If so, you should also have a ROOT.xml file in your Tomcat context  
> directory, and it should contain the name of your war file.
> 
> But since you say Tomcat was not installed, I supposed you don't. Try with  
> that.
> 
> Andrea

---

<div class="post-metadata">

**Author:** ![Andrea\_Campi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/andrea_campi/32/514_2.png) [@Andrea\_Campi](https://discourse.chef.io/u/Andrea_Campi)\
**Post date:** [April 12, 2012, 10:41am UTC](https://discourse.chef.io/t/recipe-application-does-not-work-because-chef-envronment-is-not-defined/2654/14 "2012-04-12T10:41:24Z")

</div>

On Thu, Apr 12, 2012 at 12:23 PM, Jesus M. Movilla  
[jesus.movilla@altran.es](mailto:jesus.movilla@altran.es) wrote:

> Hi Andrea
> 
> You are completely right. It was missing "tomcat" cookbook in the type  
> attribute of the databag.
> 
> Everything worked fine excepto with the tomcat cookbook. The process of  
> starting tomcat gives back the following error.
> 
> [Thu, 12 Apr 2012 12:18:34 +0200] DEBUG: service[tomcat] runlevel 5, action  
> start, priority 92  
> [Thu, 12 Apr 2012 12:18:34 +0200] DEBUG: Executing /usr/sbin/invoke-rc.d  
> tomcat6 start  
> [Thu, 12 Apr 2012 12:18:39 +0200] DEBUG: ---- Begin output of  
> /usr/sbin/invoke-rc.d tomcat6 start ----  
> [Thu, 12 Apr 2012 12:18:39 +0200] DEBUG: STDOUT: \* Starting Tomcat servlet  
> engine tomcat6  
> ...fail!

What happens if you run /usr/sbin/invoke-rc.d tomcat6 start manually?

Chances are it will fail there too; on some platforms/distros that's  
what happens when you start a service that is already started.  
Does the service "tomcat" declaration has this for your platform:

supports :status =\> true

?

Try to at least see it running cleanly once: stop tomcat, remove the  
war and its context, and do a chef-client run once; it should run  
cleanly and start tomcat.  
If it does, then as far as the application cookbook goes everything  
should be good.

Sorry, hard to help you much further without getting into a lot of details.
