Monday, July 24, 2017

Jenkins slave node gives error /bin/java": java.io.IOException: error=2 when trying to build project

/bin/java": java.io.IOException: error=2
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.(UNIXProcess.java:164)
    at java.lang.ProcessImpl.start(ProcessImpl.java:81)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:476)


As the error indicates the you need to check the environment variables 'JAVA_HOME' or 'java.home' on the slave node. You need to make sure that 'JAVA_HOME' or 'java.home' is pointing to say in linux /opt/common/vendor/jdk1.7.0_79 and not /opt/common/vendor/jdk1.7.0_79/jre.

To check the configuration you can login to Jenkins as admin and then
select Manage Hudson/Jenkins then choose Manage Nodes.
there should be a Node Properties section.
Check the Tool Locations checkbox.
Click on Add/Update then Select your JDK in the dropdown list and add the path to it.

sonar-maven-plugin Insufficient privileges

When using "sonar-maven-plugin" as part of the jenkins build process, you might encounter this error message "[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project service1-data: Insufficient privileges -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project service1-data: Insufficient privileges
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
".

To fix this issue make sure that jenkins continuous integration (CI) job is building with correct projects' pom.xml in multi-module project. For example if your project has the following hierarchy
project/pom.xml
project/folder1/pom.xml
project/folder2/pom.xml

then if jenkins CI build is using project/pom.xml then
the sonar jenkins job (using sonar-maven-plugin) should also be using project/pom.xml

If the jenkins CI job is using project/pom.xml but sonar jenkins job is using different pom.xml say project/folder1/pom.xml then you will get above error.

Saturday, December 10, 2016

Tuesday, November 22, 2016

Nexus 5 disable autoplay music via bluetooth

Using Nexus 5 with kitkat 4.4.4, once you have paired a bluetooth device with your phone, you might have noticed when when the bluetooth device is detected and connected, music or videos starts playing automatically.

To disable this feature you need to go to

Settings -> bluetooth -> paired devices ->
Select the bluetooth device
under profiles -> uncheck "Media audio"

Tuesday, November 1, 2016

Nexus 5 power button reboot/restart

If you have an issue with your Nexus 5 phone's power button wherein the phone just restarts/reboots after pressing the power button then you need to boot in recovery mode and select 'wipe cache partition'. This worked for Kitkat 4.4.2 version of Android installed in the Nexus 5.

Detailed list of steps are present at this google link.

Registry key Error: Java version has value '1.8', but '1.7' is required


When working with multiple versions of Java SDK installed in your computer, you might come across this error where you have installed Java8 and then when you try to run/compile an application using Java6 or Java7 you get stuck.

Essentially you need to make sure that the  system 'path' variable points to the Java version that you need. When installing Java8 there are lot of folders that get added to the 'path' like 'C:\programdata\Oracle\Java\' or c:\program files\java\java8\nin, etc Once these folders are deleted from the 'path' variable then you will not get this error. Make sure that any windows command prompts are re-opened once changes have been done to the 'path' variable.

The below two posts nicely summarize the fix needed to make Java8 co-exist along with Java6/7.
http://stackoverflow.com/questions/26324486/properly-installing-java-8-along-with-java-7
http://stackoverflow.com/questions/29697543/registry-key-error-java-version-has-value-1-8-but-1-7-is-required

Sunday, June 5, 2016

How to add custom/local jars to a maven project as in-project repository

There are certain times when you will need to add a custom jar that is not present in a central or local repository as part of the maven build/compile goals. This jar along with others would need to be shipped out as part of the jar depdencies that are needed for the program to run. If you encounter such a suitation then follow the steps below to add the custom/local jar to your project.

1) Create a folder called 'lib' in your project root hierarchy.
For example if you have a project called c:\myTestProject then create a folder c:\myTestProject\lib

2) Copy the jar file to c:\myTestProject
For example lets say that we need to add a jar called abcd.jar to our project. So copy abcd.jar to c:\myTestProject\abcd.jar

3) Using maven 2.3 onwards, from windows command line, issue the command
mvn install:install-file -Dfile=c:\myTestProject\abcd.jar -DgroupId=com.xyz.myproject -DartifactId=abcd -Dversion=1.0.0 -Dpackaging=jar -DlocalRepositoryPath=c:\myTestProject\lib -DgeneratePom=true

After running that command, you will see the below folder created with the jar in it
c:\myTestProject\lib\com\xyz\myproject\abcd-1.0.0.jar


Now you can delete the c:\myTestProject\abcd.jar

4) Make the below changes to your projects pom.xml file

Note: file://${project.basedir}\lib has a \lib (backlash\lib) which is needed to work on windows computers
 

<project>
...
...

<repositories>
  <repository>
    <id>my-local-repo</id>
    <releases>
        <enabled>true</enabled>
    </releases>
    <snapshots>
        <enabled>true</enabled>
    </snapshots>
    <url>file://${project.basedir}\lib</url>
  </repository>
</repositories>

<dependencies>
    <dependency>
         <groupId>com.xyz.myproject</groupId>
        <artifactId>abcd</artifactId>
        <version>1.0.0</version>
    </dependency>
    ...
    ...
</dependencies>

...
...
<project>

After following the above steps, if you are still not able to build the project using maven and maven says that it cannot locate the abcd.jar file then check the maven settings ${maven_home}\.m2\settings.xml file
set the <mirrorOf> tag as mentioned below

<mirrors>
    <mirror>
        <mirrorOf>*<mirrorOf>
        ...
        ...
    </mirror>
</mirrors>