I have a problem. i have 3 tomcat directories in my windows 8 system :
D:/apache tomcat 6/
D:/apache tomcat 6_old/
D:/tomcat6/
The last two folders are old and dirty. I want to use fresh first one; so I am trying to run it.
D:/apache tomcat 6/bin/tomcat6.exe
But strangely windows runs tomcat with configuration and webapps in third one (D:/tomcat6/).
I have set CATALINA_HOME in environment variable; but no effect.
Can you please help. Thanks.
Setting CATALINA_HOME helps, but you have to use startup.bat to start Tomcat, not the tomcat6.exe
You can also do this with a small batch file (I use it that way since I have a lot of tomcat installations on my computer. Here is one of my scripts:
setlocal
cd C:\mock\apache-tomcat-7.0.27\bin
set CATALINA_HOME=C:\mock\apache-tomcat-7.0.27
call startup.bat
Don't see any reason why starting first tomcat starts a different one.
You can remove unused tomcat directories, so that you just have single Tomcat. Also make sure to kill all java/tomcat processes and then start the required one.
Change your CATALINA_HOME
from
D:/tomcat6/
to
D:/apache tomcat 6/
also make sure the following is added to path variable
%CATALINA_HOME%\bin;
Related
Can anyone please explain the below problem.
I'm using tomcat 8 and when I'm trying to start startup.bat file, the command prompt is opening and closing immediately just like blinking. However in the past while I'm working with java programs it worked fine but recently I installed Xampp and there in it again tomcat is downloaded "C:\xampp\tomcat". The same problem comes here in this folder as well, when I try to run startup.bat file. But when I use "XAMPP control panel" to start the Tomcat its able to get start and I'm getting "localhost:8080" start page in the browser.
The connector port for both tomcats are 8080 and I tried with changing the port number in tomcat 8 but no use. There should not be 2 tomcat servers in a single system? If not, why? (I've not installed them, both are in C drive)
I want to work with java servlet programs now.So I need use of tomcat. I've set below environment user varibles:
JAVA_HOME to C:\Program Files\Java\jdk1.8.0_65;
path to C:\Program Files\Java\jdk1.8.0_65\bin;C:\apache-maven-3.3.9\bin
Please suggest the solutions.
Thanks in advance.
I think you should check the tomcat log to find some clues, it is in log folder of your tomcat installation folder. Maybe you have missed some startup variable in start.bat for your new installed things.
BTW, if you want to keep seeing what happened in startup, try to run startup.bat in a command line console, but not double click it through your mouse. It will continue on generating log output in that console.
I am running a Tomcat8 server on linux (RedHat). The machine it runs on has a total of 15GB Ram of which i want to allocate 11GB to the tomcat server. Currently it only has 3.3GB avaialable for use.
I have openjdk 64 bit installed.
I am trying to set CATALINA_OPTS to -Xms512M -Xmx11g and the JAVA_OPTS to -d64 -Xms256m -Xmx12g.
I found several how-to's saying something about a setenv.sh or catalina.sh both of which I cannot find: neither under tomcat8/bin, catalina_home or catalina_base which both point to /root.
So how do I increase available memory for my Tomcat server?
Thanks!
It seems that catalina.sh is either no longer existent in the latest tomcat release or it has something to do with the fact that i am using a amazon vm and they have some kind of modified tomcat8 distribution what i would doubt.
Solution:
under usr/share/tomcat8/conf/ there is a tomcat8.conf file.
Adding the row JAVA_OPTS="-Xms1g -Xmx12g" did the trick.
UPDATE:
Please check the comments below this post
In distributions such as RedHat the standard Tomcat structure is dispersed in different locations and the main catalina.sh is indeed not present.
There are two configuration files you may find. Assuming Tomcat 8, you'll find:
/etc/tomcat8/tomcat8.conf - this is the master file
/etc/sysconfig/tomcat8 - this is per service file which inherits from the above.
This split is designed so that you can have multiple Tomcat instances running which share some settings and have distinct settings for the 1st/2nd/3rd instance.
If you want to change the location of the software, for example, normally this would be shared so you would change /etc/tomcat8/tomcat8.conf, but if you want to change command line arguments (to pass context to a Tomcat instance) or change memory of the particular instance, you'd use /etc/sysconfig/tomcat8. You second instance of tomcat could be named tomcat8b in which case its configuration file would be /etc/sysconfig/tomcat8b.
If you have no intention of running a second instance, then change either file.
catalina.sh is under tomcat/bin
I am a newbie to Ubuntu 12.10 and moved to it from Windows.
In Windows I have configured the environment variable to include servlet-api.jar in the CLASSPATH variable so I do not have to type -cp <path to servlet-api.jar> every time I compile.
For normal Java programs, I have set the JAVA_HOME using:
export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-i386" >> ~/.bashrc
With that solved, I need to set the CLASSPATH but do not know how to.
Please help on that!
Also I read on some forums that I should change the CLASSPATH manually each time I compile because changing the CLASSPATH may upset other applications.
Next, I tried this command to start Tomcat
service tomcat7 start but I got an error :
You need root privileges to run this script I do not know why. Help me solve that!
And if within the scope, please tell me how the directory structure of tomcat in Windows differs from that in Ubuntu.
Misc
I used sudo apt-get install tomcat7 to get Tomcat 7.
You don't say whether you're using an Ubuntu Tomcat package or a standalone Tomcat installation.
For a standalone Tomcat, you will be starting and stopping it using the scripts in its bin directory: startup.sh and shutdown.sh. In that case, Tomcat will use the environment variable values set at the time of invocation.
When doing this, you can set the environment variables prior to running these commands.
The same is true for the Tomcat 6 or Tomcat 7 that Ubuntu distributes as packages.
These neatly separate the $CATALINA_HOME directory (where the Tomcat 7 distribution is supposed to be) from the $CATALINA_BASE directory (where all of the changes and additions for a particular Tomcat instance are supposed to be. For the tomcat7 package, the first directory is /usr/share/tomcat7, while the second is /var/lib/tomcat7.
You can find startup.sh and shutdown.sh in /usr/share/tomcat7/bin and of course you can use them.
However, if you use the Tomcat provided with Ubuntu, you're probably going to want to run it just like any other standard system service, and the packages support this: e.g. in the case of tomcat7, you can just use
sudo service tomcat7 status
sudo service tomcat7 start
sudo service tomcat7 stop
sudo service tomcat7 restart
just like you can for any system service, and it uses the same mechanism as other system services do:
the shell script /etc/init.d/tomcat7 is used to start and stop Tomcat 7
/etc/default/tomcat7 is its configuration file, allowing a few parameters to be set
Using this method, you cannot specify additional environment variables for Tomcat to use by setting them in your shell or in /etc/default/tomcat7; they will not be passed to Tomcat.
However, there is a second method to set environment variables: if you set them in the shell script /var/lib/tomcat7/bin/setenv.sh (or, if you must, /usr/share/tomcat7/bin/setenv.sh), they will be picked up and passed to Tomcat. This method always works.
Finally, Tomcat offers finer control than just using a $CLASSPATH when it comes to specifying additional classes or JARs to be loaded on startup: in its conf/catalina.properties configuration file, you can set the common.loader, server.loader and shared.loader to a list of directories and/or JAR files to be loaded in additional to the standard ones.
All it means is that you should do that as a superuser - which translates to administrator in windows so you should try something like sudo service tomcat7 start
Try export CLASSPATH=/usr/share/tomcat7/lib/servlet-api.jar:/usr/share/tomcat7/lib/jsp-api.jar - This will depend on where your tomcat installation in located.
You can get more here
Cheers
This is just an assumption, but I'm following the log of catalina.out and it looks like every time I would expect a value from an environment variable there is nothing. For example:
java.io.FileNotFoundException: /logs/adminLog.log (No such file or directory) where it should go to $CATALINA_BASE/logs/adminLog.log and $CATALINA_BASE=/var/lib/tomcat6
I've set the environment variables this webapp uses as system wide in the /etc/environment file. I've checked and after restarting they are still there. But tomcat insists of reading blanks.
Any ideas of why this is happening? Am I missing something?
You should put tomcat / webapp specific environment variables into setenv.sh in tomcat's bin directory. Create one if it does not exists.
Depends on how you start Tomcat up. Let us say you are starting as user 'test' (assuming unix machine.). Login as 'test' and check environment variables are there in your environment with the 'env' command.
If it is there then Tomcat when started from that shell, with tomcat/bin/startup.sh will be able to read them.
Now, Tomcat will only read variables it understands. If you are setting your own, then your application needs to read them.
There are numerous places on the Internet, suggesting that it is easily achieved by any (or all) of the following methods:
through CATALINA_OPTS
through JAVA_OPTS
through TOMCAT_OPTS
by placing the set statements in the setenv.bat file inside the tomcat's bin folder
My problem, is that I have tried all of the above and my web application still does not see my system property!
Here is what I am doing:
Stop tomcat7 service
set CATALINA_OPTS=-Dabc.def=true in the system environment
set JAVA_OPTS=-Dabc.def=true in the system environment
set TOMCAT_OPTS=-Dabc.def=true in the system environment
put all of the above into c:\Program Files\Apache Software Foundation\Tomcat 7.0\bin\setenv.bat (seems totally redundant, but just in case)
Start tomcat7 service
Inspect the environment of the tomcat7 process using the Process Explorer tool - the environment is correct, I do see both CATALINA_OPTS and JAVA_OPTS and TOMCAT_OPTS equal to -Dabc.def=true
run my web app, which is a simple servlet dumping all the system properties to the response stream - abc.def is not amongst them
Please, put me out of my misery and tell me how to do it.
For the Tomcat service, startup settings are stored in the registry under Options key at:
HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Procrun 2.0\Tomcat<X>\Parameters\Java
(substitute appropriate Tomcat version where needed).
Edit:
On 64-bit Windows, the registry key is:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\Procrun 2.0\Tomcat<X>\Parameters\Java
even if Tomcat is running under a 64-bit JVM.
I know this post is almost 9 years old but thought someone might find this useful.
Although #prunge and #mark answers were very accurate and following their logic I was able to add system properties to my tomcat 7 instance running on Windows, there is an easier way.
In the installation directory of Tomcat there is an exe you can run called
%INSTALL_DIRECTORY%\bin\tomcat7w.exe
This opens up a Tomcat properties windows where you can control the service i.e. start and stop tomcat and there is a tab (Java) that allows you to set the Java properties as well
Scroll to the end of that panel under "Java Options" and add your system properties
-Dpropertyname=value
Then navigate back to the General tab and restart tomcat
I have tested this and my grails app now can see my properties. I use the following Groovy code to get the property out
System.properties.getProperty("propertyname")
Adding the system properties in the Windows registry showed up in this window as well so its one and the same thing, just this application seems to me to be slightly more convenient.
Hope this helps someone else