I am using Tomcat 7.0 and I found a reference of how to change session savings into the database. But I don't get how to change
org.apache.catalina.session.StandardSession.ACTIVITY_CHECK to true
The link that I am referencing is http://www.intelligrape.com/blog/2010/07/21/tomcat-6-session-persistence-through-jdbcstore/
I am using localhost Tomcat 7.X downloaded as zip, MySQL 5.5, STS 3.1(Incuding Eclipse)
Any figuring out?
This is a system property ( http://tomcat.apache.org/tomcat-7.0-doc/config/systemprops.html ) so to set these you have to specify the -D option. In your case "-Dorg.apache.catalina.session.StandardSession.ACTIVITY_CHECK=true".
But where? Well, System Properties are given to the Java process when it starts. In case of Tomcat you can use a environment variable called $JAVA_OPTS which is given to the Java process on startup. So
export JAVA_OPTS="$JAVA_OPTS -Dorg.apache.catalina.session.StandardSession.ACTIVITY_CHECK=true"
and then run Tomcat. For this to persist make sure that the user running catalina.sh has this environment variable always set.
add below line in catalina.bat just after where you found other JAVA OPTS already being set.
set "JAVA_OPTS=%JAVA_OPTS% -Dorg.apache.catalina.session.StandardSession.ACTIVITY_CHECK=true"
e.g.
rem Register custom URL handlers
rem Do this here so custom URL handles (specifically 'war:...') can be used in the security policy
set "JAVA_OPTS=%JAVA_OPTS% -Djava.protocol.handler.pkgs=org.apache.catalina.webresources"
set "JAVA_OPTS=%JAVA_OPTS% -Dorg.apache.catalina.session.StandardSession.ACTIVITY_CHECK=true"
Related
This question already has answers here:
Passing JVM arguments to Tomcat when running as a service?
(2 answers)
Closed 3 years ago.
We currently run the tomcat 8.5 as windows service. How is it possible to pass over a java property i.e. via -D parameter to the startup of the service?
do we can pass over a parameter through the service properties dialogue "startup parameters" of the windows operating system (Service Manager). If yes what would be the syntax?
do we need to hard code that property somewhere in the startup bat files of tomcat, if yes which ones?
other possibilities i.e. system variable like CATALINA OPTS?
Thank you and regards
Mark
First sure that you had ran Service.bat install then please run Tomcat7w (or Tomcat8w, Tomcat9w if you use another Tomcat version).
Select and add Java Properties in Java Options.
If you install service with another name, example service.bat install TomcatApp then please rename Tomcat7w to before open.
This is from the Environment Variable Prerequisites section of the catalina.bat script in Tomcat 8.5:
rem JAVA_OPTS (Optional) Java runtime options used when any command
rem is executed.
rem Include here and not in CATALINA_OPTS all options, that
rem should be used by Tomcat and also by the stop process,
rem the version command etc.
rem Most options should go into CATALINA_OPTS.
You should be able to set the JAVA_OPTS environment variable with your custom -D parameters.
I've been trying to automate the creation of our development environment by combining batch files and WLST, but I am struggling to change the memory WebLogic server will start with.
Currently we are manually changing the memory settings in the <DOMAIN_HOME>/bin/setDomainEnv.cmd script, but this is a workaround. It should be possible to to do it automatically without much effort.
Setting the Domain
The script that sets the Domain in pretty simple:
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_45
set MW_HOME=C:\dev\wls1036_dev
set DOMAIN_HOME=C:\dev\domain
cd %MW_HOME%
call configure.cmd
mkdir %DOMAIN_HOME%
cd %DOMAIN_HOME%
%JAVA_HOME%\bin\java.exe -Xmx1024m -XX:MaxPermSize=256m -Dweblogic.management.username=weblogic -Dweblogic.management.password=welcome1 weblogic.Server
I've tried to use some variables in this script such as MEM_ARGS, JAVA_OPTIONS, but none of these are forwarded to the final configuration of the domain, later it always starts with 512 heap, and 128 perm, which are not enough.
WLST memory start args
We are using Eclipse, and it does call the startWebLogic.cmd as start script. It is the standard configuration.
I tried to use the following WLST script. It does set the server start arguments, but WebLogic is not using those properties and loads not enough memory.
edit()
startEdit()
cd('/Servers/myserver/ServerStart/myserver')
cmo.setArguments('-Xmx1024m -XX:MaxPermSize=256m')
activate()
Any ideas?
You can use the trick for getting ServerStart arguments:
Write simple offline WLST-script to get arguments from config.xml:
getArguments.py
import sys
readDomain(sys.argv[1])
cd('Server/%s/ServerStart/NO_NAME_0' % sys.argv[2])
argsFile = open('arguments.txt', 'w')
print >>argsFile, cmo.arguments
Add this script to startWeblogic.cmd like:
startWebLogic.cmd
...
set DOMAIN_HOME=%~dp0
path\to\wlst.cmd getArguments.py %DOMAIN_HOME% admin_server_name
set /p EXTRA_JAVA_PROPERTIES=<arguments.txt
call "%DOMAIN_HOME%\bin\startWebLogic.cmd" %*
There is no easy way of setting values when executing WebLogic from Eclipse. It'll call the batch script and, at least at current version, does not allow to send dynamic parameters.
We solved it making the setDomainEnv.cmd file part of our versioned configuration:
Copy the setDomainEnv.cmd file to your version control configuration.
Edit whatever you want (memory, etc)
Copy the file like copy custom\setDomainEnv.cmd %DOMAIN_HOME%\bin /y when running your development environment configuration script.
Now every time you configure your development environment memory values will be ready without manual intervention.
You have to reedit your stuff when updating WebLogic, so you don't end up with an outdated component.
I want to set a custom variable for my application in tomcat, and use System.getProperty in java to get it.
I tried :
MyV=test OR export MyV=test in setenv.sh
export -DMyV=test in
catalina.sh
export JAVA_OPTS="-DMyV=test" in catalina.sh
all above are not working, System.getProperty("MyV") always returns null when I start or debug tomcat.
so, what should I do to get the value of MyV,thank you!
My operation system is OS X, JDK version is 1.8 and I start tomcat in Eclipse.
You should try the JAVA_OPTS without quotes JAVA_OPTS=-DMyV=test
I'm running Weblogic locally, but will run also be run in production on server instances administred from weblogic server
I have set a system property in Weblogic using, "-DRUNTIME_ENVIRONMENT=LOCALHEST" under the menu item in Servers -> Configuration-> Server start -> Arguments:
I my java file, i have System.out.println("ENVR_:" + System.getProperty("RUNTIME_ENVIRONMENT"));
And it prints null, is there some argument i have missed?
Have to add "set JAVA_OPTIONS=%JAVA_OPTIONS% -Druntime.environment=local" to the startWebLogic.cmd file
I believe the settings on that page apply only if Node Manager is used. So you will need to start your application server with Node Manager and not using the command line or other means.
If you are using Linux/Mac OS(I am using WebLogic 12.2 on Mac):
Find the file startWebLogic.sh then edit
Find and this line change this line JAVA_OPTIONS="${SAVE_JAVA_OPTIONS} -Denv=dev"
-Denv=dev is the environment you want
I have 2 Java Web Projects. One runs on JDK 1.5 and the other runs on JDK 1.6. I want to run both of them on the same computer, but the JAVA_HOME environment variable can only have one value. I want to set JAVA_HOME for each Tomcat server.
place a setenv.sh in the the bin directory with
JAVA_HOME=/usr/java/jdk1.6.0_43/
JRE_HOME=/usr/java/jdk1.6.0_43/jre
or an other version your running.
One thing that you could do would be to modify the catalina.sh (Unix based) or the catalina.bat (windows based).
Within each of the scripts you can set certain variables which only processes created under the shell will inherit. So for catalina.sh, use the following line:
export JAVA_HOME="intented java home"
And for windows use
set JAVA_HOME="intented java home"
If you are a Windows user, put the content below in a setenv.bat file that you must create in Tomcat bin directory.
set JAVA_HOME=C:\Program Files\Java\jdk1.6.x
If you are a Linux user, put the content below in a setenv.sh file that you must create in Tomcat bin directory.
JAVA_HOME=/usr/java/jdk1.6.x
Also, note that there shouldn't be any space after =:
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_27
You can add setenv.sh in the the bin directory with:
export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
and it will dynamically change when you update your packages.
In UNIX I had this problem, I edited catalina.sh manually and entered
export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.24
echo "Using JAVA_HOME: $JAVA_HOME"
as the first 2 lines. I tried setting the JAVA_HOME in /etc/profile but it did not help.
This worked finally.
I think this is a best practice (You may be have many Tomcat instance in same computer, you want per Tomcat instance use other Java Runtime Environment):
This is manual inside file: catalina.sh
# JRE_HOME Must point at your Java Runtime installation.
# Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME
# are both set, JRE_HOME is used.
Linux based Tomcat6 should have /etc/tomcat6/tomcat6.conf
# System-wide configuration file for tomcat6 services
# This will be sourced by tomcat6 and any secondary service
# Values will be overridden by service-specific configuration
# files in /etc/sysconfig
#
# Use this one to change default values for all services
# Change the service specific ones to affect only one service
# (see, for instance, /etc/sysconfig/tomcat6)
#
# Where your java installation lives
#JAVA_HOME="/usr/lib/jvm/java-1.5.0"
# Where your tomcat installation lives
CATALINA_BASE="/usr/share/tomcat6"
...
I had the same problem my OS is windows 8 and I am using Tomcat 8,
I just edited the setclasspath.bat file in bin folder and set JAVA_HOME and JRE_HOME
like this...
#echo off
...
...
set "JRE_HOME=%ProgramFiles%\Java\jre8"
set "JAVA_HOME=%ProgramFiles%\Java\jdk1.7.0_03"
...
...
and it works fine for me now......
For Debian distro we can override the setting via defaults
/etc/default/tomcat6
Set the JAVA_HOME pointing to the java version you want.
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
Just a note...
If you add that code to setclasspath.bat or setclasspath.sh, it will actually be used by all of Tomcat's scripts you could run, rather than just Catalina.
The method for setting the variable is as the other's have described.
I think you only need add in startup.sh or startup.bat the set JAVA_HOME=C:\Program Files\Java\jdk-19
After check...