Does Bluemix devops build pipeline support java 8 apps? - java-8

Given the Bluemix announcement that java 8 is supported.
What do I need to do to get my java 8 app compiling in the IBM Bluesmix build pipeline (jazzhub build and deploy).
I have set the java8 environment variable and restaged the app using the following:
cf set-env <myApp> JBP_CONFIG_IBMJDK "version: 1.8.+"
cf restage <myApp>
The specific 'builder type' I am using is 'Maven' and the failures I receive are around the new date and time classes in java8.
[ERROR] <...>/services/TestHelperService.java:[3,17] package java.time does not exist
[ERROR] <...>/services/TestHelperService.java:[37,17] cannot find symbol
[ERROR] symbol: class LocalDateTime
[ERROR] location: class <...>.services.TestHelperService

To use Java 8 you need to change the JAVA_HOME environment variable in the build shell command:
export JAVA_HOME=~/java8
For example:
#!/bin/bash
#export JAVA_HOME=~/java8 - Bluemix have changed the java8 location
export JAVA_HOME=/opt/IBM/java8
mvn -B package

I also wanted to use Java8 in Bluemix Jazz build pipeline. Just changing $JAVA_HOME didn't work for me. I had to update the $PATH as well.
export JAVA_HOME=/opt/IBM/java8
export PATH=$JAVA_HOME/bin:$PATH
After that maven was run on java8.

Hi this solution does not work for me here is my build script
#!/bin/bash
echo "Java Home before $JAVA_HOME"
export JAVA_HOME=~/java8
echo "Java Home after $JAVA_HOME"
#mvn -B package -DskipTests
#mvn -B package
And here is the console output as you can see JAVA_HOME is not modified after "export" command.
Checking out Revision 86514c6dc277b6903fcd6f51ca7c97ea733b1d42 (detached)
[ba6eba91-33a3-4b67-8efd-48962cf063ba] $ /bin/bash /tmp/hudson7007424628517212775.sh
Java Home before /home/jenkins/java
Java Home after /home/jenkins/java
Base artifact directory /home/jenkins/workspace/e92a4db8-6702-d006-0cdc-2a827a4e78a5/ba6eba91-33a3-4b67-8efd-48962cf063ba/target does not exist or is not a valid directory.
[xUnit] [INFO] - Starting to record.
[xUnit] [INFO] - Processing JUnit
[xUnit] [INFO] - [JUnit] - No test report file(s) were found with the pattern 'target/surefire-reports/TEST-*.xml' relative to '/home/jenkins/workspace/e92a4db8-6702-d006-0cdc-2a827a4e78a5/ba6eba91-33a3-4b67-8efd-48962cf063ba' for the testing framework 'JUnit'. Did you enter a pattern relative to the correct directory? Did you generate the result report(s) for 'JUnit'?
[xUnit] [ERROR] - No test reports found for the metric 'JUnit' with the resolved pattern 'target/surefire-reports/TEST-*.xml'. Configuration error?.
[xUnit] [INFO] - There are errors when processing test results.
[xUnit] [INFO] - Skipping tests recording.
Finished: SUCCESS

