I have a Windows virtual machine with OpenJDK 13 installed that I would like to setup as a Jenkins node/agent.
When I create the node configuration using the Jenkins UI and select Launch Method: Launch Agent by connecting it to the master it provides a link to download slave-agent.jnlp
On a system with the original jdk/jre older than version 9, which contains java web start, if I run that jnlp file, it brings up a window with a menu that includes an option File - Install as A Service
However, as OpenJDK (and I believe any JRE/JDK versions greater than 8) do NOT contain Java Web Start, I cannot seem to gain access to that option.
I am able to successfully run java -jar agent.jar -jnlpUrl https://jenkinsserver/blah/slave-agent.jnlp -secret blah -workDir "somedirectory" and have the node register with Jenkins, but it is not running as a service.
I had an older agent that was still using old version of JRE, so I looked at its Jenkins service configuration and unfortunately it seems to be relying on executable(s), .config file(s), and xml file(s), which I cannot determine the source of, beyond they must be created when running the "Install as a service" instructions from slave-agent.jnlp
I also attempted to use IcedTea-Web which is apparently supposed to be a Java Web Start replacement, but I've had no success.
Can anyone tell me how to setup a Windows machine running OpenJDK as a Jenkins node/agent with the Jenkins node/agent components running as a Windows service?
I had a similar issue and now I use NSSM.
Download NSSM
Open a cmd and install the service (I used JenkinsService as Servicename):
<path to nssm.exe>\nssm install <Servicename>
Insert the path to the jdk to the field Path
add the rest to the field Arguments:
-jar agent.jar -jnlpUrl https://jenkinsserver/blah/slave-agent.jnlp -secret blah -workDir "somedirectory"
Click on install the service
Now you can check the new service JenkinsService in the windows service manager. As soon as it's running you can check the connection to the master.
If you want to setup a Java base application as a service, I believe the best option would be to use Procrun from Apache. It is the exact method that Tomcat uses.
Related
I compiled a Servlet with java 15 and tried to run it with Tomcat 10 but got the error:
"java.lang.UnsupportedClassVersionError: Servlet1 has been compiled by a more recent version of the Java Runtime"
Looking at the Tomcat Properties I noticed Tomcat uses Java 8 that is installed also on my PC.
So I went to the Tomcat Properties under the Java tab and put down jdk-15.0.1\bin\jvm.dll
-> Tomcat didn't start anymore.
I noticed that in the same properties under the Java tab, there is "Java Classpath" but it's value was
Tomcat-Dir\bin\bootstrap.jar (I think). Then I changed this to jdk-15.0.1\bin (and variations thereof).
Now to my problem - Tomcat doesn't start anymore "ClassNotFoundException ... Bootstrap" I can change back the path to the JVM by checking "Use default", but I don't remember exactly the path under "Java Classpath". Can someone tell me what the default value needs to be here for Tomcat10. I would like to at least be able to start Tomcat again.
I'm talking about this Tab in the Tomcat properties
The problem you are describing (immediate service start failure, nothing in Tomcat's logs and a short line in commons-daemon.log) happens when there is a mismatch between the architecture of the Procrun service application (installed as bin\tomcat10.exe in your Tomcat installation) and the architecture of the jvm.dll: a 32-bit executable cannot load a 64-bit library and viceversa.
You can confirm it with tomcat10.exe version (works only in an administrator cmd)) and java -version.
To solve this you need to download the complete Apache Commons Daemon distribution for Windows (cf. download area) and replace tomcat10.exe with the appropriate prunsrv.exe executable (there are two versions in the zip archive).
Regarding which libraries should be in Tomcat's classpath, you just need bin\bootstrap.jar and bin\tomcat-juli.jar in your server's installation folder.
Remark: The Windows MSI installer for Tomcat contains both prunsrv.exe versions, but installs only one depending on the architecture of the Java executable you choose during installation. Probably you have a 32-bit Java 8 and 64-bit Java 15. For a long time the java.com page automatically proposed the 32-bit version of Java.
I tried to install OpenJDK 12 in jenkins, with *.tar.gz installer but i get the error Cannot run program "/bin/java"
JAVA_HOME=/var/jenkins_home/tools/hudson.model.JDK/java12
Note I created the directory "hudson.model.JDK" myself.
here is the tool configuration
full error log
JDK 12 has one bug logged
https://bugs.openjdk.java.net/browse/JDK-6746185
according to this Malformed URL is invalid, So jenkins is not able to download JDK
Simple solution is download JDk from this link, or whatever you like and add Open JDK in jenkins as I do
https://download.java.net/java/GA/jdk12.0.1/69cfe15208a647278a19ef0990eea691/12/GPL/openjdk-12.0.1_linux-x64_bin.tar.gz
Download JDK and extract it to one folder.
Manage Jenkins> Global Configurations> Add JDK>
1. Name: Open JDK(Or whatever you want)
2. JAVA_HOME: \Open_JDK\
like in my case
E:\Open_JDK\openjdk-11.0.2_windows-x64_bin\jdk-11.0.2
in jenkins
Save and exit, everything working fine
Happy Jenkins, Happy to help
JDK Tool Plugin in Jenkins only support the automatic download of version up to Java SDK 1.9 so I will write the process made by me in order to config OpenJDK-11(I'm using this specific version but another version can be used) in a Jenkins running in a Docker container:
Login into the host server where the docker container is running using SSH
service.
Check the running containers with the command: docker ps
Get in into the Jenkins container with the command(in my case, the container name is "jenkins"): docker exec -it containerName /bin/bash
Download the OpenJDK 11: cd /usr/local && wget https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz
Unpack the downloaded file: tar -zxvf openjdk-11+28_linux-x64_bin.tar.gz
Now you will have a folder "jdk-11" under /usr/local.
Go to Global Tools Configuration in Jenkins and set up the SDK config like the showed image:
Now you can make use of a different version of Java SDK in Jenkins builds using as label "Java SE 11".
JDK 12 is not yet supported by Jenkins.
Link: https://jenkins.io/doc/administration/requirements/java/
Background:
I am currently working in a Linux Virtual Machine on some Java plugins that I install into Eclipse by placing them into the /opt/eclipse/dropins folder. My plugins need to support both CentOS 6 and CentOS 7 VMs (shouldn't be a big deal since they are written in Java and both flavors of CentOS have Java 1.8.0 installed). My plugins build and install just fine on both OSs. I see them in Eclipse and can interact with them as expected.
The VMs I need to support can either be local to my machine (opened with VMWare Player/Workstation) or hosted on a cloud server. We use Windows Remote Desktop to get into the cloud VMs through xrdp on the Linux server.
Problem:
One of my plugins needs nddsjava.so from /opt/rti_connext_dds-5.2.3/lib/x64Linux3gcc4.8.2.
On both local VMs (CentOS 6 and 7), I can just set the LD_LIBRARY_PATH in an /etc/profile.d script so that any user that logs in can get the path to the required C++ library.
On CentOS 7 cloud VMs, however, when this plugin is invoked, I get java.lang.UnsatisfiedLinkError: no nddsjava in java.library.path. This happens only when opening Eclipse via the Linux menus. If I open a terminal and start Eclipse from there, the plugin can find the C++ library (because my LD_LIBRARY_PATH is set in my /bin/bash terminal). I did a little digging and found out that running chmod g-s /usr/bin/ssh-agent fixes the issue when opening Eclipse from the Linux menus (yes I understand that the chmod opens a security vulnerability. I am willing to look past this).
On CentOS 6 cloud VMs, I have never gotten the plugin to find the C++ library. LD_LIBRARY_PATH seems to get wiped when signing in through xrdp and for whatever reason, CentOS 6 appears to be explicitly not sourcing any of the profile scripts in the main top-level gnome-session process, which means other processes spawned from the GUI will not have LD_LIBRARY_PATH either.
I have also tried adding -Djava.library.path to my eclipse.ini file with no luck. It will fail on the next C++ library needed even though it lives in the same directory: java.lang.UnsatisfiedLinkError: /opt/rti_connext_dds-5.2.3/lib/x64Linux3gcc4.8.2/libnddsjava.so: libnddsc.so: cannot open shared object file: No such file or directory
Question:
Is there a single place that I can set my LD_LIBRARY_PATH for all flavors of Linux I am attempting to support (local CentOS 6, xrdp CentOS 6, local CentOS 7, and xrdp CentOS 7)?
Note: When I say cloud VM below, I mean server hosted VM in which I Windows-Remote-Desktopped into via xrdp.
This answer from server fault worked for me in the CentOS 6 cloud VM. The CentOS 7 cloud VM did not have the startwm.sh script in /etc/xrdp. Instead, it lived in /usr/libexec/xrdp and did not contain the xinitrc lines (referenced in the server fault link) causing the issue in the CentOS 6 cloud VM. Something else must be wiping the LD_LIBRARY_PATH variable in the CentOS 7 cloud VM, so I still needed to perform chmod g-s /usr/bin/ssh-agent to allow my /etc/profile.d script to be invoked on startup.
I am starting a Windows Server AMI and would need to have java 8 installed after boot. I already have an instance-setup.txt script to install the codedeploy-agent automatically (from here: http://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-set-up-new-instance.html), but would need to install Java 8 at the same time. I have no idea how to automatize this though, did anyone manage to do it successfully by any chance ?
Thanks !
Emmanuel
The Java installers for Windows provide the ability to run an installation in silent mode via the command line or a script. If you package a Java installation executable with your deployment you can run a silent install like this:
jre-8-windows-i586.exe /s
Check out the documentation on Windows Installer Options for Java for more information and other available options: http://docs.oracle.com/javase/8/docs/technotes/guides/install/windows_installer_options.html
I am trying to run shell scripts in Windows XP using Java. I found that we can run shell scripts using cygwin in Windows, but what if it is not installed on the system?
I want to check whether it is installed on machine, if it is not installed - add that software as a part of my application and install it.
If cygwin complains with windows installer standards then when you install it you should be able to find a registry entry for this program.
You should check the registry for something like localmachine/software/cygwin.... this validation can be done using RegistryKey class in c#.
To include this program as a dependency you must provide the way you are installing your app, visual studio windows installer? Inno installer?