Problems about Jenkins running remote shell script - java

I have some question when using jenkins.
the scenario:
I have installed a tomcat on machine A,and config all necessary environment including JDK, and they work well.
I wrote a shell script named restart.sh to kill the tomcat process,and restart.
I execute the script and it works well.When I check the tomcat process using ps -ef,and it shows the exact JDK path as I already config.The JDK path is /usr/local/java/JDK7
When I execute the restart.sh script via jenkins,problem comes. I can see the tomcat process using the wrong JDK path,/usr/bin/java,not the path as i config. I use SSH Publishers plugin to run the remote script.see as the image below:
enter image description here
I don't know how this problem happen,please help,Thanks all

This might be the problem of path variables, just to cross verify , find JAVA_HOME on your server 1. By logging onto server manually 2. From Exec command of your ssh section of your jenkins job , most probably you will find the answer.
i'm assuming you're jenkins is configured to use jdk which is defined at its root level.
if this didn't solve , we need to look into this problem from another angle.

Related

Apache nifi doesn't start

I've tried several times to run an Apache Nifi server, but it won't work. I'm using windows 8 and installed java version 8.
I get this error message:
'nifi-env.bat' is not recognized as an internal or external command, operable program or batch file.The JAVA_HOME environment variable is not defined correctly.Instead the PATH will be used to find the java executable.
Error Screenshot:
I've tried the solution to the following similar problem, but this did not help:
Nifi commands on windows
I've also tried what is explained in this video, but this did not work either:
How to Install Apache NiFi and run Simple Process
What should I do in order to run the nifi?
There seems to be a Java installation error, which is affecting the nifi-env.bat file. Problem will be solved if you create a virtual environment with java. The following link explains how to create a Java Virtual environment. This will also solve the problem with 'nifi-env.bat' is not recognized as an internal or external command as in that case nifi would only be able to be run within the virtual environment.
Try to troubleshoot the problem by reinstalling java, if the above doesn't work out.
I have pulling my hair off for this, but I discovered the directory which holds nifi, must have not spaces.
My folder's name was "apache nifi" and there I unzipped the download from apache nifi's website, but after one hour I realized the name could be the problem, and actually it was. I just changed folder's name from "apache nifi" to just "nifi" and voilá, it just runs.
Check if JAVA_HOME path is set properly.

Restore old Jenkins jobs in Windows after the update

We were running plug-in rich Jenkins 2.46.1 and one of my team member tried to update Jenkins but it just hangs on displaying Please wait while Jenkins is restarting message for about 2 hours so I somehow forced Jenkins to shutdown and then started it using java -jar Jenkins.war command.
When Jenkins restarted again all my jobs were not displayed in Jenkins GUI but they were present in jobs and workspace folders so I tried an option Reload configuration from disk but that also did not restore jobs.
Please someone advice how I can restore my Jenkins jobs as they were before.
I believe you are not pointing JENKINS_HOME correctly. You may need something like this as startup script/batch file
For Linux:
export JENKINS_HOME=<path/to/old/jenkins/home>
java -jar Jenkins.war
For Windows:
set JENKINS_HOME=<path/to/old/jenkins/home>
java -jar Jenkins.war
Basically running war directly points to default temp directly for Jenkins Home. It can be overwritten by above environment variable. You can also centrally define it so that each start you do not need specify again.

OPENSHIFT editing LD_LIBRARY_PATH & PATH for environment setting

I am currently working on trying to deploy my java web application onto Openshift. My web application imports Gurobi library which requires a Gurobi License Environment to run my Linear Programming model. As such i've been going around trying everything i can to get the license installed to the openshift linux server etc
I've managed to get a few things going.
I've SSH into my application and registered the HostName of the openshift linux platform to the license.
I've managed to change the .bash_profile file which sets up the custom environments. below are the input i have placed into the file.
export GUROBI_HOME="/var/lib/openshift/54d4e281e0b8cd3a1400015c/jbossews/gurobi600/linux64"
export PATH="${PATH}:${GUROBI_HOME}/bin"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib"
export GRB_LICENSE_FILE="/var/lib/openshift/54d4e281e0b8cd3a1400015c/jbossews/gurobi.lic"
The problem with the input above is that I believe for PATH & LD_LIBRARY_PATH, openshift automatically reinstates them everytime I access my app through the shell.
I think this has resulted in my application being unable to instanciate a GRBENV object which is a Gurobi Environment object which checks the gurobi.lic file and use the LD_LIBRARY_FILE.
Has anyone did something similar to this before? Really need help in this.
Brandon
The way openshift instantiates your app and the ssh shell seems to be different. The correct place to set the environment variables are one of the start action_hooks. For instance, if you edit the .openshift/action_hooks/start file and add:
export PATH="${PATH}:${GUROBI_HOME}/bin"
this will work for the instance that runs your APP, but not for the SSH Shell. I did the following test:
echo $PATH > $OPENSHIFT_DATA_DIR/PATH
to confirm that the path running the APP can be set by the start hook.
I´m not sure if this solves your question (because you mention SSH shell, and I still don´t know how to set the PATH for that).

