poise / application_java

Development repository for Opscode Cookbook application_java
http://community.opscode.com/cookbooks/application_java
Apache License 2.0
21 stars 64 forks source link

Basic deployment of a local WAR file does not work #12

Open et304383 opened 9 years ago

et304383 commented 9 years ago
application "myapp" do
  path "/var/builds/myapp"
  repository "/home/etucker/git/myapp/build/libs/myapp-1.0.0-SNAPSHOT.war"
  scm_provider Chef::Provider::File::Deploy

  java_webapp

  tomcat
end

This does not work, throwing the following error:

  * deploy_revision[myapp] action deploy
    - purge old staged files
    ================================================================================
    Error executing action `deploy` on resource 'deploy_revision[myapp]'
    ================================================================================

    NoMethodError
    -------------
    undefined method `new' for nil:NilClass

    Cookbook Trace:
    ---------------
    /home/etucker/.chef/local-mode-cache/cache/cookbooks/application_java/libraries/provider_file_deploy.rb:54:in `action_sync'
    /home/etucker/.chef/local-mode-cache/cache/cookbooks/application_java/libraries/provider_file_deploy.rb:45:in `target_revision'

    Resource Declaration:
    ---------------------
    # In /home/etucker/.chef/local-mode-cache/cache/cookbooks/application/providers/default.rb

    122:   @deploy_resource = send(new_resource.strategy.to_sym, new_resource.name) do
    123:     action force ? :force_deploy : :deploy
    124:     scm_provider new_resource.scm_provider
    125:     revision new_resource.revision
    126:     repository new_resource.repository
    127:     enable_submodules new_resource.enable_submodules
    128:     user new_resource.owner
    129:     group new_resource.group
    130:     deploy_to new_resource.path
    131:     ssh_wrapper "#{new_resource.path}/deploy-ssh-wrapper" if new_resource.deploy_key
    132:     shallow_clone new_resource.shallow_clone
    133:     rollback_on_error new_resource.rollback_on_error
    134:     all_environments = ([new_resource.environment]+new_resource.sub_resources.map{|res| res.environment}).inject({}){|acc, val| acc.merge(val)}
    135:     environment all_environments
    136:     migrate new_resource.migrate
    137:     all_migration_commands = ([new_resource.migration_command]+new_resource.sub_resources.map{|res| res.migration_command}).select{|cmd| cmd && !cmd.empty?}
    138:     migration_command all_migration_commands.join(' && ')
    139:     restart_command do
    140:       ([new_resource]+new_resource.sub_resources).each do |res|
    141:         cmd = res.restart_command
    142:         if cmd.is_a? Proc
    143:           version = Chef::Version.new(Chef::VERSION)
    144:           provider = if version.major > 10 || version.minor >= 14
    145:             Chef::Platform.provider_for_resource(res, :nothing)
    146:           else
    147:             Chef::Platform.provider_for_resource(res)
    148:           end
    149:           provider.load_current_resource
    150:           provider.instance_eval(&cmd)
    151:         elsif cmd && !cmd.empty?
    152:           execute cmd do
    153:             user new_resource.owner
    154:             group new_resource.group
    155:             environment all_environments
    156:           end
    157:         end
    158:       end
    159:     end

    Compiled Resource:
    ------------------
    # Declared in /home/etucker/.chef/local-mode-cache/cache/cookbooks/application/providers/default.rb:122:in `run_deploy'

    deploy_revision("myapp") do
      action [:deploy]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      deploy_to "/var/builds/myapp"
      repository_cache "cached-copy"
      revision "HEAD"
      rollback_on_error true
      remote "origin"
      shallow_clone true
      scm_provider Chef::Provider::File::Deploy
      keep_releases 5
      enable_checkout true
      checkout_branch "deploy"
      declared_type :deploy_revision
      cookbook_name "myapp"
      repo "/home/etucker/git/myapp/build/libs/myapp-1.0.0-SNAPSHOT.war"
      restart_command #<Proc:0x0000000cc3cb50@/home/etucker/.chef/local-mode-cache/cache/cookbooks/application/providers/default.rb:139>
      before_migrate #<Proc:0x0000000cc39e28@/home/etucker/.chef/local-mode-cache/cache/cookbooks/application/providers/default.rb:166>
      before_symlink #<Proc:0x0000000cc39ba8@/home/etucker/.chef/local-mode-cache/cache/cookbooks/application/providers/default.rb:169>
      before_restart #<Proc:0x0000000cc39900@/home/etucker/.chef/local-mode-cache/cache/cookbooks/application/providers/default.rb:172>
      after_restart #<Proc:0x0000000cc39630@/home/etucker/.chef/local-mode-cache/cache/cookbooks/application/providers/default.rb:175>
      shared_path "/var/builds/myapp/shared"
      destination "/var/builds/myapp/shared/cached-copy"
    end

  * service[tomcat] action restart
    - restart service service[tomcat]
  * execute[wait for tomcat] action run
    - execute sleep 5

Running handlers:
[2015-09-09T08:18:52-03:00] ERROR: Running exception handlers
Running handlers complete
[2015-09-09T08:18:52-03:00] ERROR: Exception handlers complete
Chef Client failed. 7 resources updated in 34.015680264 seconds
[2015-09-09T08:18:53-03:00] FATAL: Stacktrace dumped to /home/etucker/.chef/local-mode-cache/cache/chef-stacktrace.out
[2015-09-09T08:18:53-03:00] ERROR: deploy_revision[myapp] (/home/etucker/.chef/local-mode-cache/cache/cookbooks/application/providers/default.rb line 122) had an error: NoMethodError: undefined method `new' for nil:NilClass
[2015-09-09T08:18:53-03:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Any chance this cookbook can be updated to use application cookbook version 4.x? I think this cookbook needs some TLC.

atward commented 8 years ago

Application cookbook is pinned to ~>3.0. Issue seems to be with deploy which is part of chef.

et304383 commented 8 years ago

So is there intent to fix this or is this cookbook not actively maintained?

coderanger commented 8 years ago

@eric-tucker Intent is to fix it but I can't currently give a time estimate. I'm working on a new Java cookbook to base the revamped version on, but it's slow going.

darrenrabbitt commented 8 years ago

any idea when the new java cookbook will be ready? There doesn't appear to be many cookbooks working deploying java web apps at all.

howdoicomputer commented 7 years ago

So I was able to get this working on a basic level. Work is here: https://github.com/howdoicomputer/application_java/commit/c310c09bf3a744a45ff3ded6edc1e2b2d7f3d2b7

I am pointing my application version to a specific fork...

cookbook 'application', git: 'https://github.com/kangguru/application.git'

...because it fixes the application cookbook to the point where it is compatible with Chef 12 while also being compatible with application_java.

I also had to pin tomcat to version 1.3.0 because version 2 onward doesn't expose an interface that application_java expects.

This was all so I could get a two year old Seyren cookbook working. I, uh, sort of got it working but it's a non-optimal and janky solution so I've come to the decision to just write a Seyren cookbook from scratch.

Buuuuut... if people want to use this cookbook at its current state for Chef 12 then maybe this comment will be helpful.