Ask Your Question
2

Java not found

asked 2013-10-02 01:15:55 -0500

George gravatar image

updated 2013-10-06 14:09:13 -0500

ramindk gravatar image

Hi, I'm struggling deploying a jar file. I manage to create a VM in which I have installed Java (if I connect with puppy, I can run java commands). The problem is that I want to deploy my jar file as part of the configuration, so I create an exec resource, but I receive a "java command not found" error:

exec { 'start myJar':
  command => 'java -jar myJar.jar', 
  path    => '/vagrant/dependencies/packages/myJar',
  require => [ Class["must-have"], Class["mysql"] ],
}

My Java installation is part of "must-have" class:

package { ["oracle-java7-installer"]:
  ensure  => present,
  require => Exec['apt-get update 2'],
}

exec { 'accept_license':
  command => "echo ...
(more)
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2013-10-02 07:43:12 -0500

ryanbrooks gravatar image

A good place to start is to identify which step is causing the failure. Have you tried creating a test VM which just includes "must-have" and then manually seeing if you can run Java (or even if the files have installed)?

Assuming the issue is there, what operating system and version are using? Later versions of Ubuntu don't have the Oracle installer without adding the WebUpd8Team PPA ( https://launchpad.net/~webupd8team/+archive/java ), so you might just be missing that.

A couple of days ago I wrote an Oracle Java module for Puppet ( https://github.com/spikeheap/puppet-oraclejava ). It ... (more)

edit flag offensive delete link more

Comments

If this answer solves your "Java not found" question it would be nice if you could mark it as accepted :). It's good form to ask new questions separately, even ...(more)

ryanbrooks gravatar imageryanbrooks ( 2013-10-03 09:27:47 -0500 )edit
0

answered 2013-10-02 08:59:32 -0500

George gravatar image

Hi,

I have enable log on exec and I found that I had some errors regarding file rights and paths. Please find bellow the updated version of exec which works:

exec { 'start myJar':
    cwd => '/vagrant/dependencies/packages/myJar',
    command => '/usr/bin/java -jar myJar.jar',
    path => '/usr/bin/:/bin/',
    require => [ Class["must-have"],
                 Class["mysql"] ],
    logoutput => true
  }

Now the whole system starts almost ok. I receive a timeout error on the exec, but the jar was executed (I'm able to access it). The jar deploys an application with a jetty embedded and starts it. I think that the timeout problem ... (more)

edit flag offensive delete link more

Comments

This probably deserves to be a question in it's own right here. You are right that the problem is because the command never returns, but you also have a ...(more)

ryanbrooks gravatar imageryanbrooks ( 2013-10-03 09:21:41 -0500 )edit
1

I believe one proper pattern to reach the desired behavior is to create an init script for your platform and manage the service state. If your platform has upstart it ...(more)

evilensky gravatar imageevilensky ( 2013-10-03 09:22:57 -0500 )edit

I would package the JAR as an application for your system (e.g. a .deb for Ubuntu) with its associated init script and PID. then you can use package and ...(more)

ryanbrooks gravatar imageryanbrooks ( 2013-10-03 09:25:46 -0500 )edit

For anyone else viewing this question, it has been asked separately here: https://ask.puppetlabs.com/question/3438/java-server-timeout-command-which-never-returns-exit-code/

ryanbrooks gravatar imageryanbrooks ( 2013-10-03 09:29:43 -0500 )edit
0

answered 2013-10-06 21:43:43 -0500

spuder gravatar image

I believe there are two changes that need to be made.

  1. You need to include the full path to java. Type in which java to find the correct path. (I find it unlikely that java is in /vagrant/dependencies/packages)
  2. Set a timeout, exec statments by default error out after 300 seconds, you may need to extend it.

    exec { 'start myJar':  
        command => 'java -jar myJar.jar',   
        path    => '/usr/bin/',  
        timeout => 600  
    }
    
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-10-02 01:15:55 -0500

Seen: 681 times

Last updated: Oct 06 '13