Neo4J Server Installation Linux AWS Centos OS -- service user cannot find java

I have downloaded Neo4J enterprise from the Neo site and have untar'd it under /opt
I have successfully downloaded and installed the Java 7 Server edition from the Oracle web site. Note after indicating I want a server JRE, Oracle downloads this : jdk1.7.0_51
I have untar'd both under /opt giving me /opt/neo4j-2.0.0 and /opt/jdk1.7.0_51
I have successfully installed Neo4J 2.O on AWS with Centos Linux, such that it should run as a Service under a service account. To do this I used the Neo install command. The command ran successfully
I can successfully start Neo4J as myself. After editing my ~/.bash_profile to define JAVA_HOME and exporting.
export JAVA_HOME="/opt/jdk1.7.0_51/"
export NEO4J_HOME="/opt/neo4j-2.0.0"
export PATH=$JAVA_HOME/bin:$NEO4J_HOME:$PATH
Apply
source ~/.bash_profile
cd /$NEO$J_HOME
bin/neo4j start
Works just fine.
However, we are not able to successfully get Neo to start as a service
sudo service neo4j-service start
which: no java in (/sbin:/usr/sbin:/bin:/usr/bin)
ERROR: Unable to find java. (Cannot execute )
* Please use Oracle(R) Java(TM) 7 to run Neo4j Server. Download "Java Platform (JDK) 7" from:
http://www.oracle.com/technetwork/java/javase/downloads/index.html
* Please see http://docs.neo4j.org/ for Neo4j Server installation instructions.
If I echo $JAVA_HOME it returns as expected
If I echo $PATH it returns as expected
by as expected we can see java on the path.
If I simply type java -version before I run sudo service neo4j-service start
the response shows the java version.
A bit of background: the Linux service command is not available unless I first run a special script per our normal it policies. However, the script clobbers the exports that I would otherwise use.
Accordingly the command
service neo4j-service start
returns
-bash: neo4j-service: command not found
indicating that the 'service' command cannot be found
So sudo is required in our environment to execute the service command
We have tried simply placing jdk1.7.0_51 under /sbin/jdk1.7.0_51 that does not work. We have also tried extracting the jre folder from jdk1.7.0_51 and placing it under /sbin/jre
Also tried creating a java.sh file under /etc/profile.d/
Still no success.
So the simple question....
Where is Neo4J 2.0.0 looking for Java when running as a service? Is it using the environment variable JAVA_HOME, or is it looking in one of the following locations as the Neo4J server error message would seem to indicate? "no java in (/sbin:/usr/sbin:/bin:/usr/bin)"
Under my installation configuration the neo4j service is intended to run under the account neo4jservice. Is this as simple as making sure JAVA_HOME is available to the neo4jservice accound? Why the error message "no java in (/sbin:/usr/sbin:/bin:/usr/bin)"?
Thanks in advance
I ran a test on my solaris and Linux Mint install and this seems to work for me
Perhaps it's not elegant, but it will get you going. Just drop the sudo part for your startup script.
sudo NEO4J_HOME="/opt/neo4j" JAVA_HOME="/usr/java" /opt/neo4j/bin/neo4j start
Obviously, modify the environment variables to your situation:
JAVA_HOME="/opt/jdk1.7.0_51/" NEO4J_HOME="/opt/neo4j-2.0.0" service neo4j-service start
Not quite the answer I was hoping for... as the answer seems to disregard this part of the original POST: "So sudo is required in our environment to execute the service command"
What does seem to work is modifying the neo4j-service script to include the exports.
neo4j-service is found at /etc/init.d

"Failed to create java" on running Windows service

I have a java application, which has to run as windows service.
I am able to install the service using the following command.
"%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass %STARTER% --StopClass %STOPPER% %START_PARAMS% %STOP_PARAMS%
The service is installed successfully but when i try to run it it shows Failed to create java. path also it is not showing in the jkartha log file.
I have JAVA_HOME environment variable pointing to jdk1.5.
and even i copied msvcr71.dll to windows\system32 folder and restarted the PC.
I am running this on windows 2008 server.
I didn't install apache tomcat server. prunsrv.exe and procmgr.exe i just copied.
Please suggest me how i need to overcome this problem.
whether to run application as windows service, prunsrv.exe, prunmgr.exe are enough is it? I am able to successfully install but not able to start why???
You probably need to set your service to run as the user that installed Java, otherwise it won't find its environment variables.
If you must run in the default Local System account, then you can run a batch file that sets up the environment and then launches java.exe.

Categories

Resources