# Problem deploying Java app

**URL:** <https://discourse.chef.io/t/problem-deploying-java-app/5871>\
**Category:** Chef Infra (archive)\
**Created:** [October 30, 2014, 7:24am UTC](https://discourse.chef.io/t/problem-deploying-java-app/5871 "2014-10-30T07:24:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oliver\_naaris](https://avatars.discourse-cdn.com/v4/letter/o/8edcca/32.png) [@oliver\_naaris](https://discourse.chef.io/u/oliver_naaris)\
**Post date:** [October 30, 2014, 7:24am UTC](https://discourse.chef.io/t/problem-deploying-java-app/5871/1 "2014-10-30T07:24:10Z")

</div>

Hi all!

I’ve been lurking in this mailing list for over a year and this is my first  
time posting here.  
Anyway, I was trying to setup a demo Java environment using this tutorial:  
[http://blog.jamie.ly/programming/2014/03/06/deploying-a-java-tomcat-application-via-chef.html](http://blog.jamie.ly/programming/2014/03/06/deploying-a-java-tomcat-application-via-chef.html)

The problem is that when I try to bootstrap the node I get the following  
errors.  
I’m also curious of how other companies are deploying Java apps - are you using  
the application\_java cookbook or some other mechanism?

# ================================================================================ Error executing action `before_deploy` on resource ’application\_java\_tomcat[jaxrs\_tutorial]’

## Chef::Exceptions::ResourceNotFound

Cannot find a resource matching service[tomcat] (did you define it first?)

## Cookbook Trace:

/var/chef/cache/cookbooks/application\_java/providers/tomcat.rb:48:in `block (2 levels) in class_from_file' /var/chef/cache/cookbooks/application_java/providers/tomcat.rb:46:in`block in  
class\_from\_file’  
/var/chef/cache/cookbooks/application/providers/default.rb:110:in `block (3 levels) in before_deploy' /var/chef/cache/cookbooks/application/providers/default.rb:109:in`each’  
/var/chef/cache/cookbooks/application/providers/default.rb:109:in `block (2  
levels) in before\_deploy’

## Resource Declaration:

# In /var/chef/cache/cookbooks/application/resources/default.rb

115: resource = super(resource\_name.to\_sym, [self.name](http://self.name), &block)  
116: break

## Compiled Resource:

# Declared in /var/chef/cache/cookbooks/application/resources/default.rb:115:in

`block in method\_missing’

application\_java\_tomcat(“jaxrs\_tutorial”) do  
action [:nothing]  
retries 0  
retry\_delay 2  
cookbook\_name "jaxrs\_tutorial"  
recipe\_name "default"  
type :tomcat  
restart\_command  
#Proc:0x000000035134e0@/var/chef/cache/cookbooks/application\_java/providers/tomcat.rb:27  
end

# ================================================================================ Error executing action `run` on resource ‘ruby\_block[jaxrs\_tutorial before\_deploy]’

## Chef::Exceptions::ResourceNotFound

application\_java\_tomcat[jaxrs\_tutorial] (jaxrs\_tutorial::default line 115) had  
an error: Chef::Exceptions::ResourceNotFound: Cannot find a resource matching  
service[tomcat] (did you define it first?)

## Cookbook Trace:

/var/chef/cache/cookbooks/application\_java/providers/tomcat.rb:48:in `block (2 levels) in class_from_file' /var/chef/cache/cookbooks/application_java/providers/tomcat.rb:46:in`block in  
class\_from\_file’  
/var/chef/cache/cookbooks/application/providers/default.rb:110:in `block (3 levels) in before_deploy' /var/chef/cache/cookbooks/application/providers/default.rb:109:in`each’  
/var/chef/cache/cookbooks/application/providers/default.rb:109:in `block (2  
levels) in before\_deploy’

## Resource Declaration:

# In /var/chef/cache/cookbooks/application/providers/default.rb

107: ruby\_block “#{new\_resource.name} before\_deploy” do  
108: block do  
109: new\_resource.sub\_resources.each do |resource|  
110: resource.run\_action :before\_deploy  
111: end  
112: callback(:before\_deploy, new\_resource.before\_deploy)  
113: end  
114: end  
115: end

## Compiled Resource:

# Declared in /var/chef/cache/cookbooks/application/providers/default.rb:107:in

`before\_deploy’

ruby\_block(“jaxrs\_tutorial before\_deploy”) do  
action "run"  
retries 0  
retry\_delay 2  
block\_name "jaxrs\_tutorial before\_deploy"  
cookbook\_name "jaxrs\_tutorial"  
block  
#Proc:0x00000003466538@/var/chef/cache/cookbooks/application/providers/default.rb:108  
end

Thanks and Regards,  
Oliver Naaris

---

<div class="post-metadata">

**Author:** ![Tyler](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/tyler/32/205_2.png) [@Tyler](https://discourse.chef.io/u/Tyler)\
**Post date:** [October 30, 2014, 5:08pm UTC](https://discourse.chef.io/t/problem-deploying-java-app/5871/2 "2014-10-30T17:08:28Z")

</div>

We wrote our own cookbook to install our java applications. Our opinion was that the open source cookbooks we could have used tried to do too much. So we wrote our own that was much more targeted to our needs.

I haven’t used any of the cookbooks referenced in that blog post. But the error below reference different line numbers than the latest version of the `application` cookbook on github - [GitHub - poise/application: A Chef cookbook to deploy applications.](https://github.com/poise/application) [https://github.com/poise/application](https://github.com/poise/application)

Can you update your cookbooks to the latest version and try again? Maybe there was a bug in an old version.

-T

> On Oct 30, 2014, at 12:24 AM, [oliver.naaris@gmail.com](mailto:oliver.naaris@gmail.com) wrote:
> 
> Hi all!
> 
> I've been lurking in this mailing list for over a year and this is my first  
> time posting here.  
> Anyway, I was trying to setup a demo Java environment using this tutorial:  
> [Deploying a Java Tomcat Application via Chef](http://blog.jamie.ly/programming/2014/03/06/deploying-a-java-tomcat-application-via-chef.html)
> 
> The problem is that when I try to bootstrap the node I get the following  
> errors.  
> I'm also curious of how other companies are deploying Java apps - are you using  
> the application\_java cookbook or some other mechanism?
> 
> # ================================================================================ Error executing action `before_deploy` on resource 'application\_java\_tomcat[jaxrs\_tutorial]'
> 
> ## Chef::Exceptions::ResourceNotFound
> 
> Cannot find a resource matching service[tomcat] (did you define it first?)
> 
> ## Cookbook Trace:
> 
> /var/chef/cache/cookbooks/application\_java/providers/tomcat.rb:48:in `block (2 levels) in class_from_file' /var/chef/cache/cookbooks/application_java/providers/tomcat.rb:46:in `block in  
> class\_from\_file'  
> /var/chef/cache/cookbooks/application/providers/default.rb:110:in `block (3 levels) in before_deploy' /var/chef/cache/cookbooks/application/providers/default.rb:109:in `each'  
> /var/chef/cache/cookbooks/application/providers/default.rb:109:in `block (2  
> levels) in before\_deploy'
> 
> ## Resource Declaration:
> 
> # In /var/chef/cache/cookbooks/application/resources/default.rb
> 
> 115: resource = super(resource\_name.to\_sym, self.name, &block)  
> 116: break
> 
> ## Compiled Resource:
> 
> # Declared in /var/chef/cache/cookbooks/application/resources/default.rb:115:in
> 
> `block in method\_missing'
> 
> application\_java\_tomcat("jaxrs\_tutorial") do  
> action [:nothing]  
> retries 0  
> retry\_delay 2  
> cookbook\_name "jaxrs\_tutorial"  
> recipe\_name "default"  
> type :tomcat  
> restart\_command  
> #Proc:0x000000035134e0@/var/chef/cache/cookbooks/application\_java/providers/tomcat.rb:27  
> end
> 
> # ================================================================================ Error executing action `run` on resource 'ruby\_block[jaxrs\_tutorial before\_deploy]'
> 
> ## Chef::Exceptions::ResourceNotFound
> 
> application\_java\_tomcat[jaxrs\_tutorial] (jaxrs\_tutorial::default line 115) had  
> an error: Chef::Exceptions::ResourceNotFound: Cannot find a resource matching  
> service[tomcat] (did you define it first?)
> 
> ## Cookbook Trace:
> 
> /var/chef/cache/cookbooks/application\_java/providers/tomcat.rb:48:in `block (2 levels) in class_from_file' /var/chef/cache/cookbooks/application_java/providers/tomcat.rb:46:in `block in  
> class\_from\_file'  
> /var/chef/cache/cookbooks/application/providers/default.rb:110:in `block (3 levels) in before_deploy' /var/chef/cache/cookbooks/application/providers/default.rb:109:in `each'  
> /var/chef/cache/cookbooks/application/providers/default.rb:109:in `block (2  
> levels) in before\_deploy'
> 
> ## Resource Declaration:
> 
> # In /var/chef/cache/cookbooks/application/providers/default.rb
> 
> 107: ruby\_block "#{new\_resource.name} before\_deploy" do  
> 108: block do  
> 109: new\_resource.sub\_resources.each do |resource|  
> 110: resource.run\_action :before\_deploy  
> 111: end  
> 112: callback(:before\_deploy, new\_resource.before\_deploy)  
> 113: end  
> 114: end  
> 115: end
> 
> ## Compiled Resource:
> 
> # Declared in /var/chef/cache/cookbooks/application/providers/default.rb:107:in
> 
> `before\_deploy'
> 
> ruby\_block("jaxrs\_tutorial before\_deploy") do  
> action "run"  
> retries 0  
> retry\_delay 2  
> block\_name "jaxrs\_tutorial before\_deploy"  
> cookbook\_name "jaxrs\_tutorial"  
> block  
> #Proc:0x00000003466538@/var/chef/cache/cookbooks/application/providers/default.rb:108  
> end
> 
> Thanks and Regards,  
> Oliver Naaris

---

<div class="post-metadata">

**Author:** ![oliver\_naaris](https://avatars.discourse-cdn.com/v4/letter/o/8edcca/32.png) [@oliver\_naaris](https://discourse.chef.io/u/oliver_naaris)\
**Post date:** [October 30, 2014, 7:04pm UTC](https://discourse.chef.io/t/problem-deploying-java-app/5871/3 "2014-10-30T19:04:04Z")

</div>

Hi Tyler and thanks for the response

It took me half a day but I manged to figure out that the Tomcat 0.16.x  
cookbook introduced some breaking changes that caused this problem. For  
the moment I fixed the version number to 0.15.12 and it works. However  
the java application deployment cookbook seems kinda broken at times. I  
really wish that someone publishes a better version at Github.

Thanks again  
Oliver

On 30/10/14 19:08, Tyler wrote:

> We wrote our own cookbook to install our java applications. Our  
> opinion was that the open source cookbooks we could have used tried to  
> do too much. So we wrote our own that was much more targeted to our  
> needs.
> 
> I haven’t used any of the cookbooks referenced in that blog post. But  
> the error below reference different line numbers than the latest  
> version of the `application` cookbook on github -  
> [GitHub - poise/application: A Chef cookbook to deploy applications.](https://github.com/poise/application)
> 
> Can you update your cookbooks to the latest version and try again?  
> Maybe there was a bug in an old version.
> 
> -T
> 
> > On Oct 30, 2014, at 12:24 AM, [oliver.naaris@gmail.com](mailto:oliver.naaris@gmail.com)  
> > [mailto:oliver.naaris@gmail.com](mailto:oliver.naaris@gmail.com) wrote:
> > 
> > Hi all!
> > 
> > I've been lurking in this mailing list for over a year and this is my  
> > first  
> > time posting here.  
> > Anyway, I was trying to setup a demo Java environment using this  
> > tutorial:  
> > [http://blog.jamie.ly/programming/2014/03/06/deploying-a-java-tomcat-application-via-chef.html](http://blog.jamie.ly/programming/2014/03/06/deploying-a-java-tomcat-application-via-chef.html)
> > 
> > The problem is that when I try to bootstrap the node I get the following  
> > errors.  
> > I'm also curious of how other companies are deploying Java apps - are  
> > you using  
> > the application\_java cookbook or some other mechanism?
> > 
> > # ================================================================================ Error executing action `before_deploy` on resource 'application\_java\_tomcat[jaxrs\_tutorial]'
> > 
> > ## Chef::Exceptions::ResourceNotFound
> > 
> > Cannot find a resource matching service[tomcat] (did you define it  
> > first?)
> > 
> > ## Cookbook Trace:
> > 
> > /var/chef/cache/cookbooks/application\_java/providers/tomcat.rb:48:in  
> > `block (2 levels) in class_from_file' /var/chef/cache/cookbooks/application_java/providers/tomcat.rb:46:in `block in  
> > class\_from\_file'  
> > /var/chef/cache/cookbooks/application/providers/default.rb:110:in  
> > `block (3 levels) in before_deploy' /var/chef/cache/cookbooks/application/providers/default.rb:109:in `each'  
> > /var/chef/cache/cookbooks/application/providers/default.rb:109:in  
> > `block (2  
> > levels) in before\_deploy'
> > 
> > ## Resource Declaration:
> > 
> > # In /var/chef/cache/cookbooks/application/resources/default.rb
> > 
> > 115: resource = super(resource\_name.to\_sym, self.name, &block)  
> > 116: break
> > 
> > ## Compiled Resource:
> > 
> > # Declared in
> > 
> > /var/chef/cache/cookbooks/application/resources/default.rb:115:in  
> > `block in method\_missing'
> > 
> > application\_java\_tomcat("jaxrs\_tutorial") do  
> > action [:nothing]  
> > retries 0  
> > retry\_delay 2  
> > cookbook\_name "jaxrs\_tutorial"  
> > recipe\_name "default"  
> > type :tomcat  
> > restart\_command  
> > #Proc:0x000000035134e0@/var/chef/cache/cookbooks/application\_java/providers/tomcat.rb:27  
> > end
> > 
> > # ================================================================================ Error executing action `run` on resource 'ruby\_block[jaxrs\_tutorial before\_deploy]'
> > 
> > ## Chef::Exceptions::ResourceNotFound
> > 
> > application\_java\_tomcat[jaxrs\_tutorial] (jaxrs\_tutorial::default line  
> > 115) had  
> > an error: Chef::Exceptions::ResourceNotFound: Cannot find a resource  
> > matching  
> > service[tomcat] (did you define it first?)
> > 
> > ## Cookbook Trace:
> > 
> > /var/chef/cache/cookbooks/application\_java/providers/tomcat.rb:48:in  
> > `block (2 levels) in class_from_file' /var/chef/cache/cookbooks/application_java/providers/tomcat.rb:46:in `block in  
> > class\_from\_file'  
> > /var/chef/cache/cookbooks/application/providers/default.rb:110:in  
> > `block (3 levels) in before_deploy' /var/chef/cache/cookbooks/application/providers/default.rb:109:in `each'  
> > /var/chef/cache/cookbooks/application/providers/default.rb:109:in  
> > `block (2  
> > levels) in before\_deploy'
> > 
> > ## Resource Declaration:
> > 
> > # In /var/chef/cache/cookbooks/application/providers/default.rb
> > 
> > 107: ruby\_block "#{new\_resource.name} before\_deploy" do  
> > 108:block do  
> > 109: new\_resource.sub\_resources.each do |resource|  
> > 110: resource.run\_action :before\_deploy  
> > 111: end  
> > 112: callback(:before\_deploy, new\_resource.before\_deploy)  
> > 113:end  
> > 114: end  
> > 115: end
> > 
> > ## Compiled Resource:
> > 
> > # Declared in
> > 
> > /var/chef/cache/cookbooks/application/providers/default.rb:107:in  
> > `before\_deploy'
> > 
> > ruby\_block("jaxrs\_tutorial before\_deploy") do  
> > action "run"  
> > retries 0  
> > retry\_delay 2  
> > block\_name "jaxrs\_tutorial before\_deploy"  
> > cookbook\_name "jaxrs\_tutorial"  
> > block  
> > #Proc:0x00000003466538@/var/chef/cache/cookbooks/application/providers/default.rb:108  
> > end
> > 
> > Thanks and Regards,  
> > Oliver Naaris
