Setting CATALINA_OPTS for tomcat6 on windows doesn't work - jmx

I'm trying to setup Tomcat6 to work with JMX on Windows Vista 64.
To do that I need to pass the parameters below to Tomcat6.
What I do in command prompt. (that doesn't work)
set CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9898 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
tomcat6.exe
What I do that does work (but causes other problems)
java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9898 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -jar bootstrap.jar
It seems as if tomcat is just ignoring the environment variable CATALINA_OPTS.
Am I doing something wrong?
--- Update - Since writing this i've tried to edit catalina.bat and define the variable CATALINA_OPTS there. No success. (tried adding the parameters to JAVA_OPTS too, no success either)
Thanks in Advance!!

Ignoring the possibility that TC6 could be broken in that environment as I can't check it myself, there are a couple of things you can check:
You have two - characters in your CATALINA_OPTS line in the first parameter, should be one. That would break it, I expect.
If not that:
Is anything else in your Tomcat startup script overwriting CATALINA_OPTS?

Silly me, I started tomcat with tomcat6.exe instead of startup.bat.
Now works.
Thanks!

Related

Grails: how to define configuration profile when launching grails war with java command?

I have a grails 3.0 application packaged as war file, and I would like to run it with java command line. Things looks simple from the reference guide: java -jar my_war_file_name. But I cannot find a way to pass in the profile (dev/test/prod), and also it looks like -D option cannot overwrite the configuration as well. Any idea?
Best Regards
Sorry, I found the problem. I should put -D in front of -jar. So this is working:
java -Dgrails.env=prod -Dserver.port=xxxx -jar my_war_file

System properties management

Is there any "adequate" way to change system properties in Jenkins? What is the easiest/fastest way change them? For instance, I need to turn off the useless (in my case) pinging thread.
If you really want a quick and simple way to change a system property, you can use the script console
System.setProperty("hudson.remoting.Launcher.pingIntervalSec", 0)
But that won't survive a restart. To make it permanent, add the setting to the java args. For me (CentOS, Jenkins 2.7.1) that's a line about halfway down /etc/sysconfig/jenkins (for other distributions I believe it's /etc/default/jenkins) where you should add your option to the existing list like this:
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Dhudson.remoting.Launcher.pingIntervalSec=0"
You'll have to restart Jenkins after you make that change (thanks Mark Tickner)
If you run Jenkins on windows as a service without tomcat, you can edit jenkins.xml. Add the property in <service><arguments> before the -jar.
Than restart the service.
<service>
<!-- ... -->
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -Dhudson.tasks.MailSender.SEND_TO_UNKNOWN_USERS=true -Dhudson.tasks.MailSender.SEND_TO_USERS_WITHOUT_READ=true -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments>
The system properties available and how to set them are listed on the wiki:
https://wiki.jenkins-ci.org/display/JENKINS/Features+controlled+by+system+properties
To disable slave pinging, you can set hudson.remoting.Launcher.pingIntervalSec to 0.
System properties can be set in the same way as with any other Java program, e.g.:
java -Dhudson.remoting.Launcher.pingIntervalSec=0 -jar jenkins.war
If you use Tomcat on Windows you can edit the File C:\apache-tomcat-7.0.67\conf\catalina.properties and simply add the Line
hudson.DNSMultiCast.disabled=true
at the End of the File. Then safe the File and restart Tomcat.
I have the similar problem: I need to disable DNSMultiCast (set hudson.DNSMultiCast.disabled = false) and I can't understand how to do it
for example, https://wiki.jenkins-ci.org/display/JENKINS/Features+controlled+by+system+properties - there is such advice "...pass all of these arguments before the -jar argument..." but I run jenkins under tomcat so I am not sure I can change startup parameters.
I tried to change /etc/tomcat6/Catalina/localhost/jenkins.xml to
<?xml version="1.0" encoding="UTF-8"?>
<Context >
<Environment name="JENKINS_HOME" value="/var/jenkins"
type="java.lang.String" override="false"/>
<Environment name="hudson.DNSMultiCast.disabled" value="true"
type="java.lang.Boolean" override="false"/>
</Context>
but I didn't help.
Can someone explain how to change jenkins system properties when tomcat is used.
Maybe it's a bad hack but I set it in the pipeline job that needs the setting.
Like this:
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "") // allow formatted HTML pages to be published
It seems to work - as far as I can tell...
I followed each steps mentioned above but it fails.
So I did change the system time zone using timedatectl set-timezone Europe/London command and then I have restarted jenkins service service jenkins restart it worked.
I was using Rehdat 7.5
Jenkins version 2.168.
Jenkins Installed via yum install jenkins
I hope this will help some one.

Jenkins: console output characters

Does anyone know how to beat such chars in Jenkins console output log?
Seems there is a problem with UTF-8.
The issue here is that the characters are not being output as UTF-8 to your console. I think the solution is to tell jenkins when you invoke it to write output as UTF-8. See this solution for a similar problem UTF-8 char encoding does not work on console (Linux)
Something like
java -Dfile.encoding=UTF-8 jenkins.war might do the trick
In Jenkins ver. 2.46.2, I just got this to work by going to Nodes, Advanced settings, JVM Options and putting -Dfile.encoding=UTF8 and then taking that node offline and online again. Hope this helps other people. It would be great if UTF8 support was default.
To give the the answer more complete.
If you use an tomcat container to run jenkins, then edit catalina.sh config file:
vim apache-tomcat-path/bin/catalina.sh
Add -Dfile.encoding=UTF-8 to the JAVA_OPTS var and restart tomcat will do the trick.
For those who are using a build-agent and a pipeline, add this to the agent's dockerfile, and no further jenkins settings are needed
ENV JAVA_TOOL_OPTIONS -Dfile.encoding=UTF-8
Try to change the encoding with you are opening your file to 'utf-8' and check your encoding saved for the script in vs code(whatever platform)
enter image description here
I've tried everything with file.encoding variable, but didn't work.
My solution was to check environment locale variables in Jenkins Controller and Agent node where job is actually runing, and make them match.
In my case, agent node running the job required environment variable "LC_ALL=C.UTF-8", which was already defined in controller node.
More details here: https://stackoverflow.com/a/68217405/3284482
Try using AnsiColor plugin in Jenkins. This worked for me. I had tried all the above solutions but nothing happened. As I downloaded AnsiColor plugin everything got fixed!

Jenkins service start error on red hat linux

The jenkins service does not start when ever i run jenkins service start . It says
Starting Jenkins bash: /usr/bin/java: No such file or directory
[FAILED]
I have java installed at /usr/lib/jvm/jdk1.7.0_51. The JAVA_HOME variable is also set. Also tried adding this java to /etc/init.d/jenkins file. I need to use the sun jdk, not open jdk.
Tried some of the alternatives from stackoverflow as well but did not work out.
Any suggestions will be of great help.
Thanks,
Bhargav
Thanks Paul. The script inside /etc/sysconfig/jenkins needs to be edited. Else it uses the default java.
JENKINS_JAVA_CMD="path of java installation"
Along with the above script, one can make changes to /etc/init.d/jenkins file if needed to add the path of java installation in your system.
I'd guess that there's a script that has /usr/bin/java hardcoded. When you find the culprit, remove the /usr/bin so that it uses the default. Or you can change it to use the JAVA_HOME path, something like this:
JAVA_EXECUTABLE=$JAVA_HOME/bin/java
$JAVA_EXECUTABLE $JAVA_OPTS etc.. etc..

What are default JVM options used by grails run-app

According to this page:
http://grails.github.io/grails-howtos/en/performanceTuning.html#s3, the grails run-app command will provide some options to the JVM itself, such as -XX:MaxPermSize. So, my question is, what options are provided by the grails run-app command by default? The reason that I am asking this is that I am doing some benchmarking in the development mode, so I want to make sure that I am actually changing something when I provide JVM options through GRAILS_OPTS.
Thank you in advance.
You can get the detail in startGrails.bat present in
GRAILS_HOME/bin/
Default setting for GRAILS_OPTS (if not provided by user) looks like
GRAILS_OPTS=-server -Xmx768M -Xms64M
-XX:PermSize=32m -XX:MaxPermSize=256m -Dfile.encoding=UTF-8
which gets overriden based on the command used. In case of run-app I think the default is used unless otherwise specified by user as environment variable.

Resources