# Example using application\_java?

**URL:** <https://discourse.chef.io/t/example-using-application-java/2797>\
**Category:** Chef Infra (archive)\
**Created:** [May 29, 2012, 7:11pm UTC](https://discourse.chef.io/t/example-using-application-java/2797 "2012-05-29T19:11:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jesse\_Campbell](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jesse_campbell/32/251_2.png) [@Jesse\_Campbell](https://discourse.chef.io/u/Jesse_Campbell)\
**Post date:** [May 29, 2012, 7:11pm UTC](https://discourse.chef.io/t/example-using-application-java/2797/1 "2012-05-29T19:11:49Z")

</div>

Does anyone have an example that uses application\_java?  
We are deploying about 15 different war files into tomcat from a maven  
repository (running nexus), there is a DB role that would need rails  
migrations performed.  
There is a simple example for deploying jenkins, but it doesn’t get  
into migrations at all…

We’re currently deploying tomcat with the tomcat6 cookbook, dropping  
the dependent jar files in with our own custom cookbook as we’d  
originally wanted to avoid the methods that the tomcat and java  
cookbook used for jar distribution.

Thanks all,  
-Jesse

---

<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:** [May 29, 2012, 8:20pm UTC](https://discourse.chef.io/t/example-using-application-java/2797/2 "2012-05-29T20:20:41Z")

</div>

Jesse,

On Tue, May 29, 2012 at 9:11 PM, Jesse Campbell [hikeit@gmail.com](mailto:hikeit@gmail.com) wrote:

> Does anyone have an example that uses application\_java?  
> We are deploying about 15 different war files into tomcat from a maven  
> repository (running nexus), there is a DB role that would need rails  
> migrations performed.  
> There is a simple example for deploying jenkins, but it doesn't get  
> into migrations at all..
> 
> We're currently deploying tomcat with the tomcat6 cookbook, dropping  
> the dependent jar files in with our own custom cookbook as we'd  
> originally wanted to avoid the methods that the tomcat and java  
> cookbook used for jar distribution.

documentation can/should be improved, but there is something in the  
application cookbook.  
There is nothing framework-specific to migrations anyway; as many  
other feature in the application cookbook, it maps directly to the  
deploy resource; its documentation applies.

Except... the Java cookbook does not use deploy at this time; it  
didn't in the previous version, and unfortunately it still does not.

It's not very clear to me how migrations would fit in the workflow of  
a typical Java shop. In fact I've brainstormed about application\_java  
with miscellaneous people and we haven't even touched on  
migrations--not high-priority enough, I guess.

I'm curious: you mention Rails migrations? Do you also have a Rails  
app, or do you use it just for managing migrations?  
Could you maybe use application\_ruby for that part, and then somehow  
orchestrate the deployment interactions?

Andrea

---

<div class="post-metadata">

**Author:** ![Torben\_Knerr](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@Torben\_Knerr](https://discourse.chef.io/u/Torben_Knerr)\
**Post date:** [May 29, 2012, 9:07pm UTC](https://discourse.chef.io/t/example-using-application-java/2797/3 "2012-05-29T21:07:45Z")

</div>

On Tue, May 29, 2012 at 10:20 PM, Andrea Campi \<[andrea.campi@zephirworks.com](mailto:andrea.campi@zephirworks.com)

> wrote:

> Jesse,
> 
> On Tue, May 29, 2012 at 9:11 PM, Jesse Campbell [hikeit@gmail.com](mailto:hikeit@gmail.com) wrote:
> 
> > Does anyone have an example that uses application\_java?  
> > We are deploying about 15 different war files into tomcat from a maven  
> > repository (running nexus), there is a DB role that would need rails  
> > migrations performed.  
> > There is a simple example for deploying jenkins, but it doesn't get  
> > into migrations at all..
> > 
> > We're currently deploying tomcat with the tomcat6 cookbook, dropping  
> > the dependent jar files in with our own custom cookbook as we'd  
> > originally wanted to avoid the methods that the tomcat and java  
> > cookbook used for jar distribution.
> 
> documentation can/should be improved, but there is something in the  
> application cookbook.  
> There is nothing framework-specific to migrations anyway; as many  
> other feature in the application cookbook, it maps directly to the  
> deploy resource; its documentation applies.
> 
> Except... the Java cookbook does not use deploy at this time; it  
> didn't in the previous version, and unfortunately it still does not.
> 
> It's not very clear to me how migrations would fit in the workflow of  
> a typical Java shop. In fact I've brainstormed about application\_java  
> with miscellaneous people and we haven't even touched on  
> migrations--not high-priority enough, I guess.

As for migrations in java flyway and liquibase come into mind:  
[http://code.google.com/p/flyway/](http://code.google.com/p/flyway/)

> **[The Liquibase Community | The Database DevOps Community](https://www.liquibase.org/)**
>
> Join the Liquibase Community. Participate, learn, and contribute as millions of developers bring the database into their CI/CD pipeline.

Don't have a concrete (and chefifyed) example though...

Torben

I'm curious: you mention Rails migrations? Do you also have a Rails

> app, or do you use it just for managing migrations?  
> Could you maybe use application\_ruby for that part, and then somehow  
> orchestrate the deployment interactions?
> 
> Andrea

---

<div class="post-metadata">

**Author:** ![Jesse\_Campbell](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jesse_campbell/32/251_2.png) [@Jesse\_Campbell](https://discourse.chef.io/u/Jesse_Campbell)\
**Post date:** [May 29, 2012, 10:37pm UTC](https://discourse.chef.io/t/example-using-application-java/2797/4 "2012-05-29T22:37:34Z")

</div>

We deploy our rails apps in war/java containers using something called  
Warbler (this comes from the developers, I haven't investigated it  
myself). The dev group wants us to implement capistrano, but i feel  
like that is like saying we should use puppet for this one thing...  
we're a chef shop, do it the chef way is how I want to respond... but  
so far I haven't found what i need.  
We may continue using Bryan's tomcat6, and use his maven LWRP for  
deploying the wars... but i think even that may leave us without a  
migrations plan...  
perhaps there is a way to use some aspects of the deploy resource to  
orchestrate migrations... i'll investigate later in the week (for now  
I just need to get things running once to get the PMs off my back).

-Jesse

On Tue, May 29, 2012 at 4:20 PM, Andrea Campi  
[andrea.campi@zephirworks.com](mailto:andrea.campi@zephirworks.com) wrote:

> Jesse,
> 
> On Tue, May 29, 2012 at 9:11 PM, Jesse Campbell [hikeit@gmail.com](mailto:hikeit@gmail.com) wrote:
> 
> > Does anyone have an example that uses application\_java?  
> > We are deploying about 15 different war files into tomcat from a maven  
> > repository (running nexus), there is a DB role that would need rails  
> > migrations performed.  
> > There is a simple example for deploying jenkins, but it doesn't get  
> > into migrations at all..
> > 
> > We're currently deploying tomcat with the tomcat6 cookbook, dropping  
> > the dependent jar files in with our own custom cookbook as we'd  
> > originally wanted to avoid the methods that the tomcat and java  
> > cookbook used for jar distribution.
> 
> documentation can/should be improved, but there is something in the  
> application cookbook.  
> There is nothing framework-specific to migrations anyway; as many  
> other feature in the application cookbook, it maps directly to the  
> deploy resource; its documentation applies.
> 
> Except... the Java cookbook does not use deploy at this time; it  
> didn't in the previous version, and unfortunately it still does not.
> 
> It's not very clear to me how migrations would fit in the workflow of  
> a typical Java shop. In fact I've brainstormed about application\_java  
> with miscellaneous people and we haven't even touched on  
> migrations--not high-priority enough, I guess.
> 
> I'm curious: you mention Rails migrations? Do you also have a Rails  
> app, or do you use it just for managing migrations?  
> Could you maybe use application\_ruby for that part, and then somehow  
> orchestrate the deployment interactions?
> 
> 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:** [May 30, 2012, 7:03am UTC](https://discourse.chef.io/t/example-using-application-java/2797/5 "2012-05-30T07:03:18Z")

</div>

On Wed, May 30, 2012 at 12:37 AM, Jesse Campbell [hikeit@gmail.com](mailto:hikeit@gmail.com) wrote:

> We deploy our rails apps in war/java containers using something called  
> Warbler (this comes from the developers, I haven't investigated it  
> myself). The dev group wants us to implement capistrano, but i feel  
> like that is like saying we should use puppet for this one thing...  
> we're a chef shop, do it the chef way is how I want to respond... but  
> so far I haven't found what i need.  
> We may continue using Bryan's tomcat6, and use his maven LWRP for  
> deploying the wars... but i think even that may leave us without a  
> migrations plan...  
> perhaps there is a way to use some aspects of the deploy resource to  
> orchestrate migrations... i'll investigate later in the week (for now  
> I just need to get things running once to get the PMs off my back).

For a quick and dirty fix, you could try subscribing to the  
java\_remote\_file resource.  
I haven't actually tried this so YMMV, but it should be doable.

I'd start with something like this:

assuming you have a:

application "app-test" do  
...  
end

then in your recipe add something like:

execute "migrate app-test" do  
command "rake db:migrate" # or whatever shell command you need to run  
action :nothing  
subscribes :run, resources(:java\_remote\_file =\> "app-test")  
end

Maybe it will work on the first attempt 🙂  
If it won't, run it with chef-client -l debug and email me the log  
(private email) and I'll walk you through the rest.  
Once we get you set up, I'll document it for the next poor soul.

Andrea

---

<div class="post-metadata">

**Author:** ![Jesse\_Campbell](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jesse_campbell/32/251_2.png) [@Jesse\_Campbell](https://discourse.chef.io/u/Jesse_Campbell)\
**Post date:** [May 30, 2012, 7:04pm UTC](https://discourse.chef.io/t/example-using-application-java/2797/6 "2012-05-30T19:04:27Z")

</div>

I'll give that a try in the next week or two and see how far I get. We  
have a deadline for go-live, and migration doesn't have to be ready  
for the first deploy, so I'll have to wait until things are up before  
I can revisit it.

Thanks!!!

On Wed, May 30, 2012 at 3:03 AM, Andrea Campi  
[andrea.campi@zephirworks.com](mailto:andrea.campi@zephirworks.com) wrote:

> On Wed, May 30, 2012 at 12:37 AM, Jesse Campbell [hikeit@gmail.com](mailto:hikeit@gmail.com) wrote:
> 
> > We deploy our rails apps in war/java containers using something called  
> > Warbler (this comes from the developers, I haven't investigated it  
> > myself). The dev group wants us to implement capistrano, but i feel  
> > like that is like saying we should use puppet for this one thing...  
> > we're a chef shop, do it the chef way is how I want to respond... but  
> > so far I haven't found what i need.  
> > We may continue using Bryan's tomcat6, and use his maven LWRP for  
> > deploying the wars... but i think even that may leave us without a  
> > migrations plan...  
> > perhaps there is a way to use some aspects of the deploy resource to  
> > orchestrate migrations... i'll investigate later in the week (for now  
> > I just need to get things running once to get the PMs off my back).
> 
> For a quick and dirty fix, you could try subscribing to the  
> java\_remote\_file resource.  
> I haven't actually tried this so YMMV, but it should be doable.
> 
> I'd start with something like this:
> 
> assuming you have a:
> 
> application "app-test" do  
> ...  
> end
> 
> then in your recipe add something like:
> 
> execute "migrate app-test" do  
> command "rake db:migrate" # or whatever shell command you need to run  
> action :nothing  
> subscribes :run, resources(:java\_remote\_file =\> "app-test")  
> end
> 
> Maybe it will work on the first attempt 🙂  
> If it won't, run it with chef-client -l debug and email me the log  
> (private email) and I'll walk you through the rest.  
> Once we get you set up, I'll document it for the next poor soul.
> 
> Andrea

---

<div class="post-metadata">

**Author:** ![StephenKing](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/stephenking/32/656_2.png) [@StephenKing](https://discourse.chef.io/u/StephenKing)\
**Post date:** [August 9, 2012, 1:45pm UTC](https://discourse.chef.io/t/example-using-application-java/2797/7 "2012-08-09T13:45:25Z")

</div>

Hi,

I'm having the same problem.

Could sb. please give me an example, how to deploy a Java .war using application\_java?  
It's driving me nuts..  
I always end up with the same problem as this poor guy: [Error using application cookbook to deploy hello.war · GitHub](https://gist.github.com/2959823)

Thanks!  
Steffen

On May 29, 2012, at 9:11 PM, Jesse Campbell [hikeit@gmail.com](mailto:hikeit@gmail.com) wrote:

> Does anyone have an example that uses application\_java?  
> We are deploying about 15 different war files into tomcat from a maven  
> repository (running nexus), there is a DB role that would need rails  
> migrations performed.  
> There is a simple example for deploying jenkins, but it doesn't get  
> into migrations at all..
> 
> We're currently deploying tomcat with the tomcat6 cookbook, dropping  
> the dependent jar files in with our own custom cookbook as we'd  
> originally wanted to avoid the methods that the tomcat and java  
> cookbook used for jar distribution.
> 
> Thanks all,  
> -Jesse

---

<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:** [August 9, 2012, 2:19pm UTC](https://discourse.chef.io/t/example-using-application-java/2797/8 "2012-08-09T14:19:46Z")

</div>

On Thu, Aug 9, 2012 at 3:45 PM, Steffen Gebert [st+opscode@st-g.de](mailto:st+opscode@st-g.de) wrote:

> Hi,
> 
> I'm having the same problem.
> 
> Could sb. please give me an example, how to deploy a Java .war using  
> application\_java?  
> It's driving me nuts..  
> I always end up with the same problem as this poor guy:  
> [https://gist.github.com/2959823](https://gist.github.com/2959823)

The same error? That's strange.  
Can you do a run with chef-client -l debug and post it somewhere  
online / attach it / send it to me.

The only resource that could raise that error is this one:

> <https://github.com/poise/application_java/blob/master/providers/java_webapp.rb#L72>

You could try specifying the action explicitly:

template "#{new\_resource.path}/shared/#{new\_resource.application.name}.xml" do  
action :create  
… leave the rest unchanged  
end

But that's just a hunch—the log will make it clearer.

Andrea

---

<div class="post-metadata">

**Author:** ![StephenKing](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/stephenking/32/656_2.png) [@StephenKing](https://discourse.chef.io/u/StephenKing)\
**Post date:** [August 10, 2012, 9:41am UTC](https://discourse.chef.io/t/example-using-application-java/2797/9 "2012-08-10T09:41:10Z")

</div>

Hi Andrea,

thanks for your offer to help!

I've pasted the log here:

> <https://gist.github.com/StephenKing/3312956>

and the recipe here: [chef-gitblit/recipes/default.rb at master · StephenKing/chef-gitblit · GitHub](https://github.com/StephenKing/chef-gitblit/blob/master/recipes/default.rb)

Changing the application\_java cookbook as suggested also didn't help.

Thanks!  
Steffen

On Aug 9, 2012, at 4:19 PM, Andrea Campi [andrea.campi@zephirworks.com](mailto:andrea.campi@zephirworks.com) wrote:

> On Thu, Aug 9, 2012 at 3:45 PM, Steffen Gebert [st+opscode@st-g.de](mailto:st+opscode@st-g.de) wrote:
> 
> > Hi,
> > 
> > I'm having the same problem.
> > 
> > Could sb. please give me an example, how to deploy a Java .war using  
> > application\_java?  
> > It's driving me nuts..  
> > I always end up with the same problem as this poor guy:  
> > [Error using application cookbook to deploy hello.war · GitHub](https://gist.github.com/2959823)
> 
> The same error? That's strange.  
> Can you do a run with chef-client -l debug and post it somewhere  
> online / attach it / send it to me.
> 
> The only resource that could raise that error is this one:  
> [application\_java/providers/java\_webapp.rb at master · poise/application\_java · GitHub](https://github.com/opscode-cookbooks/application_java/blob/master/providers/java_webapp.rb#L72)  
> You could try specifying the action explicitly:
> 
> template "#{new\_resource.path}/shared/#{new\_resource.application.name}.xml" do  
> action :create  
> … leave the rest unchanged  
> end
> 
> But that's just a hunch—the log will make it clearer.
> 
> Andrea
