maestrodev / puppet-maven

A puppet recipe for Apache Maven, to download artifacts from a Maven repository, install Maven, configure settings.xml,...
http://www.maestrodev.com
Apache License 2.0
73 stars 77 forks source link

Java class required #44

Open juasiepo opened 9 years ago

juasiepo commented 9 years ago

I am installing java by uncompressing it in a specific folder and updating the JAVA_HOME and not using the rpm/yum java based. While trying to download and artifact using maven, it fails and the log shows: Could not evaluate: mvn returned 1: Is Maven installed?

The "funny thing" s that if I run the exec command shown on logs manually it works perfectly but not while it runs through puppet.

puppet-maven seems to need the rpm/yum java version somehow and doesn't like my approach. Any Idea how can I make it compatible? the other option I can think is that there is some environment variable not set. Who knows.... :)

Thanks for your time

carlossg commented 9 years ago

Probably the path used by puppet and exec are different. Maven also uses JAVA_HOME

juasiepo commented 9 years ago

Yes, I thought that to so I populated the JAVA_HOME using the module's parameter $maven_opts but still no luck

riman commented 8 years ago

Hi. I ran into this issue too. If Java is installed by decompressing jdk-version.tar.gz into (for ex.) /opt/jdk then Maven would not work. I tried setting maven::environment as:

maven::environment { 'maven-env' :
    # anything to add to MAVEN_OPTS in ~/.mavenrc
    user => 'root',
    maven_opts           => '-Xmx1384m',       # anything to add to MAVEN_OPTS in ~/.mavenrc
    maven_path_additions => "/opt/jdk/jdk$jdk_version/bin",      # anything to add to the PATH in ~/.mavenrc
    mavenrc_additions => "export JAVA_HOME=/opt/jdk/jdk$jdk_version"
  } ->

but it didn't help either.

The error reads as:

Error: ["mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get -DgroupId=com.mycompany -DartifactId=theapp -Dversion=1.2.5 -DremoteRepositories=http://buildserver:port/public -Ddest=/dir/theapp-1.2.5.jar -Dtransitive=false -Ppuppet-maven "] returned 1: Error: JAVA_HOME is not defined correctly. We cannot execute

If JAVA_HOME is exported in /root/.bashrc as

export JAVA_HOME=...
export PATH=$JAVA_HOME/bin:$PATH

before running puppet agent then everything work OK.