I can confirm that setting JAVA_HOME to /opt/IBM/java8 in the build script does work (tried out on 2016-05-04):
#!/bin/bash
echo "Java home before: $JAVA_HOME"
export JAVA_HOME=/opt/IBM/java8
echo "Java home after: $JAVA_HOME"
mvn -B package
This results in the output:
Java home before: /opt/IBM/java
Java home after: /opt/IBM/java8
As noted before, the deploy stage must either have JBP_CONFIG_IBMJDK set to "version: 1.8.+" (cf set-env myApp JBP_CONFIG_IBMJDK "version: 1.8.+" or line in env: section of manifest.yml) or (that's what I do) you need to define buildpack: java_buildpack in manifest.yml. Since May 2015, java_buildpack uses to JDK8.
Last thing to be aware of is to change source version of maven-compiler-plugin in pom.xml, of course -- but that's not Bluemix-specific.
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>(whatever version is current)</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>

Related

How to set up apache ranger on apple macbook pro m1

I'm trying to set up apache ranger for work using this https://github.com/apache/ranger/tree/master/dev-support/ranger-docker
however by running
mvn clean package -DskipTests
I'm getting the following error: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.6:exploded (prepare) on project security-admin-web: Execution prepare of goal org.apache.maven.plugins:maven-war-plugin:2.6:exploded failed: Unable to load the mojo 'exploded' in the plugin 'org.apache.maven.plugins:maven-war-plugin:2.6' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: null The entire error can be seen in this picture:
[1]
and as an alternative provided in the github, when I run:
docker-compose -f docker-compose.ranger-base.yml -f docker-compose.ranger-build.yml up
I get the error:
ranger-build | The JAVA_HOME environment variable is not defined correctly
ranger-build | This environment variable is needed to run this program
ranger-build | NB: JAVA_HOME should point to a JDK not a JRE
ranger-build | mv: cannot stat 'target/ranger-*': No such file or directory
ranger-build exited with code 1
I have also tried following https://medium.com/swlh/hands-on-apache-ranger-docker-poc-with-hadoop-hdfs-hive-presto-814344a03a17
however it gets stuck in the ranger-admin container and localhost:6080 doesn't work.
[1]: https://i.stack.imgur.com/57ubI.jpg
I was able to solve this by downgrading my maven to 3.6.3 as I was having incompatibility issues, although this particular issue was resolved by adding maven war 2.6 plug in in pom.xml but then more incompatibility issues arose so i had to uninstall and reinstall a completely different maven version and that fixed all the issues.

Travis CI doesn`t see my changes in github files

I have a github repository in the organization and the Travis file has been changed to:
language: java
jdk: oraclejdk8
mvn installation
mvn test
however, it looked different and contained a ant test command that was removed.
Recently, when I try to restart a job, do the following again:
Ant test 0,23 USD Buildfile: build.xml does not exist! The
construction was unsuccessful The "ant test" command ended at 1.
and in the config view there is no current travis file with github.
What's the problem? why Travis doesnt see my changes in github files?

-Dmaven.multiModuleProjectDirectory system property is not set in JDeveloper 12.1.3 and external maven

In JDeveloper 12.1.3 get 'suddenly' follwing error when running any maven goal on a random Java application. I mean suddenly, because i use JDeveloper infrequently for making modifications to Java classes and do not have full control over my Development environment. (Managed by admins).
Most important env variables are;
M2 = %M2_HOME%\bin
M2_HOME = D:\Tools\apache-maven-3.3.9
MAVEN_HOME = D:\Tools\apache-maven-3.3.9
MAVEN_OPTS = -Xms256m -Xmx512m -Dmaven.multiModuleProjectDirectory=%MAVEN_HOME%
I also tried enclose %MAVEN_HOME% in double quotes.
Maven preferences in JDeveloper are
Maven Version, external version: D:\Tools\apache-maven-3.3.9
User settings: D:\Tools\apache-maven-3.3.9\conf\settings.xml
Additional settings: -X -DdownloadSources=true -DdownloadJavadocs=true -P deploy-to-local-server -Dmaven.multiModuleProjectDirectory=D:\Tools\apache-maven-3.3.9
Local Repository: D:\Tools\Apache\maven3_repository
Index Directory: D:\Tools\Apache\maven3_index
All settings seems to be ok. When running mvn from the commandline, e.g. mvn test --settings D:\Tools\apache-maven-3.3.3\conf\settings.xml the build completes successfully.
Als tried to set the Java property in the jdev.conf AddVMOption -Dmaven.multiModuleProjectDirectory="%MAVEN_HOME%"
If the mvn goal test is chosen in JDeveloper it executes the command;
D:\Oracle\Java\jdk1.7.0_45\bin\javaw.exe -classpath D:\Tools\apache-maven-3.3.9\boot\plexus-classworlds-2.5.2.jar;D:\Tools\apache-maven-3.3.9\lib\wagon-provider-api-2.10.jar;D:\Tools\apache-maven-3.3.9\lib\wagon-http-shared-2.10.jar;D:\Tools\apache-maven-3.3.9\lib\wagon-http-2.10-shaded.jar;D:\Tools\apache-maven-3.3.9\lib\wagon-file-2.10.jar;D:\Tools\apache-maven-3.3.9\lib\slf4j-simple-1.7.5.jar;D:\Tools\apache-maven-3.3.9\lib\slf4j-api-1.7.5.jar;D:\Tools\apache-maven-3.3.9\lib\plexus-utils-3.0.22.jar;D:\Tools\apache-maven-3.3.9\lib\plexus-sec-dispatcher-1.3.jar;D:\Tools\apache-maven-3.3.9\lib\plexus-interpolation-1.21.jar;D:\Tools\apache-maven-3.3.9\lib\plexus-component-annotations-1.6.jar;D:\Tools\apache-maven-3.3.9\lib\plexus-cipher-1.7.jar;D:\Tools\apache-maven-3.3.9\lib\org.eclipse.sisu.plexus-0.3.2.jar;D:\Tools\apache-maven-3.3.9\lib\org.eclipse.sisu.inject-0.3.2.jar;D:\Tools\apache-maven-3.3.9\lib\maven-settings-builder-3.3.9.jar;D:\Tools\apache-maven-3.3.9\lib\maven-settings-3.3.9.jar;D:\Tools\apache-maven-3.3.9\lib\maven-repository-metadata-3.3.9.jar;D:\Tools\apache-maven-3.3.9\lib\maven-plugin-api-3.3.9.jar;D:\Tools\apache-maven-3.3.9\lib\maven-model-builder-3.3.9.jar;D:\Tools\apache-maven-3.3.9\lib\maven-model-3.3.9.jar;D:\Tools\apache-maven-3.3.9\lib\maven-embedder-3.3.9.jar;D:\Tools\apache-maven-3.3.9\lib\maven-core-3.3.9.jar;D:\Tools\apache-maven-3.3.9\lib\maven-compat-3.3.9.jar;D:\Tools\apache-maven-3.3.9\lib\maven-builder-support-3.3.9.jar;D:\Tools\apache-maven-3.3.9\lib\maven-artifact-3.3.9.jar;D:\Tools\apache-maven-3.3.9\lib\maven-aether-provider-3.3.9.jar;D:\Tools\apache-maven-3.3.9\lib\jsr250-api-1.0.jar;D:\Tools\apache-maven-3.3.9\lib\jsoup-1.7.2.jar;D:\Tools\apache-maven-3.3.9\lib\javax.inject-1.jar;D:\Tools\apache-maven-3.3.9\lib\guice-4.0-no_aop.jar;D:\Tools\apache-maven-3.3.9\lib\guava-18.0.jar;D:\Tools\apache-maven-3.3.9\lib\commons-lang3-3.4.jar;D:\Tools\apache-maven-3.3.9\lib\commons-lang-2.6.jar;D:\Tools\apache-maven-3.3.9\lib\commons-io-2.2.jar;D:\Tools\apache-maven-3.3.9\lib\commons-cli-1.2.jar;D:\Tools\apache-maven-3.3.9\lib\cdi-api-1.0.jar;D:\Tools\apache-maven-3.3.9\lib\aopalliance-1.0.jar;D:\Tools\apache-maven-3.3.9\lib\aether-util-1.0.2.v20150114.jar;D:\Tools\apache-maven-3.3.9\lib\aether-transport-wagon-1.0.2.v20150114.jar;D:\Tools\apache-maven-3.3.9\lib\aether-spi-1.0.2.v20150114.jar;D:\Tools\apache-maven-3.3.9\lib\aether-impl-1.0.2.v20150114.jar;D:\Tools\apache-maven-3.3.9\lib\aether-connector-basic-1.0.2.v20150114.jar;D:\Tools\apache-maven-3.3.9\lib\aether-api-1.0.2.v20150114.jar; -Dclassworlds.conf=D:\Tools\apache-maven-3.3.9\bin\m2.conf -Dmaven.home=D:\Tools\apache-maven-3.3.9 org.codehaus.classworlds.Launcher -X -DdownloadSources=true -DdownloadJavadocs=true -P deploy-to-local-server -Dmaven.multiModuleProjectDirectory=D:\Tools\apache-maven-3.3.9 --settings D:\Tools\apache-maven-3.3.9\conf\settings.xml --file C:\Projecten\project\A\B\pom.xml clean -Denv.ORACLE_HOME=D:\Oracle\Middleware_JDev12.1.3
When executing this command on the commandline it completes, but does not seem to execute to goal. If javaw is replace with java it shows the error -Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variable and mvn script match. again. As can be seen in de command extract above, the system property is set.
Any other suggestions ?
Downgrading Maven to 3.1.1 resolved the issue. For now this is a solution for me.

custom maven GWT build fails on openshift

On RedHat OpenShift I have created a jenkins build server. To get it working for my custom build I've changed the config.xml to have numExecutors=1. Then I added a maven gwt project to build. The build fails because it can not create the user preferences directory. See this log snippet.
[INFO] --- gwt-maven-plugin:2.5.0-rc2:compile (default) # web ---
[INFO] auto discovered modules [de.hpfsc.parent]
[ERROR] Apr 09, 2014 2:06:42 AM java.util.prefs.FileSystemPreferences$1 run
[ERROR] WARNING: Couldn't create user preferences directory. User preferences are unusable.
[ERROR] Apr 09, 2014 2:06:42 AM java.util.prefs.FileSystemPreferences$1 run
[ERROR] WARNING: java.io.IOException: No such file or directory
To test the correct working of simple maven builds I created a new jenkins project on https://github.com/abroer/jsltSpringLocaleProblem.git. This maven project works correctly and is being built without errors.
The problem can be recreated by building the https://github.com/steinsag/gwt-maven-example.git project.
Here's the job configuration
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties>
<hudson.plugins.openshift.OpenShiftApplicationUUIDJobProperty plugin="openshift#1.4">
<applicationUUID></applicationUUID>
</hudson.plugins.openshift.OpenShiftApplicationUUIDJobProperty>
<hudson.plugins.openshift.OpenShiftBuilderSizeJobProperty plugin="openshift#1.4">
<builderSize>small</builderSize>
</hudson.plugins.openshift.OpenShiftBuilderSizeJobProperty>
<hudson.plugins.openshift.OpenShiftBuilderTimeoutJobProperty plugin="openshift#1.4">
<builderTimeout>300000</builderTimeout>
</hudson.plugins.openshift.OpenShiftBuilderTimeoutJobProperty>
<hudson.plugins.openshift.OpenShiftBuilderTypeJobProperty plugin="openshift#1.4">
<builderType></builderType>
</hudson.plugins.openshift.OpenShiftBuilderTypeJobProperty>
</properties>
<scm class="hudson.plugins.git.GitSCM" plugin="git#1.1.12">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<name>origin</name>
<refspec>+refs/heads/*:refs/remotes/origin/*</refspec>
<url>https://github.com/steinsag/gwt-maven-example.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>**</name>
</hudson.plugins.git.BranchSpec>
</branches>
<recursiveSubmodules>false</recursiveSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<authorOrCommitter>false</authorOrCommitter>
<clean>false</clean>
<wipeOutWorkspace>false</wipeOutWorkspace>
<pruneBranches>false</pruneBranches>
<remotePoll>false</remotePoll>
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
<gitTool>Default</gitTool>
<submoduleCfg class="list"/>
<relativeTargetDir></relativeTargetDir>
<excludedRegions></excludedRegions>
<excludedUsers></excludedUsers>
<gitConfigName></gitConfigName>
<gitConfigEmail></gitConfigEmail>
<skipTag>false</skipTag>
<scmName></scmName>
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers class="vector"/>
<concurrentBuild>false</concurrentBuild>
<builders>
<hudson.tasks.Maven>
<targets>clean package</targets>
<mavenName>(Default)</mavenName>
<usePrivateRepository>false</usePrivateRepository>
<settings class="jenkins.mvn.DefaultSettingsProvider"/>
<globalSettings class="jenkins.mvn.DefaultGlobalSettingsProvider"/>
</hudson.tasks.Maven>
</builders>
<publishers/>
<buildWrappers/>
</project>
AFAICT, these messages shouldn't fail the compilation.
GWT uses preferences only in one place: update checks, so store when it last checked for updates. This is done asynchronously in a dedicated thread, and shouldn't fail the build.
GWT supports disabling update checks by passing the -XdisableUpdateCheck to the Compiler, but the gwt-maven-plugin doesn't let you do it. Try using the exec-maven-plugin to call the GWT compiler and pass the -XdisableUpdateCheck as argument to see if it fixes your problem.

mvn release:prepare doesn't work using maven 3

My JAVA_HOME is properly set up to /usr/local/java/jdk1.7.0_01
$echo $JAVA_HOME
/usr/local/java/jdk1.7.0_01
$sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
* 2 /usr/local/java/jdk1.7.0_01/bin/java 1 manual mode
3 /usr/local/java/jre1.7.0_01/bin/java 1 manual mode
I am using mvn release:prepare plugin to produce the git tag and flip project's version in the pom.xml. It works perfect if I use maven 2.2.1 When I use maven 3.0.4, I get:
[INFO] Error: JAVA_HOME is not defined correctly.
[INFO] We cannot execute /usr/local/java/jdk1.7.0_01/bin/java/bin/java
I guess there might be a bug in maven 3, when it runs, it tries to append /bin/java twice to my JAVA_HOME.
Try using the standard Oracle/Sun JDK, if that is an option at all. I have hit this myself before on Debian/Ubuntu. I never had the patience to figure out what was wrong with the OpenJDK, but it doesn't cope well with Maven. Or... at least... such was my observation.
JAVA_HOME must point to jre, then set :
export JAVA_HOME=/usr/local/java/jdk1.7.0_01/jre
Search JAVA_HOME in your mvn command file (use which mvn to find it).
Mine does handle the JAVA_HOME if not already defined.
So perhaps you can get around it by unset JAVA_HOME
remove the file in old maven home and it will change to new one.
mv /usr/local/Cellar/maven/3.8.1/libexec /usr/local/Cellar/maven_bak
before that, you need to export your jdk and maven firstly. and how to do this, you can see following link.
https://stackoverflow.com/a/67715235/11679986

Resources