Error application_java recipe


#1

Just starting out with Chef and writing recipes and I’m stumped on this one. can anyone help?

my recipe:

application 'gw_core' do
  path '/usr/share/tomcat6/webapps'
  owner node['tomcat']['user']
  group node['tomcat']['group']
  repository 'http://someurl.com/artifactory/gw_core.war'
  scm_provider Chef::Provider::RemoteFile::Deploy
  java_webapp 
  tomcat
end

the logs:

Starting Chef Client, version 12.5.1
resolving cookbooks for run list: ["gw_core"]
Synchronizing Cookbooks:
  - application_java (3.0.0)
  - application (3.0.0)
  - chef-sugar (3.2.0)
  - gw_core (0.1.0)
  - apt (2.9.2)
  - openssl (4.4.0)
  - java (1.36.0)
  - tomcat (1.0.1)
  - yum (3.8.2)
  - yum-epel (0.6.5)
Compiling Cookbooks...
[2015-12-14T14:14:29-08:00] WARN: Chef::Mixin::RecipeDefinitionDSLCore is deprecated. Use Chef::DSL::Recipe instead.

[2015-12-14T14:14:29-08:00] WARN: Called from:
        /var/chef/cache/cookbooks/application/resources/default.rb:23:in `class_from_file'
        /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/mixin/from_file.rb:42:in `class_eval'
        /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/mixin/from_file.rb:42:in `class_from_file'
Converging 3 resources
Recipe: gw_core::default
  * application_java_java_webapp[gw_core] action nothing (skipped due to action :nothing)
  * application_java_tomcat[gw_core] action nothing (skipped due to action :nothing)
  * application[gw_core] action deploy
    * application_java_java_webapp[gw_core] action before_compile (up to date)
    * application_java_tomcat[gw_core] action before_compile (up to date)
     (up to date)
Recipe: tomcat::default
  * yum_package[tomcat6] action install (up to date)
  * yum_package[tomcat6-admin-webapps] action install (up to date)
  * tomcat_instance[base] action configure

  * directory[/usr/share/tomcat6/lib/endorsed] action create (up to date)
  * template[/etc/sysconfig/tomcat6] action create (up to date)
  * template[/etc/tomcat6/server.xml] action create
    - update content in file /etc/tomcat6/server.xml from a8cabf to 759b43
    --- /etc/tomcat6/server.xml 2015-12-14 13:13:05.000000000 -0800
    +++ /etc/tomcat6/.server.xml20151214-6915-z5sznf    2015-12-14 14:14:36.000000000 -0800
    @@ -89,9 +89,9 @@
              described in the APR documentation -->
         <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
                    keystoreFile="/etc/tomcat6/keystore.jks"
    -               keystorePass="Urpga7AhEzYfkTOOb6Qd"
    +               keystorePass="leKK6YfGLFxB32IsUsKr"
                    keystoreType="jks"
    -               truststorePass="Urpga7AhEzYfkTOOb6Qd"
    +               truststorePass="leKK6YfGLFxB32IsUsKr"
                    maxThreads="150" scheme="https" secure="true"
                    clientAuth="false" sslProtocol="TLS"
                  />
    - restore selinux security context
  * template[/etc/tomcat6/logging.properties] action create (up to date)
  * execute[Create Tomcat SSL certificate] action run (up to date)
  * service[tomcat6] action start (up to date)
  * service[tomcat6] action enable (up to date)
  * execute[wait for tomcat6] action nothing (skipped due to action :nothing)
  * directory[/usr/share/tomcat6/webapps] action create (up to date)
  * directory[/usr/share/tomcat6/webapps/shared] action create (up to date)
  * ruby_block[gw_core before_deploy] action run
  Recipe: gw_core::default
    * application_java_java_webapp[gw_core] action before_deploy (up to date)
    * application_java_tomcat[gw_core] action before_deploy

      ================================================================================
      Error executing action `before_deploy` on resource 'application_java_tomcat[gw_core]'
      ================================================================================

      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 /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/dsl/recipe.rb

      144:           return send(method_symbol, *args, &block)
      145:         end

      Compiled Resource:
      ------------------
      # Declared in /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/dsl/recipe.rb:144:in `method_missing'

      application_java_tomcat("gw_core") do
        action [:nothing]
        retries 0
        retry_delay 2
        default_guard_interpreter :default
        declared_type :application_java_tomcat
        cookbook_name "gw_core"
        recipe_name "default"
        type :tomcat
        restart_command #<Proc:0x00000004adf5f8@/var/chef/cache/cookbooks/application_java/providers/tomcat.rb:27>
      end


    ================================================================================
    Error executing action `run` on resource 'ruby_block[gw_core before_deploy]'
    ================================================================================

    Chef::Exceptions::ResourceNotFound
    ----------------------------------
    application_java_tomcat[gw_core] (gw_core::default line 144) 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("gw_core before_deploy") do
      action [:run]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      block_name "gw_core before_deploy"
      declared_type :ruby_block
      cookbook_name "gw_core"
      block #<Proc:0x00000004aa78d8@/var/chef/cache/cookbooks/application/providers/default.rb:108>
    end

Recipe: tomcat::default
  * service[tomcat6] action restart
    - restart service service[tomcat6]
  * execute[wait for tomcat6] action run
    - execute sleep 5

Running handlers:
[2015-12-14T14:15:13-08:00] ERROR: Running exception handlers
Running handlers complete
[2015-12-14T14:15:13-08:00] ERROR: Exception handlers complete
Chef Client failed. 4 resources updated in 46 seconds
[2015-12-14T14:15:13-08:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2015-12-14T14:15:13-08:00] ERROR: ruby_block[gw_core before_deploy] (/var/chef/cache/cookbooks/application/providers/default.rb line 107) had an error: Chef::Exceptions::ResourceNotFound: application_java_tomcat[gw_core] (gw_core::default line 144) had an error: Chef::Exceptions::ResourceNotFound: Cannot find a resource matching service[tomcat] (did you define it first?)
[2015-12-14T14:15:14-08:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

#2

application_java hasn’t yet been rewritten to use the upgraded application cookbook code, so it is über-deprecated. Using the artifact cookbook directly is probably what you want for now, pending the rewrite/upgrade of application_java which will happen when I get a chance to finish poise-java.


#3

can you give me a reference to a basic recipe for using artifact cookbook to deploy a war file?

thanks