Ask Your Question

Java not found

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

George gravatar image

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

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 ...
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

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

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 ( ), so you might just be missing that.

A couple of days ago I wrote an Oracle Java module for Puppet ( ). It ... (more)

edit flag offensive delete link more


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 -0600 )edit

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

George gravatar image


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


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 -0600 )edit

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 -0600 )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 -0600 )edit

For anyone else viewing this question, it has been asked separately here:

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

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

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


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

Seen: 805 times

Last updated: Oct 06 '13